Skip to main content

ErasedTensorOperationsExpand

Trait ErasedTensorOperationsExpand 

Source
pub trait ErasedTensorOperationsExpand<E: Numeric> {
    // Required methods
    fn __expand_vector_size_method(&self, scope: &Scope) -> VectorSize;
    fn __expand_lines_method(&self, scope: &Scope) -> NativeExpand<usize>;

    // Provided methods
    fn __expand_read_line_method(
        &self,
        _scope: &Scope,
        _index: NativeExpand<usize>,
    ) -> ExpandValue { ... }
    fn __expand_write_line_method(
        &mut self,
        _scope: &Scope,
        _index: NativeExpand<usize>,
        _value: ExpandValue,
    ) { ... }
}
Expand description

What a backing has to answer to be an ErasedTensor.

Expand-only, and that is the whole point: the value crosses as an ExpandValue, which is untyped in the IR, so the trait can be object-safe without the width appearing in it. The implementor knows its own width and is the one that can check the caller’s against it.

Only the two width-free queries are required. A backing implements __expand_read_line_method or __expand_write_line_method for the half it can serve, and declares it with ReadsLines / WritesLines; the defaults are unreachable for a backing that declares itself honestly.

§Invariant

The line methods take and return an untyped ExpandValue, so nothing in their signature ties the value to a width. Every caller in this module checks the width against __expand_vector_size_method first, and a caller that skips the check builds IR whose type is a lie.

Required Methods§

Source

fn __expand_vector_size_method(&self, scope: &Scope) -> VectorSize

The line width this backing takes, in scalars.

Source

fn __expand_lines_method(&self, scope: &Scope) -> NativeExpand<usize>

How many lines the backing holds, which is what a checked access is checked against.

Provided Methods§

Source

fn __expand_read_line_method( &self, _scope: &Scope, _index: NativeExpand<usize>, ) -> ExpandValue

Read one line at index, counted in lines of vector_size.

Source

fn __expand_write_line_method( &mut self, _scope: &Scope, _index: NativeExpand<usize>, _value: ExpandValue, )

Write one line at index, counted in lines of vector_size.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<E: Numeric, N: Size> ErasedTensorOperationsExpand<E> for TensorExpand<Vector<E, N>>

A launched tensor, reached through the indirection anyway.

The degenerate case, and the one a test compares the interesting cases against.

Implementors§

Source§

impl<E: Numeric, N: Size, IO: Clone> ErasedTensorOperationsExpand<E> for VirtualTensorExpand<E, N, IO>

A VirtualTensor is the backing an erased tensor most often wraps, so it is one without the caller writing an adapter.

The write half is declared only for ReadWrite, which is the same gate VirtualTensor itself puts on write.

Source§

impl<E: Numeric, N: Size, V> ErasedTensorOperationsExpand<E> for ErasedView<V, N>

Source§

impl<E: Numeric, N: Size, V> ErasedTensorOperationsExpand<E> for ErasedViewMut<V, N>