Interface ITensorAllocator
Interfaces for tensor allocator
Namespace: Unity.Barracuda
Syntax
public interface ITensorAllocator : IDisposable
Methods
Alloc(TensorShape, AllocScope, DataType)
Allocate
Declaration
Tensor Alloc(TensorShape shape, AllocScope scope = AllocScope.LayerOutput, DataType dataType = DataType.Float)
Parameters
| Type | Name | Description | 
|---|---|---|
| TensorShape | shape | shape  | 
| AllocScope | scope | tensor lifetime scope  | 
| DataType | dataType | tensor data type  | 
Returns
| Type | Description | 
|---|---|
| Tensor | allocated Tensor  | 
Alloc(TensorShape, ITensorData, AllocScope, DataType)
Allocate with existing ITensorData buffer
Declaration
Tensor Alloc(TensorShape shape, ITensorData buffer, AllocScope scope = AllocScope.LayerOutput, DataType dataType = DataType.Float)
Parameters
| Type | Name | Description | 
|---|---|---|
| TensorShape | shape | shape  | 
| ITensorData | buffer | buffer  | 
| AllocScope | scope | tensor lifetime scope  | 
| DataType | dataType | 
Returns
| Type | Description | 
|---|---|
| Tensor | allocated Tensor  | 
MoveToDevice(Tensor, ITensorData, ITensorData, Boolean)
Move Tensor to device
Declaration
void MoveToDevice(Tensor x, ITensorData newBuffer, ITensorData oldBuffer, bool disposeDetachedBufferHint)
Parameters
| Type | Name | Description | 
|---|---|---|
| Tensor | x | Tensor  | 
| ITensorData | newBuffer | new buffer  | 
| ITensorData | oldBuffer | old buffer  | 
| Boolean | disposeDetachedBufferHint | dispose detached buffer hint  | 
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)
Release Tensor
Declaration
void Release(Tensor x, bool calledFromTensorDispose)
Parameters
| Type | Name | Description | 
|---|---|---|
| Tensor | x | Tensor  | 
| Boolean | calledFromTensorDispose | called from tensor dispose flag  | 
Reset(Boolean)
Reset allocator
Declaration
void Reset(bool keepCachedMemory)
Parameters
| Type | Name | Description | 
|---|---|---|
| Boolean | keepCachedMemory | keep cached memory flag  | 
WaiveOwnership(Tensor)
Waive ownership
Declaration
void WaiveOwnership(Tensor x)
Parameters
| Type | Name | Description | 
|---|---|---|
| Tensor | x | Tensor  |