pub trait TensorStorage:
Send
+ Sync
+ 'static {
// Required methods
fn dtype(&self) -> &Symbol;
fn len(&self) -> usize;
fn location(&self) -> TensorLocation;
fn cell(&self, index: usize) -> Result<Value>;
fn materialize(&self) -> Result<Arc<dyn TensorStorage>>;
fn as_any(&self) -> &dyn Any;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Storage behind the canonical Tensor value.
Implementations may keep cells in host-native or resident layouts.
Observation is fallible: a resident implementation performs and caches its
checked readback in materialize. A successful
materialization must return host storage with the same dtype and length.
Required Methods§
Sourcefn location(&self) -> TensorLocation
fn location(&self) -> TensorLocation
The current storage placement.
Sourcefn materialize(&self) -> Result<Arc<dyn TensorStorage>>
fn materialize(&self) -> Result<Arc<dyn TensorStorage>>
Returns a host-observable form of this storage.
Resident implementations cache both success and failure so repeated or concurrent observations perform at most one readback.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".