Class ReferenceCPUOps
Reference CPU implementation of IOps
Inherited Members
Namespace: Unity.Barracuda
Assembly: Unity.Barracuda.dll
Syntax
public class ReferenceCPUOps : IOps, IOpsStatistics
Constructors
ReferenceCPUOps(ITensorAllocator)
Create ReferenceCPUOps
Declaration
public ReferenceCPUOps(ITensorAllocator allocator = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ITensorAllocator | allocator | allocator |
Methods
Abs(Tensor)
Abs
Declaration
public virtual Tensor Abs(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Acos(Tensor)
Acos
Declaration
public virtual Tensor Acos(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Acosh(Tensor)
Acosh
Declaration
public virtual Tensor Acosh(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Add(Tensor[])
Add tensors together
Declaration
public virtual Tensor Add(Tensor[] tensors)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
ArgMax(Tensor, int)
ArgMax
Declaration
public virtual Tensor ArgMax(Tensor X, int axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int | axis | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
ArgMin(Tensor, int)
ArgMax
Declaration
public virtual Tensor ArgMin(Tensor X, int axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int | axis | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Asin(Tensor)
Asin
Declaration
public virtual Tensor Asin(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Asinh(Tensor)
Asinh
Declaration
public virtual Tensor Asinh(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Atan(Tensor)
Atan
Declaration
public virtual Tensor Atan(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Atanh(Tensor)
Atanh
Declaration
public virtual Tensor Atanh(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
AvgPool2D(Tensor, int[], int[], int[])
2D average pooling
Declaration
public virtual Tensor AvgPool2D(Tensor X, int[] pool, int[] stride, int[] pad)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | pool | pooling |
| int[] | stride | stride |
| int[] | pad | padding |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Bernoulli(float)
Bernoulli distribution
Declaration
protected float Bernoulli(float p)
Parameters
| Type | Name | Description |
|---|---|---|
| float | p | p |
Returns
| Type | Description |
|---|---|
| float | random value |
Border2D(Tensor, int[], float)
2D border padding
Declaration
public virtual Tensor Border2D(Tensor X, int[] pad, float value)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | pad | padding |
| float | value |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Border3D(Tensor, int[], float)
3D border padding
Declaration
public virtual Tensor Border3D(Tensor X, int[] pad, float value)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | pad | padding |
| float | value |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Ceil(Tensor)
Ceil
Declaration
public virtual Tensor Ceil(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Clip(Tensor, float, float)
Clip
Declaration
public virtual Tensor Clip(Tensor X, float min, float max)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| float | min | min value |
| float | max | max value |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Concat(Tensor[], int)
Concatenate tensors across axis
Declaration
public virtual Tensor Concat(Tensor[] tensors, int axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
| int | axis | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
ConstantOfShape(TensorShape, DataType, float)
Creates a constant of shape input
Declaration
public virtual Tensor ConstantOfShape(TensorShape X, DataType type, float value = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| TensorShape | X | input shape |
| DataType | type | Tensor DataType |
| float | value | value |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Conv2D(Tensor, Tensor, Tensor, int[], int[], FusedActivation)
2D convolution
Declaration
public virtual Tensor Conv2D(Tensor X, Tensor K, Tensor B, int[] stride, int[] pad, Layer.FusedActivation fusedActivation)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Tensor | K | |
| Tensor | B | |
| int[] | stride | stride |
| int[] | pad | padding |
| Layer.FusedActivation | fusedActivation | fused activation type |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Conv2DTrans(Tensor, Tensor, Tensor, int[], int[], int[], FusedActivation)
Transpose 2D convolution
Declaration
public virtual Tensor Conv2DTrans(Tensor X, Tensor K, Tensor B, int[] stride, int[] pad, int[] outputAdjustment, Layer.FusedActivation fusedActivation)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Tensor | K | |
| Tensor | B | |
| int[] | stride | stride |
| int[] | pad | padding |
| int[] | outputAdjustment | output adjustments |
| Layer.FusedActivation | fusedActivation | fused activation type |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Conv3D(Tensor, Tensor, Tensor, int[], int[], FusedActivation)
3D convolution
Declaration
public virtual Tensor Conv3D(Tensor X, Tensor K, Tensor B, int[] stride, int[] pad, Layer.FusedActivation fusedActivation)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Tensor | K | |
| Tensor | B | |
| int[] | stride | stride |
| int[] | pad | padding |
| Layer.FusedActivation | fusedActivation | fused activation type |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Copy(Tensor)
Copy
Declaration
public virtual Tensor Copy(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
CopyAndReshape(Tensor, TensorShape)
Copy and reshape Tensor
Declaration
protected virtual Tensor CopyAndReshape(Tensor X, TensorShape shape)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | input |
| TensorShape | shape | shape |
Returns
| Type | Description |
|---|---|
| Tensor | output |
Cos(Tensor)
Cos
Declaration
public virtual Tensor Cos(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Cosh(Tensor)
Cosh
Declaration
public virtual Tensor Cosh(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Dense(Tensor, Tensor, Tensor, FusedActivation)
Dense layer (matrix multiplication) o = x ⨯ w + b
Declaration
public virtual Tensor Dense(Tensor X, Tensor W, Tensor B, Layer.FusedActivation fusedActivation)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Tensor | W | |
| Tensor | B | |
| Layer.FusedActivation | fusedActivation | fused activation type |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Dense3(Tensor, Tensor, Tensor)
rank3 Dense layer (matrix multiplication) o = x ⨯ w + b
O: N,,W,C / X: N,,W,C / W:N,,,C / B:N,,,_
Declaration
public virtual Tensor Dense3(Tensor X, Tensor W, Tensor B)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Tensor | W | |
| Tensor | B |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
DepthToSpace(Tensor, int[], DepthToSpaceMode)
Depth to space
Declaration
public virtual Tensor DepthToSpace(Tensor X, int[] blocksize, Layer.DepthToSpaceMode mode)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | blocksize | |
| Layer.DepthToSpaceMode | mode | mode |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
DepthwiseConv2D(Tensor, Tensor, Tensor, int[], int[], FusedActivation)
Depthwise 2D convolution
Declaration
public virtual Tensor DepthwiseConv2D(Tensor X, Tensor K, Tensor B, int[] stride, int[] pad, Layer.FusedActivation fusedActivation)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Tensor | K | |
| Tensor | B | |
| int[] | stride | stride |
| int[] | pad | padding |
| Layer.FusedActivation | fusedActivation | fused activation type |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Div(Tensor[])
Divide tensors o = tensors[0] / tensors[1] / ... / tensors[N-1]
Declaration
public virtual Tensor Div(Tensor[] tensors)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Dropout(Tensor, float)
Dropout
Declaration
public virtual Tensor Dropout(Tensor X, float alpha)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| float | alpha | alpha |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Elu(Tensor, float)
ELU
Declaration
public virtual Tensor Elu(Tensor X, float alpha)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| float | alpha | alpha |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Equal(Tensor, Tensor)
Equal
Declaration
public virtual Tensor Equal(Tensor A, Tensor B)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | A | |
| Tensor | B |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor with |
Erf(Tensor)
Erf
Declaration
public virtual Tensor Erf(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Exp(Tensor)
Exponent e^x
Declaration
public virtual Tensor Exp(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Expand(Tensor, TensorShape)
Expand
Declaration
public virtual Tensor Expand(Tensor X, TensorShape newShape)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| TensorShape | newShape |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Flatten(Tensor)
Flatten
Declaration
public virtual Tensor Flatten(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Floor(Tensor)
Floor
Declaration
public virtual Tensor Floor(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Gather(Tensor[], int)
Gather
Declaration
public virtual Tensor Gather(Tensor[] tensors, int axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
| int | axis | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Gaussian(float, float)
Gaussian distribution
Declaration
protected float Gaussian(float mean, float stdDev)
Parameters
| Type | Name | Description |
|---|---|---|
| float | mean | mean |
| float | stdDev | standard deviation |
Returns
| Type | Description |
|---|---|
| float | random value |
GetModelExecutionsReporter()
Get model executions reporter
Declaration
public IModelExecutionsReporter GetModelExecutionsReporter()
Returns
| Type | Description |
|---|---|
| IModelExecutionsReporter | model executions reporter |
GlobalAvgPool2D(Tensor)
2D global average pooling
Declaration
public virtual Tensor GlobalAvgPool2D(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
GlobalAvgVariancePool2D(Tensor)
2D global average variance pooling
Declaration
public virtual Tensor GlobalAvgVariancePool2D(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
GlobalMaxPool2D(Tensor)
2D global max pooling
Declaration
public virtual Tensor GlobalMaxPool2D(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Greater(Tensor, Tensor)
Greater
Declaration
public virtual Tensor Greater(Tensor A, Tensor B)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | A | |
| Tensor | B |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor with |
GreaterEqual(Tensor, Tensor)
Greater or equal
Declaration
public virtual Tensor GreaterEqual(Tensor A, Tensor B)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | A | |
| Tensor | B |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor with |
HardSigmoid(Tensor, float, float)
HardSigmoid
Declaration
public virtual Tensor HardSigmoid(Tensor X, float alpha, float beta)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| float | alpha | alpha |
| float | beta |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
IsFusedActivationSupported(FusedActivation)
Check if fusedActivation is supported in-place
Declaration
protected virtual bool IsFusedActivationSupported(Layer.FusedActivation fusedActivation)
Parameters
| Type | Name | Description |
|---|---|---|
| Layer.FusedActivation | fusedActivation | fused activation type |
Returns
| Type | Description |
|---|---|
| bool |
|
LRN(Tensor, float, float, float, int)
LRN (Local Response Normalization)
Declaration
public virtual Tensor LRN(Tensor X, float alpha, float beta, float bias, int size)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| float | alpha | alpha |
| float | beta | beta |
| float | bias | bias |
| int | size | size |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
LSTM(Tensor, Tensor[], Tensor[], Tensor[], Tensor[], Tensor, Tensor)
LSTM
Declaration
public virtual Tensor[] LSTM(Tensor X, Tensor[] W, Tensor[] R, Tensor[] Wb, Tensor[] Rb, Tensor hidden, Tensor cell)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | The input sequences packed into one 3-D tensor. |
| Tensor[] | W | W parameter weight matrix for input, output, forget, and cell gates - W[iofc] |
| Tensor[] | R | R recurrence weight matrix for input, output, forget, and cell gates - R[iofc] |
| Tensor[] | Wb | W bias vectors for input, output, forget, and cell gates - Wb[iofc] |
| Tensor[] | Rb | R bias vectors for input, output, forget, and cell gates - Rb[iofc] |
| Tensor | hidden | Initial value of the hidden |
| Tensor | cell | Initial value of the cell |
Returns
| Type | Description |
|---|---|
| Tensor[] | [Y (concatenated intermediate values of the hidden), Y_h (final hidden), Y_c (final cell)] |
LeakyRelu(Tensor, float)
Leaky ReLU
Declaration
public virtual Tensor LeakyRelu(Tensor X, float alpha)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| float | alpha | alpha |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Less(Tensor, Tensor)
Less
Declaration
public virtual Tensor Less(Tensor A, Tensor B)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | A | |
| Tensor | B |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor with |
LessEqual(Tensor, Tensor)
Less or equal
Declaration
public virtual Tensor LessEqual(Tensor A, Tensor B)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | A | |
| Tensor | B |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor with |
Log(Tensor)
Log
Declaration
public virtual Tensor Log(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
LogSoftmax(Tensor, int)
LogSoftmax
Declaration
public virtual Tensor LogSoftmax(Tensor X, int axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
LogicalAnd(Tensor, Tensor)
And
Declaration
public virtual Tensor LogicalAnd(Tensor A, Tensor B)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | A | |
| Tensor | B |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor with |
LogicalNot(Tensor)
Not
Declaration
public virtual Tensor LogicalNot(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor with !x values |
LogicalOr(Tensor, Tensor)
Or
Declaration
public virtual Tensor LogicalOr(Tensor A, Tensor B)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | A | |
| Tensor | B |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor with |
LogicalXor(Tensor, Tensor)
Xor
Declaration
public virtual Tensor LogicalXor(Tensor A, Tensor B)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | A | |
| Tensor | B |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor with |
MatMul(Tensor, bool, Tensor, bool)
Simple 2D matrix multiplication O = X ⨯ Y
Declaration
public virtual Tensor MatMul(Tensor X, bool xTranspose, Tensor Y, bool yTranspose)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | left Tensor |
| bool | xTranspose |
|
| Tensor | Y | right Tensor |
| bool | yTranspose |
|
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
MatMul(Tensor, int, Tensor, int)
Multidimensional Matrix multiplication o = x ⨯ y
Declaration
public virtual Tensor MatMul(Tensor X, int rankX, Tensor Y, int rankY)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int | rankX | rank of |
| Tensor | Y | |
| int | rankY | rank of |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Max(Tensor[])
Max
Declaration
public virtual Tensor Max(Tensor[] tensors)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
MaxPool2D(Tensor, int[], int[], int[])
2D max pooling
Declaration
public virtual Tensor MaxPool2D(Tensor X, int[] pool, int[] stride, int[] pad)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | pool | pooling |
| int[] | stride | stride |
| int[] | pad | padding |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Mean(Tensor[])
Mean
Declaration
public virtual Tensor Mean(Tensor[] tensors)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Min(Tensor[])
Min
Declaration
public virtual Tensor Min(Tensor[] tensors)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Mul(Tensor[])
Multiply tensors together
Declaration
public virtual Tensor Mul(Tensor[] tensors)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Multinomial(Tensor, int, int)
Multinomial random distribution
Declaration
public virtual Tensor Multinomial(Tensor X, int count, int seed)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int | count | count |
| int | seed | seed |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Neg(Tensor)
Neg
Declaration
public virtual Tensor Neg(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
NewOutputTensor(DataType, TensorShape, string)
Allocate new Tensor via allocator using AllocScope.LayerOutput scope
Declaration
protected Tensor NewOutputTensor(DataType type, TensorShape s, string name = "")
Parameters
| Type | Name | Description |
|---|---|---|
| DataType | type | data type |
| TensorShape | s | shape of the tensor to be created |
| string | name | tensor name |
Returns
| Type | Description |
|---|---|
| Tensor | new |
NewTempTensor(DataType, TensorShape, string)
Allocate new Tensor via allocator using AllocScope.InternalToLayer scope
Declaration
protected Tensor NewTempTensor(DataType type, TensorShape s, string name = "")
Parameters
| Type | Name | Description |
|---|---|---|
| DataType | type | data type |
| TensorShape | s | shape of the tensor to be created |
| string | name | tensor name |
Returns
| Type | Description |
|---|---|
| Tensor | new |
NewTensor(DataType, TensorShape, AllocScope, string)
Allocate new Tensor via allocator
Declaration
protected Tensor NewTensor(DataType dataType, TensorShape s, AllocScope scope, string name = "")
Parameters
| Type | Name | Description |
|---|---|---|
| DataType | dataType | data type |
| TensorShape | s | shape |
| AllocScope | scope | tensor lifetime scope |
| string | name | name |
Returns
| Type | Description |
|---|---|
| Tensor | new |
NewTensorForFusedActivation(DataType, TensorShape, FusedActivation)
Allocate new Tensor via allocator
tensor lifetime will be OutputLayer if activation is supported in place, InternalToLayer otherwise.
Declaration
protected Tensor NewTensorForFusedActivation(DataType dataType, TensorShape shape, Layer.FusedActivation fusedActivation)
Parameters
| Type | Name | Description |
|---|---|---|
| DataType | dataType | data type |
| TensorShape | shape | shape of the tensor to be created |
| Layer.FusedActivation | fusedActivation | fused activation type |
Returns
| Type | Description |
|---|---|
| Tensor | new |
NewTensorLike(Tensor, AllocScope)
Allocate new Tensor similar to specified Tensor t
Declaration
protected Tensor NewTensorLike(Tensor t, AllocScope scope)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | t |
|
| AllocScope | scope | tensor lifetime scope |
Returns
| Type | Description |
|---|---|
| Tensor | new |
NewTensorLike(Tensor[], AllocScope, bool)
Allocate new Tensor corresponding to max shape of specified tensors
Declaration
protected Tensor NewTensorLike(Tensor[] tensors, AllocScope scope, bool validateType = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | tensors |
| AllocScope | scope | tensor lifetime scope |
| bool | validateType | should this method validate that all tensors are the same type |
Returns
| Type | Description |
|---|---|
| Tensor | new |
NonMaxSuppression(Tensor[], int, float, float, int)
Non max suppression tensors[0] - boxes, tensors[1] - scores
Declaration
public Tensor NonMaxSuppression(Tensor[] tensors, int maxOutputBoxesPerClass, float iouThreshold, float scoreThreshold, int centerPointBox)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | |
| int | maxOutputBoxesPerClass | max output boxes per class |
| float | iouThreshold | IOU (Intersection Over Union) threshold |
| float | scoreThreshold | score threshold |
| int | centerPointBox | center point box |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
NonZero(Tensor)
Indices for non zero values
Declaration
public Tensor NonZero(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | input |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Normalization(Tensor, Tensor, Tensor, int, int, float, FusedActivation)
Normalization
Declaration
public virtual Tensor Normalization(Tensor X, Tensor S, Tensor B, int pool, int axis, float epsilon, Layer.FusedActivation fusedActivation)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Tensor | S | |
| Tensor | B | |
| int | pool | pooling |
| int | axis | axis |
| float | epsilon | threshold |
| Layer.FusedActivation | fusedActivation | fused activation type |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
OneHot(Tensor, int, float, float, int)
One hot
Declaration
public virtual Tensor OneHot(Tensor X, int depth, float onValue, float offValue, int inputRank = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int | depth | output depth |
| float | onValue | on value |
| float | offValue | off value |
| int | inputRank | input rank helper |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
PRelu(Tensor, Tensor)
PReLU
Declaration
public virtual Tensor PRelu(Tensor X, Tensor S)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Tensor | S |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Pad2DEdge(Tensor, int[])
Edge padding
Declaration
public virtual Tensor Pad2DEdge(Tensor X, int[] pad)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | pad | padding |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Pad2DReflect(Tensor, int[])
Reflection padding
Declaration
public virtual Tensor Pad2DReflect(Tensor X, int[] pad)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | pad | padding |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Pad2DSymmetric(Tensor, int[])
Symmetric padding
Declaration
public virtual Tensor Pad2DSymmetric(Tensor X, int[] pad)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | pad | padding |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
PostLayerCleanup()
Called after every layer execution. It allows IOps to run cleanup operations such as clearing temporary buffers only used in the scope of the last layer executed.
Declaration
public virtual void PostLayerCleanup()
Pow(Tensor, float)
Power
Declaration
public virtual Tensor Pow(Tensor X, float alpha)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| float | alpha | alpha |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Pow(Tensor[])
Raise tensors to the power o =tensors[0] ^ tensors[1] ^ ... ^ tensors[N-1]
Declaration
public virtual Tensor Pow(Tensor[] tensors)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Prepare(Tensor)
Prepares tensor for use
Declaration
public virtual Tensor Prepare(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor |
PrepareNoAlloc(Tensor)
Prepares tensor for use without uploading internal data to device
Declaration
public virtual Tensor PrepareNoAlloc(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor |
RandomNormal(TensorShape, float, float, int)
Normal random distribution
Declaration
public virtual Tensor RandomNormal(TensorShape s, float mean, float scale, int seed)
Parameters
| Type | Name | Description |
|---|---|---|
| TensorShape | s | shape |
| float | mean | mean |
| float | scale | scale |
| int | seed | seed |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
RandomUniform(TensorShape, float, float, int)
Uniform random distribution
Declaration
public virtual Tensor RandomUniform(TensorShape s, float mean, float scale, int seed)
Parameters
| Type | Name | Description |
|---|---|---|
| TensorShape | s | shape |
| float | mean | mean |
| float | scale | scale |
| int | seed | seed |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Reciprocal(Tensor)
Reciprocal (1/x)
Declaration
public virtual Tensor Reciprocal(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
ReduceMax(Tensor, int)
Reduce with max
Declaration
public virtual Tensor ReduceMax(Tensor X, int axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int | axis | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
ReduceMean(Tensor, int)
Reduce with mean
Declaration
public virtual Tensor ReduceMean(Tensor X, int axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int | axis | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
ReduceMin(Tensor, int)
Reduce with min
Declaration
public virtual Tensor ReduceMin(Tensor X, int axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int | axis | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
ReduceProd(Tensor, int)
Reduce with product
Declaration
public virtual Tensor ReduceProd(Tensor X, int axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int | axis | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
ReduceSum(Tensor, int)
Reduce with sum
Declaration
public virtual Tensor ReduceSum(Tensor X, int axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int | axis | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Relu(Tensor)
ReLU
Declaration
public virtual Tensor Relu(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Relu6(Tensor)
ReLU capped to 6
Declaration
public virtual Tensor Relu6(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Resample2D(Tensor, int[], bool)
Resample 2D
Declaration
public virtual Tensor Resample2D(Tensor X, int[] size, bool bilinear)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | size | size |
| bool | bilinear | bilinear flag |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
ResetAllocator(bool)
Reset internal allocator
Declaration
public virtual void ResetAllocator(bool keepCachedMemory = true)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | keepCachedMemory | keep cached memory flag |
Reshape(Tensor, TensorShape)
Reshape
Declaration
public virtual Tensor Reshape(Tensor X, TensorShape newShape)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| TensorShape | newShape |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
RoiAlign(Tensor, Tensor, Tensor, int, int, int, float)
RoiAlign
Declaration
public virtual Tensor RoiAlign(Tensor X, Tensor Rois, Tensor Indices, int outputHeight, int outputWidth, int samplingRatio, float spatialScale)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Tensor | Rois | |
| Tensor | Indices | |
| int | outputHeight | outputHeight |
| int | outputWidth | outputWidth |
| int | samplingRatio | samplingRatio |
| float | spatialScale | spatialScale |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Round(Tensor)
Round to nearest integer. In case of halfs, round to nearest even integer
Declaration
public virtual Tensor Round(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
ScaleBias(Tensor, Tensor, Tensor)
Scale bias o = s * x + b, element wise
Declaration
public virtual Tensor ScaleBias(Tensor X, Tensor S, Tensor B)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Tensor | S | |
| Tensor | B |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
ScatterND(Tensor, Tensor, Tensor, ScatterNDReductionMode)
ScatterND
Declaration
public virtual Tensor ScatterND(Tensor X, Tensor indices, Tensor updates, Layer.ScatterNDReductionMode reduction)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | input tensor |
| Tensor | indices | indices |
| Tensor | updates | updates |
| Layer.ScatterNDReductionMode | reduction | reduction mode |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Selu(Tensor, float, float)
SELU
Declaration
public virtual Tensor Selu(Tensor X, float alpha, float gamma)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| float | alpha | alpha |
| float | gamma | gamma |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
SetModelExecutionsReporter(IModelExecutionsReporter)
Set model executions reporter
model executions reporterDeclaration
public void SetModelExecutionsReporter(IModelExecutionsReporter executionsReporter)
Parameters
| Type | Name | Description |
|---|---|---|
| IModelExecutionsReporter | executionsReporter |
Shape(Tensor, int)
Shape of the input
Declaration
public Tensor Shape(Tensor X, int axis = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | input |
| int | axis | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Sigmoid(Tensor)
Sigmoid
Declaration
public virtual Tensor Sigmoid(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Sign(Tensor)
Sign
Declaration
public virtual Tensor Sign(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor with 1 if x > 0 -1 if < 0 and 0 if == 0 values |
Sin(Tensor)
Sin
Declaration
public virtual Tensor Sin(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Sinh(Tensor)
Sinh
Declaration
public virtual Tensor Sinh(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Softmax(Tensor, int)
Softmax
Declaration
public virtual Tensor Softmax(Tensor X, int axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int | axis | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Softplus(Tensor)
Softplus
Declaration
public virtual Tensor Softplus(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
SpaceToDepth(Tensor, int[])
Space to depth
Declaration
public virtual Tensor SpaceToDepth(Tensor X, int[] blocksize)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | blocksize |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Sqrt(Tensor)
Sqrt
Declaration
public virtual Tensor Sqrt(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
StridedSlice(Tensor, int[], int[], int[])
Strided slice
Declaration
public virtual Tensor StridedSlice(Tensor X, int[] starts4Dor8D, int[] ends4Dor8D, int[] strides4Dor8D)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | starts4Dor8D | |
| int[] | ends4Dor8D | |
| int[] | strides4Dor8D | stride |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Sub(Tensor[])
Subtract tensors o = tensors[0] - tensors[1] - ... - tensors[N-1]
Declaration
public virtual Tensor Sub(Tensor[] tensors)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Swish(Tensor)
Swish
Declaration
public virtual Tensor Swish(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Tan(Tensor)
Tan
Declaration
public virtual Tensor Tan(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Tanh(Tensor)
Tanh
Declaration
public virtual Tensor Tanh(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Tile(Tensor, int[])
Tile
Declaration
public virtual Tensor Tile(Tensor X, int[] repeats)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | repeats | repetition counts |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
TopKIndices(Tensor, int, int, bool, bool)
Top K indices
Declaration
public virtual Tensor TopKIndices(Tensor X, int k, int axis, bool largest, bool sorted)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int | k | k |
| int | axis | axis |
| bool | largest | largest flag |
| bool | sorted | sorted flag |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
TopKValues(Tensor, Tensor, int)
Top K values
Declaration
public virtual Tensor TopKValues(Tensor X, Tensor I, int axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | input |
| Tensor | I | indices |
| int | axis | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Transpose(Tensor)
Transpose matrix
Declaration
public virtual Tensor Transpose(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Transpose(Tensor, int[])
Transpose according to permutations
Declaration
public virtual Tensor Transpose(Tensor X, int[] permutations)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | permutations | new axis order |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Upsample2D(Tensor, int[], bool)
Upsample 2D
Declaration
public virtual Tensor Upsample2D(Tensor X, int[] scale, bool bilinear)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | scale | scale |
| bool | bilinear | bilinear flag |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Upsample3D(Tensor, int[], bool)
Upsample 3D
Declaration
public virtual Tensor Upsample3D(Tensor X, int[] scale, bool trilinear)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int[] | scale | scale |
| bool | trilinear | trilinear flag |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Where(Tensor, Tensor, Tensor)
Where
Declaration
public virtual Tensor Where(Tensor C, Tensor A, Tensor B)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | C | |
| Tensor | A | |
| Tensor | B |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor with values |