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::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
TensorReadto a typed tensor view body.
Structs§
- Allocation
Group - One group of move-only owners and append-only logical descriptors.
- Complex
- A complex number in Cartesian form.
- Default
Scalars - Dynamic host tensor over the crate’s preset scalar set.
- Descriptor
Slot - A group-local descriptor lookup key. It carries no ownership authority.
- DynRank
- Dynamic tensor rank marker.
- Erased
Host Tensor - A host tensor whose element type is recovered at run time.
- Native
Session Ref - An exclusively borrowed backend-leaf execution session.
- Rank
- Static tensor rank marker.
- Slice
Spec - Explicit slice descriptor.
- Tensor
Layout - Storage-neutral tensor layout metadata.
Enums§
- DType
- Runtime scalar dtype tag.
- Default
Scalars Ref - Core-neutral tensor input reference.
- Default
Scalars View - Dynamic borrowed host tensor view.
- Error
Kind - Coarse classification shared by crate-local error types.
- Group
Error - Group construction and slot errors.
- Session
Entry Error - Why a backend refused to open an execution session.
- Shape
Mismatch - Structured facts describing why two tensor shapes are incompatible.
- Validation
Error - Structured validation failures owned by the tensor data model.
- Validation
Kind - Coarse classification for shared tensor validation failures.
Traits§
- Into
Rank Shape - Convert a shape container into the representation required by a tensor rank.
- Into
Shape Vec - Convert a common shape container into the dynamic owned shape type.
- Scalar
Set - A closed set of scalar types carried by one tensor value type.
- Tensor
Rank - Rank contract for tensor metadata shapes and strides.