Skip to main content

Crate tenferro_tensor

Crate tenferro_tensor 

Source
Expand description

Core tensor types, views, backend traits, and backend-independent contracts.

§Owned Tensors And Views

TypedTensor<T> and the dtype-erased Tensor enum are owned tensor values. They are the right representation when a result is materialized as compact column-major storage.

TypedTensorView is a borrowed typed view over an existing tensor buffer. It carries logical shape, arbitrary strides, and an offset, so metadata-only layout changes such as transposes, slices, and broadcasts can be represented without copying. Backend-aware code materializes and copies views through TensorViewCanonicalization, preserving placement and backend execution policy.

TensorRead is the dtype-erased borrowed input type used by eager kernels and backend dispatch. It can borrow either an owned Tensor or a TensorView with arbitrary strides. Prefer TensorRead for read-only operation inputs so callers are not forced to materialize layout-only views.

TensorOwnedView and TensorValue are the owned lazy-value forms. Use them when an API must store a view result beyond the lifetime of a borrowed input, then expose a short-lived TensorRead at kernel-dispatch time.

Use Tensor::as_slice or TypedTensorView::as_slice only when compact contiguous storage is part of the API contract. Use shape/stride-aware kernel paths or TensorRead otherwise.

§Examples

use tenferro_tensor::{Tensor, TypedTensor};

let a = Tensor::F64(TypedTensor::from_vec_col_major(vec![2], vec![1.0, 2.0]).unwrap());
assert_eq!(a.shape(), &[2]);

Re-exports§

pub use backend::default_backend_session;
pub use backend::BackendCachedDot;
pub use backend::BackendRuntimeCache;
pub use backend::BackendSession;
pub use backend::BackendSessionHost;
pub use backend::ContractionScalar;
pub use backend::DotGeneralAccumulation;
pub use backend::ElementwiseReadOp;
pub use backend::SessionCachedDot;
pub use backend::TensorAnalytic;
pub use backend::TensorBackend;
pub use backend::TensorBuffer;
pub use backend::TensorDeviceTransfer;
pub use backend::TensorDot;
pub use backend::TensorElementwise;
pub use backend::TensorFusion;
pub use backend::TensorIndexing;
pub use backend::TensorReduction;
pub use backend::TensorStructural;
pub use backend::TensorViewCanonicalization;
pub use cache::CacheStats;
pub use cache::RuntimeCacheControl;
pub use capability::capability_output_dtype;
pub use capability::BackendId;
pub use capability::CapabilityAxis;
pub use capability::CapabilityQuery;
pub use capability::OperationCapability;
pub use capability::SupportLevel;
pub use capability::TensorBackendCapability;
pub use config::CompareDir;
pub use config::DotGeneralConfig;
pub use config::GatherConfig;
pub use config::PadConfig;
pub use config::ScatterConfig;
pub use config::SliceConfig;
pub use error::BoxError;
pub use error::Error;
pub use error::Result;
pub use types::col_major_strides;
pub use types::AllocationDomainId;
pub use types::AllocationId;
pub use types::BackendBuffer;
pub use types::Buffer;
pub use types::BufferHandle;
pub use types::CpuDomainId;
pub use types::DType;
pub use types::DeviceId;
pub use types::DeviceKind;
pub use types::GpuBackendKind;
pub use types::HostAccessError;
pub use types::HostReadGuard;
pub use types::HostWriteGuard;
pub use types::MemoryKind;
pub use types::Placement;
pub use types::SharedTensorAllocationDomain;
pub use types::StridedSliceSpec;
pub use types::Tensor;
pub use types::TensorBufferRef;
pub use types::TensorBufferRefMut;
pub use types::TensorOwnedView;
pub use types::TensorRead;
pub use types::TensorScalar;
pub use types::TensorValue;
pub use types::TensorView;
pub use types::TensorViewMut;
pub use types::TensorWrite;
pub use types::TypedTensor;
pub use types::TypedTensorView;
pub use types::TypedTensorViewMut;
pub use types::TypedTensorViewMutPair;
pub use types::TypedTensorWrite;

Modules§

backend
cache
Cache accounting primitives shared by tensor backends and facade runtimes.
capability
Backend operation capability descriptors.
config
core
Lightweight backend-independent host tensor data model.
dispatch
Dtype-stripping dispatch macros for erased tensor values.
error
Runtime error types for tensor execution.
types
validate
Validation helpers shared across backends and exec layers.

Macros§

with_scalar
Dispatch a dtype-erased Tensor to a typed tensor body.
with_scalar_read
Dispatch a TensorRead to a typed tensor view body.

Structs§

DynRank
Dynamic tensor rank marker.
Rank
Static tensor rank marker.
SliceSpec
Explicit slice descriptor.
TensorLayout
Storage-neutral tensor layout metadata.

Enums§

ErrorKind
Coarse classification shared by crate-local error types.
ShapeMismatch
Structured facts describing why two tensor shapes are incompatible.
TensorRef
Core-neutral tensor input reference.
ValidationError
Structured validation failures owned by the tensor data model.
ValidationKind
Coarse classification for shared tensor validation failures.

Traits§

IntoShapeVec
Convert a common shape container into the dynamic owned shape type.
TensorRank
Rank contract for tensor metadata shapes and strides.

Type Aliases§

ShapeVec
Small tensor shape vector with inline capacity for common dynamic ranks.
StrideVec
Small tensor stride vector with signed element strides.