Class ComputeOps
GPU compute implementation of IOps
Inherited Members
Namespace: Unity.Barracuda
Syntax
public class ComputeOps : ReferenceComputeOps, IOps
Constructors
ComputeOps(ITensorAllocator, Boolean)
Create ComputeOps
Declaration
public ComputeOps(ITensorAllocator allocator = null, bool verbose = false)
Parameters
Type | Name | Description |
---|---|---|
ITensorAllocator | allocator | allocator |
Boolean | verbose | verbose flag |
Methods
Activation(String, Tensor, Single, Single)
Generic activation function
Declaration
protected override Tensor Activation(string kernelName, Tensor X, float alpha = 0F, float beta = 0F)
Parameters
Type | Name | Description |
---|---|---|
String | kernelName | kernel name |
Tensor | X | input |
Single | alpha | alpha |
Single | beta | beta |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
ApplyPadding(Tensor, Int32[], String, Single)
Apply padding
Declaration
protected override Tensor ApplyPadding(Tensor X, int[] pad, string kernelName, float constant = 0F)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X | input |
Int32[] | pad | padding |
String | kernelName | kernel name |
Single | constant | constant |
Returns
Type | Description |
---|---|
Tensor | output |
Overrides
ArgMax(Tensor, Int32)
ArgMax
Declaration
public override Tensor ArgMax(Tensor X, int axis)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X | |
Int32 | axis | axis |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
ArgMin(Tensor, Int32)
ArgMax
Declaration
public override Tensor ArgMin(Tensor X, int axis)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X | |
Int32 | axis | axis |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
Concat(Tensor[], Int32)
Concatenate tensors
across axis
Declaration
public override Tensor Concat(Tensor[] tensors, int axis)
Parameters
Type | Name | Description |
---|---|---|
Tensor[] | tensors | input tensors |
Int32 | axis | axis |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
Conv2D(Tensor, Tensor, Tensor, Int32[], Int32[], Layer.FusedActivation)
2D convolution
Declaration
public override 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 | |
Int32[] | stride | stride |
Int32[] | pad | padding |
Layer.FusedActivation | fusedActivation | fused activation type |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
Conv2DTrans(Tensor, Tensor, Tensor, Int32[], Int32[], Int32[], Layer.FusedActivation)
Transpose 2D convolution
Declaration
public override 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 | |
Int32[] | stride | stride |
Int32[] | pad | padding |
Int32[] | outputAdjustment | output adjustments |
Layer.FusedActivation | fusedActivation | fused activation type |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
Conv3D(Tensor, Tensor, Tensor, Int32[], Int32[], Layer.FusedActivation)
3D convolution
Declaration
public override 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 | |
Int32[] | stride | stride |
Int32[] | pad | padding |
Layer.FusedActivation | fusedActivation | fused activation type |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
CopyAndReshape(Tensor, TensorShape)
Copy and reshape Tensor
Declaration
protected override Tensor CopyAndReshape(Tensor X, TensorShape newShape)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X | input |
TensorShape | newShape |
Returns
Type | Description |
---|---|
Tensor | output |
Overrides
CopyAndReshape_NCHW(Tensor, TensorShape)
Copy and reshape tensor for NCHW layout
Declaration
protected override Tensor CopyAndReshape_NCHW(Tensor X, TensorShape newShape)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X | input |
TensorShape | newShape | new shape |
Returns
Type | Description |
---|---|
Tensor | output |
Overrides
Dense(Tensor, Tensor, Tensor, Layer.FusedActivation)
Dense layer (matrix multiplication) o = x
⨯ w
+ b
Declaration
public override 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 |
Overrides
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 override Tensor Dense3(Tensor X, Tensor W, Tensor B)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X | |
Tensor | W | |
Tensor | B |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
DepthwiseConv2D(Tensor, Tensor, Tensor, Int32[], Int32[], Layer.FusedActivation)
Depthwise 2D convolution
Declaration
public override 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 | |
Int32[] | stride | stride |
Int32[] | pad | padding |
Layer.FusedActivation | fusedActivation | fused activation type |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
ElementwiseWithBroadcast(String, Tensor[])
Elementwise broadcast for specified kernel
Declaration
protected override Tensor ElementwiseWithBroadcast(string kernelName, Tensor[] tensors)
Parameters
Type | Name | Description |
---|---|---|
String | kernelName | kernel name |
Tensor[] | tensors | input tensors |
Returns
Type | Description |
---|---|
Tensor | output |
Overrides
GlobalAvgPool2D(Tensor)
2D global average pooling
Declaration
public override Tensor GlobalAvgPool2D(Tensor X)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
GlobalAvgVariancePool2D(Tensor)
2D global average variance pooling
Declaration
public override Tensor GlobalAvgVariancePool2D(Tensor X)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
GlobalMaxPool2D(Tensor)
2D global max pooling
Declaration
public override Tensor GlobalMaxPool2D(Tensor X)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
GlobalPool2D(String, String, Tensor)
Generic global 2D pooling
Declaration
protected virtual Tensor GlobalPool2D(string smallKernelName, string globalKernelName, Tensor X)
Parameters
Type | Name | Description |
---|---|---|
String | smallKernelName | small kernel name |
String | globalKernelName | global kernel name |
Tensor | X | input |
Returns
Type | Description |
---|---|
Tensor | output |
LogicalNot(Tensor)
Not
Declaration
public override Tensor LogicalNot(Tensor X)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X |
Returns
Type | Description |
---|---|
Tensor | Tensor with !x values |
Overrides
LogSoftmax(Tensor)
LogSoftmax
Declaration
public override Tensor LogSoftmax(Tensor X)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
MatMul(Tensor, Boolean, Tensor, Boolean)
Simple 2D matrix multiplication O = X
⨯ Y
Declaration
public override Tensor MatMul(Tensor X, bool xTranspose, Tensor Y, bool yTranspose)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X | left Tensor |
Boolean | xTranspose |
|
Tensor | Y | right Tensor |
Boolean | yTranspose |
|
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
MatMul(Tensor, Int32, Tensor, Int32)
Multidimensional Matrix multiplication o = x
⨯ y
Declaration
public override Tensor MatMul(Tensor X, int rankX, Tensor Y, int rankY)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X | |
Int32 | rankX | rank of |
Tensor | Y | |
Int32 | rankY | rank of |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
Normalization(Tensor, Tensor, Tensor, Int32, Int32, Single, Layer.FusedActivation)
Normalization
Declaration
public override 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 | |
Int32 | pool | pooling |
Int32 | axis | axis |
Single | epsilon | threshold |
Layer.FusedActivation | fusedActivation | fused activation type |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
Pool2D(String, Tensor, Int32[], Int32[], Int32[])
Declaration
protected override Tensor Pool2D(string kernelName, Tensor X, int[] pool, int[] stride, int[] pad)
Parameters
Type | Name | Description |
---|---|---|
String | kernelName | |
Tensor | X | |
Int32[] | pool | |
Int32[] | stride | |
Int32[] | pad |
Returns
Type | Description |
---|---|
Tensor |
Overrides
PRelu(Tensor, Tensor)
PReLU
Declaration
public override Tensor PRelu(Tensor X, Tensor S)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X | |
Tensor | S |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
ScaleBias(Tensor, Tensor, Tensor)
Scale bias o = s * x + b, element wise
Declaration
public override Tensor ScaleBias(Tensor X, Tensor S, Tensor B)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X | |
Tensor | S | |
Tensor | B |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
Sign(Tensor)
Sign
Declaration
public override 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 |
Overrides
Softmax(Tensor, Int32)
Softmax
Declaration
public override Tensor Softmax(Tensor X, int axis)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X | |
Int32 | axis | axis |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
Transpose(Tensor)
Transpose matrix
Declaration
public override Tensor Transpose(Tensor X)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
Transpose(Tensor, Int32[])
Transpose according to permutations
Declaration
public override Tensor Transpose(Tensor X, int[] permutations)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X | |
Int32[] | permutations | new axis order |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
Upsample2D(Tensor, Int32[], Boolean)
Upsample 2D
Declaration
public override Tensor Upsample2D(Tensor X, int[] scale, bool bilinear)
Parameters
Type | Name | Description |
---|---|---|
Tensor | X | |
Int32[] | scale | scale |
Boolean | bilinear | bilinear flag |
Returns
Type | Description |
---|---|
Tensor | output Tensor |
Overrides
Where(Tensor, Tensor, Tensor)
Where
Declaration
public override 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 |