docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IModelStorage

    An interface that provides methods for storing variables.

    Inherited Members
    IDisposable.Dispose()
    Namespace: Unity.Sentis
    Assembly: Unity.Sentis.dll
    Syntax
    public interface IModelStorage : IDisposable

    Methods

    AllocateTensor(TensorShape, DataType, BackendType)

    Allocates a new Tensor. First tries to get a old one from the memory pool, if not create a new one

    Declaration
    Tensor AllocateTensor(TensorShape shape, DataType dataType, BackendType backendType)
    Parameters
    Type Name Description
    TensorShape shape

    The desired TensorShape.

    DataType dataType

    The desired DataType.

    BackendType backendType

    The desired BackendType.

    Returns
    Type Description
    Tensor

    The allocated tensor.

    AllocateTensorAndStore(int, TensorShape, DataType, BackendType)

    Allocates a new Tensor and stores the result of execution for a given tensor index. Reuses a tensor from a memory pool if possible or creates a new one.

    Declaration
    Tensor AllocateTensorAndStore(int index, TensorShape shape, DataType dataType, BackendType backendType)
    Parameters
    Type Name Description
    int index

    The index of the output.

    TensorShape shape

    The desired TensorShape.

    DataType dataType

    The desired DataType.

    BackendType backendType

    The desired BackendType.

    Returns
    Type Description
    Tensor

    The allocated tensor.

    Dispose(Tensor)

    Release tensor to allocator to backend's internal pool.

    Declaration
    void Dispose(Tensor tensor)
    Parameters
    Type Name Description
    Tensor tensor

    The tensor to dispose.

    DisposeAfterLayer(Layer)

    Disposes storage that can be deleted after executing a given layer.

    Declaration
    void DisposeAfterLayer(Layer forLayer)
    Parameters
    Type Name Description
    Layer forLayer

    The layer to dispose the temporary storage of.

    DisposeOnExecute()

    Disposes storage that can be deleted before executing the whole model.

    Declaration
    void DisposeOnExecute()

    GetDataType(int)

    Retrieves data type of tensor for given index.

    Declaration
    DataType GetDataType(int tensorIndex)
    Parameters
    Type Name Description
    int tensorIndex

    The tensor index.

    Returns
    Type Description
    DataType

    The retrieved data type.

    GetFloat(int, float)

    Reads single value of float tensor.

    Declaration
    float GetFloat(int tensorIndex, float defaultValue = 0)
    Parameters
    Type Name Description
    int tensorIndex

    The tensor index.

    float defaultValue

    The default value to return if the tensor is null.

    Returns
    Type Description
    float

    The retrieved float value.

    GetFloats(int, ReadOnlySpan<float>)

    Reads values of 1D float tensor.

    Declaration
    ReadOnlySpan<float> GetFloats(int tensorIndex, ReadOnlySpan<float> defaultValue = default)
    Parameters
    Type Name Description
    int tensorIndex

    The tensor index.

    ReadOnlySpan<float> defaultValue

    The default value to return if the tensor is null.

    Returns
    Type Description
    ReadOnlySpan<float>

    The retrieved float values as a read only span.

    GetInt(int, int)

    Reads single value of integer tensor.

    Declaration
    int GetInt(int tensorIndex, int defaultValue = 0)
    Parameters
    Type Name Description
    int tensorIndex

    The tensor index.

    int defaultValue

    The default value to return if the tensor is null.

    Returns
    Type Description
    int

    The retrieved integer value.

    GetInts(int, ReadOnlySpan<int>)

    Reads values of 1D integer tensor.

    Declaration
    ReadOnlySpan<int> GetInts(int tensorIndex, ReadOnlySpan<int> defaultValue = default)
    Parameters
    Type Name Description
    int tensorIndex

    The tensor index.

    ReadOnlySpan<int> defaultValue

    The default value to return if the tensor is null.

    Returns
    Type Description
    ReadOnlySpan<int>

    The retrieved integer values as a read only span.

    GetTensor(int)

    Retrieves Tensor for given index.

    Declaration
    Tensor GetTensor(int index)
    Parameters
    Type Name Description
    int index

    The index for which to retrieve its underlying Tensor.

    Returns
    Type Description
    Tensor

    The retrieved tensor.

    GetTensorShape(int)

    Retrieves shape of tensor for given index.

    Declaration
    TensorShape GetTensorShape(int tensorIndex)
    Parameters
    Type Name Description
    int tensorIndex

    The tensor index.

    Returns
    Type Description
    TensorShape

    The retrieved tensor shape.

    PeekTensor(int)

    Returns a reference to default output tensor of a given index. This is non-blocking.

    The reference is valid only until you call Execute() or Dispose() on the worker.

    Declaration
    Tensor PeekTensor(int index)
    Parameters
    Type Name Description
    int index

    The index of the tensor to peek.

    Returns
    Type Description
    Tensor

    The output tensor.

    PrepareStorage(Model, bool)

    Prepares storage for a given model.

    Declaration
    void PrepareStorage(Model model, bool takeoverWeights = false)
    Parameters
    Type Name Description
    Model model

    The model to prepare the storage of.

    bool takeoverWeights

    Whether the execution can take ownership of the weights of the model.

    SetInput(int, Tensor)

    Sets a given input with a tensor.

    Declaration
    void SetInput(int index, Tensor X)
    Parameters
    Type Name Description
    int index

    The name of the input.

    Tensor X

    The tensor for the input.

    Store(int, Tensor)

    Stores the result of execution for a given tensor index.

    Declaration
    void Store(int index, Tensor result)
    Parameters
    Type Name Description
    int index

    The index of the tensor to store.

    Tensor result

    The tensor result of execution.

    TakeTensorOwnership(int)

    Take ownership the output tensor of a given index. This is non-blocking.

    Remove all reference to tensor in storage.

    Declaration
    Tensor TakeTensorOwnership(int index)
    Parameters
    Type Name Description
    int index

    The index of the tensor to gain ownership.

    Returns
    Type Description
    Tensor

    The tensor.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)