Interface IModelStorage
An interface that provides methods for storing variables.
Inherited Members
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(string, 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(string index, TensorShape shape, DataType dataType, BackendType backendType)
Parameters
Type | Name | Description |
---|---|---|
string | 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()
GetTensor(string)
Retrieves Tensor for given index.
Declaration
Tensor GetTensor(string index)
Parameters
Type | Name | Description |
---|---|---|
string | index | The index for which to retrieve its underlying Tensor. |
Returns
Type | Description |
---|---|
Tensor | The retrieved tensor. |
PeekTensor(string)
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(string index)
Parameters
Type | Name | Description |
---|---|---|
string | 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(string, Tensor)
Sets a given input with a tensor.
Declaration
void SetInput(string index, Tensor X)
Parameters
Type | Name | Description |
---|---|---|
string | index | The name of the input. |
Tensor | X | The tensor for the input. |
Store(string, Tensor)
Stores the result of execution for a given tensor index.
Declaration
void Store(string index, Tensor result)
Parameters
Type | Name | Description |
---|---|---|
string | index | The index of the tensor to store. |
Tensor | result | The tensor result of execution. |
TakeTensorOwnership(string)
Take ownership the output tensor of a given index. This is non-blocking.
Remove all reference to tensor in storage.
Declaration
Tensor TakeTensorOwnership(string index)
Parameters
Type | Name | Description |
---|---|---|
string | index | The index of the tensor to gain ownership. |
Returns
Type | Description |
---|---|
Tensor | The tensor. |