Class PrecompiledComputeOps
Precompiled GPU compute IOps implementation
Implements
Inherited Members
Namespace: Unity.Barracuda
Assembly: Unity.Barracuda.dll
Syntax
public class PrecompiledComputeOps : ComputeOps, IOps
Constructors
PrecompiledComputeOps(ITensorAllocator, bool)
Create PrecompiledComputeOps
Declaration
public PrecompiledComputeOps(ITensorAllocator allocator = null, bool verbose = false)
Parameters
| Type | Name | Description |
|---|---|---|
| ITensorAllocator | allocator | allocator |
| bool | verbose | verbose flag |
Methods
Activation(string, Tensor, float, float)
Generic activation function
Declaration
protected override Tensor Activation(string kernelName, Tensor X, float alpha = 0, float beta = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| string | kernelName | kernel name |
| Tensor | X | input |
| float | alpha | alpha |
| float | beta | beta |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Concat(Tensor[], int)
Concatenate tensors across axis
Declaration
public override Tensor Concat(Tensor[] tensors, int axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
| int | axis | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Conv2D(Tensor, Tensor, Tensor, int[], int[], 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 | |
| int[] | stride | stride |
| int[] | pad | padding |
| Layer.FusedActivation | fusedActivation | fused activation type |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Conv2DTrans(Tensor, Tensor, Tensor, int[], int[], int[], 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 | |
| int[] | stride | stride |
| int[] | pad | padding |
| int[] | outputAdjustment | output adjustments |
| Layer.FusedActivation | fusedActivation | fused activation type |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Dense(Tensor, Tensor, Tensor, 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, int[], int[], 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 | |
| int[] | stride | stride |
| int[] | 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
Exceptions
| Type | Condition |
|---|---|
| NotImplementedException | thrown if input |
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
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
LogSoftmax(Tensor)
LogSoftmax
Declaration
public override Tensor LogSoftmax(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Normalization(Tensor, Tensor, Tensor, int, int, float, 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 | |
| int | pool | pooling |
| int | axis | axis |
| float | epsilon | threshold |
| Layer.FusedActivation | fusedActivation | fused activation type |
Returns
| Type | Description |
|---|---|
| Tensor | output 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
Pool2D(string, Tensor, int[], int[], int[])
Declaration
protected override Tensor Pool2D(string kernelName, Tensor X, int[] pool, int[] stride, int[] pad)
Parameters
| Type | Name | Description |
|---|---|---|
| string | kernelName | |
| Tensor | X | |
| int[] | pool | |
| int[] | stride | |
| int[] | pad |
Returns
| Type | Description |
|---|---|
| Tensor |
Overrides
PreExecuteLayer(Layer, Tensor[])
Prepare for layer execution
Declaration
public virtual void PreExecuteLayer(Layer layer, Tensor[] inputs)
Parameters
| Type | Name | Description |
|---|---|---|
| Layer | layer | layer |
| Tensor[] | inputs | inputs |
PrepareModel(Model, IDictionary<string, TensorShape>)
Prepare model for execution, allocating required intermediate tensors
Declaration
public virtual void PrepareModel(Model model, IDictionary<string, TensorShape> inputShapes)
Parameters
| Type | Name | Description |
|---|---|---|
| Model | model | model |
| IDictionary<string, TensorShape> | inputShapes | input shapes |
ResetAllocator(bool)
Reset internal allocator
Declaration
public override void ResetAllocator(bool keepCachedMemory = true)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | keepCachedMemory | keep cached memory flag |
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
Softmax(Tensor, int)
Softmax
Declaration
public override Tensor Softmax(Tensor X, int axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| int | axis | axis |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Upsample2D(Tensor, int[], bool)
Upsample 2D
Declaration
public override 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 |