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.

TensorValue is the owned lazy-value form. Use it 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::from_typed::<f64>(TypedTensor::from_vec_col_major(vec![2], vec![1.0, 2.0]).unwrap());
assert_eq!(a.shape(), &[2]);

Re-exports§

pub use backend::has_active_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::ReinterpretError;
pub use error::Result;
pub use types::col_major_strides;
pub use types::AllocationDomainId;
pub use types::AllocationId;
pub use types::BackendStorage;
pub use types::BackendStorageHandle;
pub use types::ColMajorView;
pub use types::ColMajorViewMut;
pub use types::CpuDomainId;
pub use types::DeviceId;
pub use types::DeviceKind;
pub use types::Dynamic;
pub use types::Gpu;
pub use types::GpuBackendKind;
pub use types::Host;
pub use types::HostAccessError;
pub use types::HostReadGuard;
pub use types::HostWriteGuard;
pub use types::MemoryKind;
pub use types::Placement;
pub use types::Representation;
pub use types::SharedTensorAllocationDomain;
pub use types::StorageBuffer;
pub use types::StridedSliceSpec;
pub use types::Tensor;
pub use types::TensorRead;
pub use types::TensorScalar;
pub use types::TensorStorageRef;
pub use types::TensorStorageRefMut;
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::TypedTensorViewMutSplit;
pub use types::TypedTensorWrite;

Modules§

backend
cache
Cache accounting primitives shared by tensor backends and facade runtimes.
capability
Backend operation capability descriptors.
config
core
Backend-independent rank/layout, dtype and scalar metadata re-exported from tenferro-tensor-core. It holds metadata only: every tensor type, including the default scalar set, is exported from this crate’s root.
dispatch
Dtype-stripping dispatch macros for erased tensor values.
error
Runtime error types for tensor execution.
prelude
Common tensor types for constructing and inspecting values.
types
validate
Validation helpers shared across backends and exec layers.

Macros§

define_scalar_set
Define a closed scalar set: its tag type, its value enum, and its membership.
with_scalar
with_scalar_read
Dispatch a TensorRead to a typed tensor view body.

Structs§

AllocationGroup
One group of move-only owners and append-only logical descriptors.
Complex
A complex number in Cartesian form.
DefaultScalars
Dynamic host tensor over the crate’s preset scalar set.
DescriptorSlot
A group-local descriptor lookup key. It carries no ownership authority.
DynRank
Dynamic tensor rank marker.
ErasedHostTensor
A host tensor whose element type is recovered at run time.
NativeSessionRef
An exclusively borrowed backend-leaf execution session.
Rank
Static tensor rank marker.
SliceSpec
Explicit slice descriptor.
TensorLayout
Storage-neutral tensor layout metadata.

Enums§

DType
Runtime scalar dtype tag.
DefaultScalarsRef
Core-neutral tensor input reference.
DefaultScalarsView
Dynamic borrowed host tensor view.
ErrorKind
Coarse classification shared by crate-local error types.
GroupError
Group construction and slot errors.
SessionEntryError
Why a backend refused to open an execution session.
ShapeMismatch
Structured facts describing why two tensor shapes are incompatible.
ValidationError
Structured validation failures owned by the tensor data model.
ValidationKind
Coarse classification for shared tensor validation failures.

Traits§

IntoRankShape
Convert a shape container into the representation required by a tensor rank.
IntoShapeVec
Convert a common shape container into the dynamic owned shape type.
ScalarSet
A closed set of scalar types carried by one tensor value type.
TensorRank
Rank contract for tensor metadata shapes and strides.

Type Aliases§

Complex32
The 32-bit complex scalar the exported dispatch macros name.
Complex64
The 64-bit complex scalar the exported dispatch macros name.
ShapeVec
Small tensor shape vector with inline capacity for common dynamic ranks.
StrideVec
Small tensor stride vector with signed element strides.