Interface ITensorAllocator
An interface that provides methods for allocating tensors.
Inherited Members
Namespace: Unity.Sentis
Syntax
public interface ITensorAllocator : IDisposable
Methods
Alloc(TensorShape, DataType, DeviceType, AllocScope)
Allocates a tensor of a given shape, data type on a given device type, and given scope.
Declaration
Tensor Alloc(TensorShape shape, DataType dataType, DeviceType deviceType, AllocScope scope = AllocScope.LayerOutput)
Parameters
Type | Name | Description |
---|---|---|
TensorShape | shape | |
DataType | dataType | |
DeviceType | deviceType | |
AllocScope | scope |
Returns
Type | Description |
---|---|
Tensor |
Alloc(TensorShape, DataType, ITensorData, AllocScope)
Allocates a tensor of a given shape, data type, and a given scope from an existing ITensorData
buffer.
Declaration
Tensor Alloc(TensorShape shape, DataType dataType, ITensorData buffer, AllocScope scope = AllocScope.LayerOutput)
Parameters
Type | Name | Description |
---|---|---|
TensorShape | shape | |
DataType | dataType | |
ITensorData | buffer | |
AllocScope | scope |
Returns
Type | Description |
---|---|
Tensor |
MoveToDevice(Tensor, ITensorData, ITensorData, Boolean)
Moves a tensor to a device.
Declaration
void MoveToDevice(Tensor x, ITensorData newBuffer, ITensorData oldBuffer, bool disposeDetachedBufferHint)
Parameters
Type | Name | Description |
---|---|---|
Tensor | x | |
ITensorData | newBuffer | |
ITensorData | oldBuffer | |
Boolean | disposeDetachedBufferHint |
PostLayerCleanup()
Allows ITensorAllocator to run cleanup operations such as clearing temporary buffers only used in the scope of the last layer executed.
Declaration
void PostLayerCleanup()
Release(Tensor, Boolean)
Releases a tensor.
Declaration
void Release(Tensor x, bool calledFromTensorDispose)
Parameters
Type | Name | Description |
---|---|---|
Tensor | x | |
Boolean | calledFromTensorDispose |
Reset(Boolean)
Resets the allocator.
Declaration
void Reset(bool keepCachedMemory)
Parameters
Type | Name | Description |
---|---|---|
Boolean | keepCachedMemory |
WaiveOwnership(Tensor)
Waives ownership of a tensor.
Declaration
void WaiveOwnership(Tensor x)
Parameters
Type | Name | Description |
---|---|---|
Tensor | x |