Class PixelShaderOps
Inherited Members
Namespace: Unity.Barracuda
Syntax
public class PixelShaderOps : ReferenceCPUOps, IOps, IOpsStatistics
Constructors
PixelShaderOps(ITensorAllocator)
Declaration
public PixelShaderOps(ITensorAllocator allocator = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ITensorAllocator | allocator |
Methods
Activation(String, Tensor, Single, Single)
Generic activation function
Declaration
protected virtual 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 |
Add(Tensor[])
Add tensors together
Declaration
public override Tensor Add(Tensor[] tensors)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
ApplyPadding(Tensor, Int32[], String, Single)
Apply padding
Declaration
protected virtual 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 |
AvgPool2D(Tensor, Int32[], Int32[], Int32[])
2D average pooling
Declaration
public override Tensor AvgPool2D(Tensor X, int[] pool, int[] stride, int[] pad)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Int32[] | pool | pooling |
| Int32[] | stride | stride |
| Int32[] | pad | padding |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Border2D(Tensor, Int32[], Single)
2D border padding
Declaration
public override Tensor Border2D(Tensor X, int[] pad, float constant)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Int32[] | pad | padding |
| Single | constant |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Clip(Tensor, Single, Single)
Clip
Declaration
public override Tensor Clip(Tensor X, float alpha, float beta)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Single | alpha | |
| Single | beta |
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
Copy(Tensor)
Copy
Declaration
public override Tensor Copy(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
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
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 virtual Tensor ElementwiseWithBroadcast(string kernelName, Tensor[] tensors)
Parameters
| Type | Name | Description |
|---|---|---|
| String | kernelName | kernel name |
| Tensor[] | tensors | input tensors |
Returns
| Type | Description |
|---|---|
| Tensor | output |
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
GlobalPool2D(String, Tensor)
Generic pooling 2D
Declaration
protected virtual Tensor GlobalPool2D(string kernelName, Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| String | kernelName | kernel name |
| Tensor | X | input |
Returns
| Type | Description |
|---|---|
| Tensor | output |
IsFusedActivationSupported(Layer.FusedActivation)
Check if fusedActivation is supported in-place
Declaration
protected override bool IsFusedActivationSupported(Layer.FusedActivation fusedActivation)
Parameters
| Type | Name | Description |
|---|---|---|
| Layer.FusedActivation | fusedActivation | fused activation type |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Overrides
LeakyRelu(Tensor, Single)
Leaky ReLU
Declaration
public override Tensor LeakyRelu(Tensor X, float alpha)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Single | alpha | alpha |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
MaxPool2D(Tensor, Int32[], Int32[], Int32[])
2D max pooling
Declaration
public override Tensor MaxPool2D(Tensor X, int[] pool, int[] stride, int[] pad)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Int32[] | pool | pooling |
| Int32[] | stride | stride |
| Int32[] | pad | padding |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Min(Tensor[])
Min
Declaration
public override Tensor Min(Tensor[] tensors)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Mul(Tensor[])
Multiply tensors together
Declaration
public override Tensor Mul(Tensor[] tensors)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
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
Pad2DEdge(Tensor, Int32[])
Edge padding
Declaration
public override Tensor Pad2DEdge(Tensor X, int[] pad)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Int32[] | pad | padding |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Pad2DReflect(Tensor, Int32[])
Reflection padding
Declaration
public override Tensor Pad2DReflect(Tensor X, int[] pad)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Int32[] | pad | padding |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Pad2DSymmetric(Tensor, Int32[])
Symmetric padding
Declaration
public override Tensor Pad2DSymmetric(Tensor X, int[] pad)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Int32[] | pad | padding |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Pin(Tensor, Boolean)
Declaration
public TextureTensorData Pin(Tensor X, bool uploadCache = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Boolean | uploadCache |
Returns
| Type | Description |
|---|---|
| TextureTensorData |
Pool2D(String, Tensor, Int32[], Int32[], Int32[])
Declaration
protected virtual 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 |
Prepare(Tensor)
Prepares tensor for use
Declaration
public override Tensor Prepare(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor |
Overrides
PrepareNoAlloc(Tensor)
Prepares tensor for use without uploading internal data to device
Declaration
public override Tensor PrepareNoAlloc(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | Tensor |
Overrides
Reciprocal(Tensor)
Reciprocal (1/x)
Declaration
public override Tensor Reciprocal(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Relu(Tensor)
ReLU
Declaration
public override Tensor Relu(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Resample2D(Tensor, Int32[], Boolean)
Resample 2D
Declaration
public override Tensor Resample2D(Tensor X, int[] size, bool bilinear)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Int32[] | size | size |
| Boolean | bilinear | bilinear flag |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Reshape(Tensor, TensorShape)
Reshape
Declaration
public override Tensor Reshape(Tensor X, TensorShape newShape)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| TensorShape | newShape |
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
Selu(Tensor, Single, Single)
SELU
Declaration
public override Tensor Selu(Tensor X, float alpha, float beta)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Single | alpha | alpha |
| Single | beta |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Sqrt(Tensor)
Sqrt
Declaration
public override Tensor Sqrt(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
StridedSlice(Tensor, Int32[], Int32[], Int32[])
Strided slice
Declaration
public override Tensor StridedSlice(Tensor X, int[] starts, int[] ends, int[] strides)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | |
| Int32[] | starts | |
| Int32[] | ends | |
| Int32[] | strides |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Sub(Tensor[])
Subtract tensors o = tensors[0] - tensors[1] - ... - tensors[N-1]
Declaration
public override Tensor Sub(Tensor[] tensors)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | tensors | input tensors |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
Tanh(Tensor)
Tanh
Declaration
public override Tensor Tanh(Tensor X)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X |
Returns
| Type | Description |
|---|---|
| Tensor | output Tensor |
Overrides
TensorToRenderTexture(Tensor, RenderTexture, Int32, Int32, Vector4, Vector4, Texture3D)
Copy Tensor data to RenderTexture
Declaration
public void TensorToRenderTexture(Tensor X, RenderTexture target, int batch, int fromChannel, Vector4 scale, Vector4 bias, Texture3D lut)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | source |
| RenderTexture | target | target |
| Int32 | batch | batch |
| Int32 | fromChannel | from channel |
| Vector4 | scale | scale |
| Vector4 | bias | bias |
| Texture3D | lut | LUT table |
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 |