Beaver.MLIR.Dialect.Linalg (beaver v0.4.8)

Copy Markdown

Summary

Functions

Return op name linalg.abs as a bitstring.

linalg.abs - Applies abs(x) elementwise.

Return op name linalg.add as a bitstring.

linalg.add - Adds two tensors elementwise.

Return op name linalg.batch_matmul as a bitstring.

linalg.batch_matmul - Performs a batched matrix multiplication of two 3D inputs.

Return op name linalg.batch_matvec as a bitstring.

linalg.batch_matvec - Performs a batched matrix-vector multiplication.

Return op name linalg.batch_mmt4d as a bitstring.

linalg.batch_mmt4d - Performs a batched matrix-matrix-transpose multiplication of two batched-4D (5D) inputs.

Return op name linalg.batch_reduce_matmul as a bitstring.

linalg.batch_reduce_matmul - Performs a batch-reduce matrix multiplication on two inputs.

Return op name linalg.batch_vecmat as a bitstring.

linalg.batch_vecmat - Performs a batched matrix-vector multiplication.

Return op name linalg.broadcast as a bitstring.

linalg.broadcast - Static broadcast operator

Return op name linalg.ceil as a bitstring.

linalg.ceil - Applies ceil(x) elementwise.

Return op name linalg.contract as a bitstring.

linalg.contract -

Return op name linalg.conv_1d as a bitstring.

linalg.conv_1d - Performs 1-D convolution with no channels.

Return op name linalg.conv_1d_ncw_fcw as a bitstring.

linalg.conv_1d_ncw_fcw - Performs 1-D convolution.

Return op name linalg.conv_1d_nwc_wcf as a bitstring.

linalg.conv_1d_nwc_wcf - Performs 1-D convolution.

Return op name linalg.conv_2d as a bitstring.

linalg.conv_2d - Performs 2-D convolution with no channels.

Return op name linalg.conv_2d_nchw_fchw as a bitstring.

linalg.conv_2d_nchw_fchw - Performs 2-D convolution.

Return op name linalg.conv_2d_nchw_fchw_q as a bitstring.

linalg.conv_2d_nchw_fchw_q - Performs 2-D convolution with zero point offsets.

Return op name linalg.conv_2d_ngchw_fgchw as a bitstring.

linalg.conv_2d_ngchw_fgchw - Performs 2-D grouped convolution.

Return op name linalg.conv_2d_ngchw_gfchw as a bitstring.

linalg.conv_2d_ngchw_gfchw - Performs 2-D grouped convolution.

Return op name linalg.conv_2d_ngchw_gfchw_q as a bitstring.

linalg.conv_2d_ngchw_gfchw_q - Performs 2-D grouped convolution with zero-point offsets.

Return op name linalg.conv_2d_nhwc_fhwc as a bitstring.

linalg.conv_2d_nhwc_fhwc - Performs 2-D convolution.

Return op name linalg.conv_2d_nhwc_fhwc_q as a bitstring.

linalg.conv_2d_nhwc_fhwc_q - Performs 2-D convolution with zero point offsets.

Return op name linalg.conv_2d_nhwc_hwcf as a bitstring.

linalg.conv_2d_nhwc_hwcf - Performs 2-D convolution.

Return op name linalg.conv_2d_nhwc_hwcf_q as a bitstring.

linalg.conv_2d_nhwc_hwcf_q - Performs 2-D convolution with zero point offsets.

Return op name linalg.conv_2d_nhwgc_gfhwc as a bitstring.

linalg.conv_2d_nhwgc_gfhwc - Performs 2-D grouped convolution.

Return op name linalg.conv_2d_nhwgc_gfhwc_q as a bitstring.

linalg.conv_2d_nhwgc_gfhwc_q - Performs 2-D grouped convolution with zero point offsets.

Return op name linalg.conv_3d as a bitstring.

linalg.conv_3d - Performs 3-D convolution with no channels.

Return op name linalg.conv_3d_ncdhw_fcdhw as a bitstring.

linalg.conv_3d_ncdhw_fcdhw - Performs 3-D convolution.

Return op name linalg.conv_3d_ndhwc_dhwcf as a bitstring.

linalg.conv_3d_ndhwc_dhwcf - Performs 3-D convolution.

Return op name linalg.conv_3d_ndhwc_dhwcf_q as a bitstring.

linalg.conv_3d_ndhwc_dhwcf_q - Performs 3-D convolution with zero point offsets.

Return op name linalg.copy as a bitstring.

linalg.copy - Copies the tensor elementwise.

Return op name linalg.depthwise_conv_1d_ncw_cw as a bitstring.

linalg.depthwise_conv_1d_ncw_cw - Performs depth-wise 1-D convolution.

Return op name linalg.depthwise_conv_1d_nwc_wc as a bitstring.

linalg.depthwise_conv_1d_nwc_wc - Performs depth-wise 1-D convolution.

Return op name linalg.depthwise_conv_1d_nwc_wcm as a bitstring.

linalg.depthwise_conv_1d_nwc_wcm - Performs depth-wise 1-D convolution.

Return op name linalg.depthwise_conv_2d_nchw_chw as a bitstring.

linalg.depthwise_conv_2d_nchw_chw - Performs depth-wise 2-D convolution.

Return op name linalg.depthwise_conv_2d_nhwc_hwc as a bitstring.

linalg.depthwise_conv_2d_nhwc_hwc - Performs depth-wise 2-D convolution.

Return op name linalg.depthwise_conv_2d_nhwc_hwc_q as a bitstring.

linalg.depthwise_conv_2d_nhwc_hwc_q - Performs depth-wise 2-D convolution.

Return op name linalg.depthwise_conv_2d_nhwc_hwcm as a bitstring.

linalg.depthwise_conv_2d_nhwc_hwcm - Performs depth-wise 2-D convolution.

Return op name linalg.depthwise_conv_2d_nhwc_hwcm_q as a bitstring.

linalg.depthwise_conv_2d_nhwc_hwcm_q - Performs depth-wise 2-D convolution.

Return op name linalg.depthwise_conv_3d_ncdhw_cdhw as a bitstring.

linalg.depthwise_conv_3d_ncdhw_cdhw - Performs depth-wise 3-D convolution.

Return op name linalg.depthwise_conv_3d_ndhwc_dhwc as a bitstring.

linalg.depthwise_conv_3d_ndhwc_dhwc - Performs depth-wise 3-D convolution.

Return op name linalg.depthwise_conv_3d_ndhwc_dhwcm as a bitstring.

linalg.depthwise_conv_3d_ndhwc_dhwcm - Performs depth-wise 3-D convolution.

Return op name linalg.div as a bitstring.

linalg.div - Divides the first tensor by the second tensor, elementwise.

Return op name linalg.div_unsigned as a bitstring.

linalg.div_unsigned - Divides the first tensor by the second tensor, elementwise. For integer types, performs an unsigned division.

Return op name linalg.dot as a bitstring.

linalg.dot - Performs a dot product of two vectors to a scalar result.

Return op name linalg.elementwise as a bitstring.

linalg.elementwise - Performs element-wise operation

Return op name linalg.erf as a bitstring.

linalg.erf - Applies erf(x) elementwise.

Return op name linalg.exp as a bitstring.

linalg.exp - Applies exp(x) elementwise.

Return op name linalg.fill as a bitstring.

linalg.fill - Fills the output tensor with the given value.

Return op name linalg.fill_rng_2d as a bitstring.

linalg.fill_rng_2d - Fills the output tensor with pseudo random numbers.

Return op name linalg.floor as a bitstring.

linalg.floor - Applies floor(x) elementwise.

Return op name linalg.generic as a bitstring.

linalg.generic

Return op name linalg.index as a bitstring.

linalg.index - linalg index operation

Return op name linalg.log as a bitstring.

linalg.log - Applies log(x) elementwise.

Return op name linalg.map as a bitstring.

linalg.map - Elementwise operations

Return op name linalg.matmul as a bitstring.

linalg.matmul -

Return op name linalg.matvec as a bitstring.

linalg.matvec - Performs a matrix-vector multiplication.

Return op name linalg.max as a bitstring.

linalg.max - Takes the max (signed) between two inputs, elementwise.

Return op name linalg.min as a bitstring.

linalg.min - Takes the min (signed) between two inputs, elementwise.

Return op name linalg.mmt4d as a bitstring.

linalg.mmt4d - Performs a matrix-matrix-transpose multiplication of two 4D inputs.

Return op name linalg.mul as a bitstring.

linalg.mul - Multiplies two tensors elementwise.

Return op name linalg.negf as a bitstring.

linalg.negf - Applies negf(x) elementwise.

Return op name linalg.pack as a bitstring.

linalg.pack - linalg.pack operation

Return op name linalg.pooling_nchw_max as a bitstring.

linalg.pooling_nchw_max - Performs max pooling.

Return op name linalg.pooling_nchw_sum as a bitstring.

linalg.pooling_nchw_sum - Performs sum pooling.

Return op name linalg.pooling_ncw_max as a bitstring.

linalg.pooling_ncw_max - Performs max pooling.

Return op name linalg.pooling_ncw_sum as a bitstring.

linalg.pooling_ncw_sum - Performs sum pooling.

Return op name linalg.pooling_ndhwc_max as a bitstring.

linalg.pooling_ndhwc_max - Performs 3D max pooling.

Return op name linalg.pooling_ndhwc_min as a bitstring.

linalg.pooling_ndhwc_min - Performs 3D min pooling.

Return op name linalg.pooling_ndhwc_sum as a bitstring.

linalg.pooling_ndhwc_sum - Performs 3D sum pooling.

Return op name linalg.pooling_nhwc_max as a bitstring.

linalg.pooling_nhwc_max - Performs max pooling.

Return op name linalg.pooling_nhwc_max_unsigned as a bitstring.

linalg.pooling_nhwc_max_unsigned - Performs unsigned max pooling.

Return op name linalg.pooling_nhwc_min as a bitstring.

linalg.pooling_nhwc_min - Performs min pooling.

Return op name linalg.pooling_nhwc_min_unsigned as a bitstring.

linalg.pooling_nhwc_min_unsigned - Performs unsigned min pooling.

Return op name linalg.pooling_nhwc_sum as a bitstring.

linalg.pooling_nhwc_sum - Performs sum pooling.

Return op name linalg.pooling_nwc_max as a bitstring.

linalg.pooling_nwc_max - Performs max pooling.

Return op name linalg.pooling_nwc_max_unsigned as a bitstring.

linalg.pooling_nwc_max_unsigned - Performs unsigned max pooling.

Return op name linalg.pooling_nwc_min as a bitstring.

linalg.pooling_nwc_min - Performs min pooling.

Return op name linalg.pooling_nwc_min_unsigned as a bitstring.

linalg.pooling_nwc_min_unsigned - Performs unsigned min pooling.

Return op name linalg.pooling_nwc_sum as a bitstring.

linalg.pooling_nwc_sum - Performs sum pooling.

Return op name linalg.powf as a bitstring.

linalg.powf - Takes the powf(lhs, rhs) between two inputs, elementwise. For powf(arg, 2) use linalg.square.

Return op name linalg.quantized_batch_matmul as a bitstring.

linalg.quantized_batch_matmul - Performs a batched matrix multiplication of two 3D inputs.

Return op name linalg.quantized_matmul as a bitstring.

linalg.quantized_matmul - Performs a matrix multiplication of two 2D inputs.

Return op name linalg.reciprocal as a bitstring.

linalg.reciprocal - Applies reciprocal(x) elementwise.

Return op name linalg.reduce as a bitstring.

linalg.reduce - Reduce operator

Return op name linalg.round as a bitstring.

linalg.round - Applies round(x) elementwise.

Return op name linalg.rsqrt as a bitstring.

linalg.rsqrt - Applies rsqrt(x) elementwise.

Return op name linalg.select as a bitstring.

linalg.select - Chooses one value based on a binary condition supplied as its first operand.

Return op name linalg.softmax as a bitstring.

linalg.softmax - Softmax operator

Return op name linalg.sqrt as a bitstring.

linalg.sqrt - Applies sqrt(x) elementwise.

Return op name linalg.square as a bitstring.

linalg.square - Applies square(x) elementwise.

Return op name linalg.sub as a bitstring.

linalg.sub - Subtracts two tensors elementwise.

Return op name linalg.tanh as a bitstring.

linalg.tanh - Applies tanh(x) elementwise.

Return op name linalg.transpose as a bitstring.

linalg.transpose - Transpose operator

Return op name linalg.unpack as a bitstring.

linalg.unpack - linalg.unpack operation

Return op name linalg.vecmat as a bitstring.

linalg.vecmat - Performs a vector-matrix multiplication.

Return op name linalg.winograd_filter_transform as a bitstring.

linalg.winograd_filter_transform - Winograd filter transform operator

Return op name linalg.winograd_input_transform as a bitstring.

linalg.winograd_input_transform - Winograd input transform operator

Return op name linalg.winograd_output_transform as a bitstring.

linalg.winograd_output_transform - Winograd output transform operator

Return op name linalg.yield as a bitstring.

linalg.yield - Linalg yield operation

Functions

abs()

Return op name linalg.abs as a bitstring.

abs(ssa)

linalg.abs - Applies abs(x) elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

No numeric casting is performed on the input operand.

add()

Return op name linalg.add as a bitstring.

add(ssa)

linalg.add - Adds two tensors elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

The shapes and element types must be identical. The appropriate casts, broadcasts and reductions should be done previously to calling this op.

This means reduction/broadcast/element cast semantics is explicit. Further passes can take that into account when lowering this code. For example, a linalg.broadcast + linalg.add sequence can be lowered to a linalg.generic with different affine maps for the two operands.

batch_matmul()

Return op name linalg.batch_matmul as a bitstring.

batch_matmul(ssa)

linalg.batch_matmul - Performs a batched matrix multiplication of two 3D inputs.

Attributes

  • indexing_maps - Optional, AffineMapArrayAttr, AffineMap array attribute
  • cast - Optional, TypeFnAttr, allowed 32-bit signless integer cases: 0, 1

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting

them to the same data type as the accumulator/output.

Broadcast and Transpose semantics can be appiled by specifying the explicit attribute
'indexing_maps' as shown below. This is a list attribute, so must include maps for all
arguments if specified.

Example Transpose:
```mlir
linalg.batch_matmul
    indexing_maps = [affine_map<(batch, m, n, k) -> (batch, k, m)>, // transpose
                     affine_map<(batch, m, n, k) -> (batch, k, n)>,
                     affine_map<(batch, m, n, k) -> (batch, m, n)>]
    ins(%arg0, %arg1 : memref<2x5x3xf32>,memref<2x5x7xf32>)
    outs(%arg2: memref<2x3x7xf32>)
```

Example Broadcast:
```mlir
linalg.batch_matmul
    indexing_maps = [affine_map<(batch, m, n, k) -> (k)>,           // broadcast
                     affine_map<(batch, m, n, k) -> (batch, k, n)>,
                     affine_map<(batch, m, n, k) -> (batch, m, n)>]
    ins(%arg0, %arg1 : memref<5xf32>, memref<2x5x7xf32>)
    outs(%arg2: memref<2x3x7xf32>)
```

Example Broadcast and Transpose:
```mlir
linalg.batch_matmul
    indexing_maps = [affine_map<(batch, m, n, k) -> (m, k)>,        // broadcast
                     affine_map<(batch, m, n, k) -> (batch, n, k)>, // transpose
                     affine_map<(batch, m, n, k) -> (batch, m, n)>]
    ins(%arg0, %arg1 : memref<3x5xf32>, memref<2x7x5xf32>)
    outs(%arg2: memref<2x3x7xf32>)
```

batch_matvec()

Return op name linalg.batch_matvec as a bitstring.

batch_matvec(ssa)

linalg.batch_matvec - Performs a batched matrix-vector multiplication.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

batch_mmt4d()

Return op name linalg.batch_mmt4d as a bitstring.

batch_mmt4d(ssa)

linalg.batch_mmt4d - Performs a batched matrix-matrix-transpose multiplication of two batched-4D (5D) inputs.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Besides the outermost batch dimension has the same semantic as linalg.batch_matmul, the differences from linalg.batch_matmul in the non-batch dimensions are the same as linalg.mmt4d vs. linalg.matmul. See the description of lingalg.mmt4d.

batch_reduce_matmul()

Return op name linalg.batch_reduce_matmul as a bitstring.

batch_reduce_matmul(ssa)

linalg.batch_reduce_matmul - Performs a batch-reduce matrix multiplication on two inputs.

The partial multiplication results are reduced into a 2D output.

Attributes

  • indexing_maps - Optional, AffineMapArrayAttr, AffineMap array attribute
  • cast - Optional, TypeFnAttr, allowed 32-bit signless integer cases: 0, 1

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

Broadcast and Transpose semantics can be applied by specifying the explicit attribute 'indexing_maps' as shown below. This is a list attribute, so must include maps for all arguments if specified.

Example Transpose:

linalg.batch_reduce_matmul
    indexing_maps = [affine_map<(batch, m, n, k) -> (batch, k, m)>, // transpose
                     affine_map<(batch, m, n, k) -> (batch, k, n)>,
                     affine_map<(batch, m, n, k) -> (m, n)>]
    ins(%arg0, %arg1 : memref<2x5x3xf32>,memref<2x5x7xf32>)
    outs(%arg2: memref<3x7xf32>)

Example Broadcast:

linalg.batch_reduce_matmul
    indexing_maps = [affine_map<(batch, m, n, k) -> (k)>,         // broadcast
                     affine_map<(batch, m, n, k) -> (batch, k, n)>,
                     affine_map<(batch, m, n, k) -> (m, n)>]
    ins(%arg0, %arg1 : memref<5xf32>, memref<2x5x7xf32>)
    outs(%arg2: memref<3x7xf32>)

Example Broadcast and Transpose:

linalg.batch_reduce_matmul
    indexing_maps = [affine_map<(batch, m, n, k) -> (m, k)>,        // broadcast
                     affine_map<(batch, m, n, k) -> (batch, n, k)>, // transpose
                     affine_map<(batch, m, n, k) -> (m, n)>]
    ins(%arg0, %arg1 : memref<3x5xf32>, memref<2x7x5xf32>)
    outs(%arg2: memref<3x7xf32>)

batch_vecmat()

Return op name linalg.batch_vecmat as a bitstring.

batch_vecmat(ssa)

linalg.batch_vecmat - Performs a batched matrix-vector multiplication.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

broadcast()

Return op name linalg.broadcast as a bitstring.

broadcast(ssa)

linalg.broadcast - Static broadcast operator

Attributes

  • dimensions - Single, DenseI64ArrayAttr, i64 dense array attribute

Operands

  • input - Single, TensorOrMemref, memref of any non-token type values or ranked tensor of any non-token type values
  • init - Single, TensorOrMemref, memref of any non-token type values or ranked tensor of any non-token type values

Results

  • result - Variadic, AnyTensor, variadic of tensor of any non-token type values

Description

Broadcast the input into the given shape by adding dimensions.

Each index in the dimensions attribute refers to a dimension of init that is added by the operation. The indices must be unique and within the rank of init; the sizes of the remaining (non-added) dimensions of init must match the shape of input.

Example:

  %bcast = linalg.broadcast
      ins(%input:tensor<16xf32>)
      outs(%init:tensor<16x64xf32>)
      dimensions = [1]

ceil()

Return op name linalg.ceil as a bitstring.

ceil(ssa)

linalg.ceil - Applies ceil(x) elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

No numeric casting is performed on the input operand.

contract()

Return op name linalg.contract as a bitstring.

contract(ssa)

linalg.contract -

Perform a contraction on two inputs, accumulating into the third.

Attributes

  • indexing_maps - Single, AffineMapArrayAttr, AffineMap array attribute
  • cast - Optional, TypeFnAttr, allowed 32-bit signless integer cases: 0, 1

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

The semantics of contracting inputs A and B on top of C to produce output D is given by

D[H] = (SUM_{(I ∪ J) \ H} A[I] * B[J]) + C[H]

where I, J, and H are tuples of (pairwise distinct) dimension identifiers - meant to range over valid indices - corresponding to the results of the mandatory (projected permutation) indexing_maps for A, B and C. SUM_{dims} means reduce over all valid indices for the dimensions in the set dims (with I, J, and K treated as sets of dim identifiers).

The iteration space consists of all dimensions in I, J and H, i.e. the domain of each of the affine_maps. Like for einsums, the iteration type of each dim is inferred and is either:

  • reduction: the dim is used to index into A and B but not C. Per the above semantics, these dims will be contracted, i.e. reduced over.

  • parallel: the dim is used to index into C and at least one of A and B, and - deriving from matmul terminology - is either an "M-like" dim (if used on A and C), an "N-like" dim (if used on B and C) or a "batch"-dim (if used to index into A, B, and C).

For example, batch-matmul is given by I = ⟨ b, m, k ⟩, J = ⟨ b, k, n ⟩, H = ⟨ b, m, n ⟩ (with k as a contracting reduction-dimension while m, n and b have parallel iteration-type) and gets represented as:

%D = linalg.contract
    indexing_maps = [affine_map<(batch, m, n, k) -> (batch, m, k)>,
                     affine_map<(batch, m, n, k) -> (batch, k, n)>,
                     affine_map<(batch, m, n, k) -> (batch, m, n)>]
    ins(%A, %B: tensor<?x?x?xf32>, tensor<?x?x?xf32>)
    outs(%C: tensor<?x?x?xf32>) -> tensor<?x?x?xf32>

Note that by permuting dims in the affine_maps' results, accesses to to the inputs and output can be arbitrarily transposed. Similarly, arbitrary broadcasts can be achieved through leaving out dims on either input operand. For example, the following is a variant of batch-matmul with a transposition applied to A while B's 2D-matrix gets broadcasted along the batch dim:

linalg.contract
    indexing_maps = [affine_map<(batch, m, n, k) -> (batch, k, m)>,
                     affine_map<(batch, m, n, k) -> (k, n)>,
                     affine_map<(batch, m, n, k) -> (batch, m, n)>]
    ins(%A, %B: memref<?x?x?xf32>, memref<?x?xf32>)
    outs(%C: memref<?x?x?xf32>)

Numeric casting is performed on the operands to the inner multiplication, promoting/truncating them to the same data type as the accumulator/output.

TODO: Allow control over the combining/accumulating op and possibly the

  multiplication op.

conv_1d()

Return op name linalg.conv_1d as a bitstring.

conv_1d(ssa)

linalg.conv_1d - Performs 1-D convolution with no channels.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

conv_1d_ncw_fcw()

Return op name linalg.conv_1d_ncw_fcw as a bitstring.

conv_1d_ncw_fcw(ssa)

linalg.conv_1d_ncw_fcw - Performs 1-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NCW.
  • Kernel: FCW.

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

conv_1d_nwc_wcf()

Return op name linalg.conv_1d_nwc_wcf as a bitstring.

conv_1d_nwc_wcf(ssa)

linalg.conv_1d_nwc_wcf - Performs 1-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

conv_2d()

Return op name linalg.conv_2d as a bitstring.

conv_2d(ssa)

linalg.conv_2d - Performs 2-D convolution with no channels.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

conv_2d_nchw_fchw()

Return op name linalg.conv_2d_nchw_fchw as a bitstring.

conv_2d_nchw_fchw(ssa)

linalg.conv_2d_nchw_fchw - Performs 2-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NCHW.
  • Kernel: FCHW.

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

conv_2d_nchw_fchw_q()

Return op name linalg.conv_2d_nchw_fchw_q as a bitstring.

conv_2d_nchw_fchw_q(ssa)

linalg.conv_2d_nchw_fchw_q - Performs 2-D convolution with zero point offsets.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NCHW.
  • Kernel: FCHW.

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. This includes the zero point offsets common to quantized operations.

conv_2d_ngchw_fgchw()

Return op name linalg.conv_2d_ngchw_fgchw as a bitstring.

conv_2d_ngchw_fgchw(ssa)

linalg.conv_2d_ngchw_fgchw - Performs 2-D grouped convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NGCHW.
  • Kernel: FGCHW.

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

conv_2d_ngchw_gfchw()

Return op name linalg.conv_2d_ngchw_gfchw as a bitstring.

conv_2d_ngchw_gfchw(ssa)

linalg.conv_2d_ngchw_gfchw - Performs 2-D grouped convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NGCHW.
  • Kernel: GFCHW.

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

conv_2d_ngchw_gfchw_q()

Return op name linalg.conv_2d_ngchw_gfchw_q as a bitstring.

conv_2d_ngchw_gfchw_q(ssa)

linalg.conv_2d_ngchw_gfchw_q - Performs 2-D grouped convolution with zero-point offsets.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NGCHW.
  • Kernel: GFCHW.

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. This includes the zero point offsets common to quantized operations.

conv_2d_nhwc_fhwc()

Return op name linalg.conv_2d_nhwc_fhwc as a bitstring.

conv_2d_nhwc_fhwc(ssa)

linalg.conv_2d_nhwc_fhwc - Performs 2-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NHWC.
  • Kernel: FHWC.

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

conv_2d_nhwc_fhwc_q()

Return op name linalg.conv_2d_nhwc_fhwc_q as a bitstring.

conv_2d_nhwc_fhwc_q(ssa)

linalg.conv_2d_nhwc_fhwc_q - Performs 2-D convolution with zero point offsets.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NHWC.
  • Kernel: FHWC.

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. This includes the zero point offsets common to quantized operations.

conv_2d_nhwc_hwcf()

Return op name linalg.conv_2d_nhwc_hwcf as a bitstring.

conv_2d_nhwc_hwcf(ssa)

linalg.conv_2d_nhwc_hwcf - Performs 2-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NHWC.
  • Kernel: HWCF.

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

conv_2d_nhwc_hwcf_q()

Return op name linalg.conv_2d_nhwc_hwcf_q as a bitstring.

conv_2d_nhwc_hwcf_q(ssa)

linalg.conv_2d_nhwc_hwcf_q - Performs 2-D convolution with zero point offsets.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NHWC.
  • Kernel: HWCF.

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. This includes the zero point offsets common to quantized operations.

conv_2d_nhwgc_gfhwc()

Return op name linalg.conv_2d_nhwgc_gfhwc as a bitstring.

conv_2d_nhwgc_gfhwc(ssa)

linalg.conv_2d_nhwgc_gfhwc - Performs 2-D grouped convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NHWGC.
  • Kernel: GFHWC.

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

conv_2d_nhwgc_gfhwc_q()

Return op name linalg.conv_2d_nhwgc_gfhwc_q as a bitstring.

conv_2d_nhwgc_gfhwc_q(ssa)

linalg.conv_2d_nhwgc_gfhwc_q - Performs 2-D grouped convolution with zero point offsets.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NHWGC.
  • Kernel: GFHWC.

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. This includes the zero point offsets common to quantized operations.

conv_3d()

Return op name linalg.conv_3d as a bitstring.

conv_3d(ssa)

linalg.conv_3d - Performs 3-D convolution with no channels.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

conv_3d_ncdhw_fcdhw()

Return op name linalg.conv_3d_ncdhw_fcdhw as a bitstring.

conv_3d_ncdhw_fcdhw(ssa)

linalg.conv_3d_ncdhw_fcdhw - Performs 3-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

conv_3d_ndhwc_dhwcf()

Return op name linalg.conv_3d_ndhwc_dhwcf as a bitstring.

conv_3d_ndhwc_dhwcf(ssa)

linalg.conv_3d_ndhwc_dhwcf - Performs 3-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

conv_3d_ndhwc_dhwcf_q()

Return op name linalg.conv_3d_ndhwc_dhwcf_q as a bitstring.

conv_3d_ndhwc_dhwcf_q(ssa)

linalg.conv_3d_ndhwc_dhwcf_q - Performs 3-D convolution with zero point offsets.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. This includes the zero point offsets common to quantized operations.

copy()

Return op name linalg.copy as a bitstring.

copy(ssa)

linalg.copy - Copies the tensor elementwise.

Attributes

  • cast - Optional, TypeFnAttr, allowed 32-bit signless integer cases: 0, 1

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

depthwise_conv_1d_ncw_cw()

Return op name linalg.depthwise_conv_1d_ncw_cw as a bitstring.

depthwise_conv_1d_ncw_cw(ssa)

linalg.depthwise_conv_1d_ncw_cw - Performs depth-wise 1-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. Multiplier is set to 1 which is a special case for most depthwise convolutions.

depthwise_conv_1d_nwc_wc()

Return op name linalg.depthwise_conv_1d_nwc_wc as a bitstring.

depthwise_conv_1d_nwc_wc(ssa)

linalg.depthwise_conv_1d_nwc_wc - Performs depth-wise 1-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. Multiplier is set to 1 which is a special case for most depthwise convolutions.

depthwise_conv_1d_nwc_wcm()

Return op name linalg.depthwise_conv_1d_nwc_wcm as a bitstring.

depthwise_conv_1d_nwc_wcm(ssa)

linalg.depthwise_conv_1d_nwc_wcm - Performs depth-wise 1-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

depthwise_conv_2d_nchw_chw()

Return op name linalg.depthwise_conv_2d_nchw_chw as a bitstring.

depthwise_conv_2d_nchw_chw(ssa)

linalg.depthwise_conv_2d_nchw_chw - Performs depth-wise 2-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. Multiplier is set to 1 which is a special case for most depthwise convolutions.

depthwise_conv_2d_nhwc_hwc()

Return op name linalg.depthwise_conv_2d_nhwc_hwc as a bitstring.

depthwise_conv_2d_nhwc_hwc(ssa)

linalg.depthwise_conv_2d_nhwc_hwc - Performs depth-wise 2-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. Multiplier is set to 1 which is a special case for most depthwise convolutions.

depthwise_conv_2d_nhwc_hwc_q()

Return op name linalg.depthwise_conv_2d_nhwc_hwc_q as a bitstring.

depthwise_conv_2d_nhwc_hwc_q(ssa)

linalg.depthwise_conv_2d_nhwc_hwc_q - Performs depth-wise 2-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

depthwise_conv_2d_nhwc_hwcm()

Return op name linalg.depthwise_conv_2d_nhwc_hwcm as a bitstring.

depthwise_conv_2d_nhwc_hwcm(ssa)

linalg.depthwise_conv_2d_nhwc_hwcm - Performs depth-wise 2-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

depthwise_conv_2d_nhwc_hwcm_q()

Return op name linalg.depthwise_conv_2d_nhwc_hwcm_q as a bitstring.

depthwise_conv_2d_nhwc_hwcm_q(ssa)

linalg.depthwise_conv_2d_nhwc_hwcm_q - Performs depth-wise 2-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

depthwise_conv_3d_ncdhw_cdhw()

Return op name linalg.depthwise_conv_3d_ncdhw_cdhw as a bitstring.

depthwise_conv_3d_ncdhw_cdhw(ssa)

linalg.depthwise_conv_3d_ncdhw_cdhw - Performs depth-wise 3-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. Multiplier is set to 1 which is a special case for most depthwise convolutions.

depthwise_conv_3d_ndhwc_dhwc()

Return op name linalg.depthwise_conv_3d_ndhwc_dhwc as a bitstring.

depthwise_conv_3d_ndhwc_dhwc(ssa)

linalg.depthwise_conv_3d_ndhwc_dhwc - Performs depth-wise 3-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. Multiplier is set to 1 which is a special case for most depthwise convolutions.

depthwise_conv_3d_ndhwc_dhwcm()

Return op name linalg.depthwise_conv_3d_ndhwc_dhwcm as a bitstring.

depthwise_conv_3d_ndhwc_dhwcm(ssa)

linalg.depthwise_conv_3d_ndhwc_dhwcm - Performs depth-wise 3-D convolution.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

div()

Return op name linalg.div as a bitstring.

div(ssa)

linalg.div - Divides the first tensor by the second tensor, elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

The shapes and element types must be identical. The appropriate casts, broadcasts and reductions should be done previously to calling this op.

This means reduction/broadcast/element cast semantics is explicit. Further passes can take that into account when lowering this code. For example, a linalg.broadcast + linalg.div sequence can be lowered to a linalg.generic with different affine maps for the two operands.

div_unsigned()

Return op name linalg.div_unsigned as a bitstring.

div_unsigned(ssa)

linalg.div_unsigned - Divides the first tensor by the second tensor, elementwise. For integer types, performs an unsigned division.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

The shapes and element types must be identical. The appropriate casts, broadcasts and reductions should be done previously to calling this op.

This means reduction/broadcast/element cast semantics is explicit. Further passes can take that into account when lowering this code. For example, a linalg.broadcast + linalg.div sequence can be lowered to a linalg.generic with different affine maps for the two operands.

dot()

Return op name linalg.dot as a bitstring.

dot(ssa)

linalg.dot - Performs a dot product of two vectors to a scalar result.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

elementwise()

Return op name linalg.elementwise as a bitstring.

elementwise(ssa)

linalg.elementwise - Performs element-wise operation

Attributes

  • kind - Single, ElementwiseKindAttr, allowed 32-bit signless integer cases: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35
  • indexing_maps - Optional, AffineMapArrayAttr, AffineMap array attribute

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

The attribute kind describes arithmetic operation to perform. The operation kind can be unary (e.g. max), binary (e.g. add) or ternary (e.g. select).

By default, all indexing maps are identities. In the case of default indexing map, all input and output shapes must match. The number of dims in each of the identity maps is equal to the rank of the output type.

Affine-maps for operands and result are required to be provided by the user when a transpose and/or broadcast is needed on any operand. When a map is not provided, default identity maps are inferred for each operand.

Iterator-types are always all parallel. Iterator-types are needed for constructing the underlying structured op.

The number of dims of the iterator-types are inferred from the rank of the result type.

Example:

Defining a unary linalg.elementwise with default indexing-map:

%exp = linalg.elementwise
    kind=#linalg.elementwise_kind<exp>
    ins(%x : tensor<4x16x8xf32>)
    outs(%y: tensor<4x16x8xf32>) -> tensor<4x16x8xf32>

Defining a binary linalg.elementwise with user-defined indexing-map:

%add = linalg.elementwise
    kind=#linalg.elementwise_kind<add>
    indexing_maps = [#transpose, #broadcast, #identity]
    ins(%exp, %arg1 : tensor<4x16x8xf32>, tensor<4x16xf32>)
    outs(%arg2: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>

erf()

Return op name linalg.erf as a bitstring.

erf(ssa)

linalg.erf - Applies erf(x) elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

No numeric casting is performed on the input operand.

exp()

Return op name linalg.exp as a bitstring.

exp(ssa)

linalg.exp - Applies exp(x) elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

No numeric casting is performed on the input operand.

fill()

Return op name linalg.fill as a bitstring.

fill(ssa)

linalg.fill - Fills the output tensor with the given value.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Works for arbitrary ranked output tensors since the operation performs scalar accesses only and is thus rank polymorphic. The value operand type must match the element type of the output.

fill_rng_2d()

Return op name linalg.fill_rng_2d as a bitstring.

fill_rng_2d(ssa)

linalg.fill_rng_2d - Fills the output tensor with pseudo random numbers.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

The operation generations pseudo random numbers using a linear congruential generator. It provides no guarantees regarding the distribution of the generated random numbers. Instead of generating the random numbers sequentially, it instantiates one random number generator per data element and runs them in parallel. The seed operand and the indices of the data element seed the random number generation. The min and max operands limit the range of the generated random numbers.

floor()

Return op name linalg.floor as a bitstring.

floor(ssa)

linalg.floor - Applies floor(x) elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

No numeric casting is performed on the input operand.

generic()

Return op name linalg.generic as a bitstring.

generic(ssa)

linalg.generic

Attributes

  • indexing_maps - Single, AffineMapArrayAttr, AffineMap array attribute
  • iterator_types - Single, IteratorTypeArrayAttr, Iterator type should be an enum.
  • doc - Optional, StrAttr, string attribute
  • library_call - Optional, StrAttr, string attribute

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Generic Linalg op form where the key properties of the computation are specified as attributes. In pretty form, a linalg.generic op is written as:

  linalg.generic #trait_attribute
      ins(%A, %B : memref<?x?xf32, stride_specification>,
                   memref<?x?xf32, stride_specification>)
      outs(%C : memref<?x?xf32, stride_specification>)
      attrs = {other-optional-attributes}
      {region}

Where #trait_attributes is an alias of a dictionary attribute containing:

  • doc [optional]: a documentation string
  • indexing_maps: a list of AffineMapAttr, one AffineMapAttr per each input and output view. Such AffineMapAttr specifies the mapping between the loops and the indexing within each view.
  • library_call [optional]: a StringAttr containing the name of an external library function that the linalg.generic operation maps to. The external library is assumed to be dynamically linked and no strong compile-time guarantees are provided. In the absence of such a library call, linalg.generic will always lower to loops.
  • iterator_types: an ArrayAttr specifying the type of the enclosing loops. Each element of the list represents and iterator of one of the following types: parallel, reduction, window

Example: Defining a #matmul_trait attribute in MLIR can be done as follows:

  #matmul_accesses = [
    (m, n, k) -> (m, k),
    (m, n, k) -> (k, n),
    (m, n, k) -> (m, n)
  ]
  #matmul_trait = {
    doc = "C(m, n) += A(m, k) * B(k, n)",
    indexing_maps = #matmul_accesses,
    library_call = "linalg_matmul",
    iterator_types = ["parallel", "parallel", "reduction"]
  }

And can be reused in multiple places as:

  linalg.generic #matmul_trait
    ins(%A, %B : memref<?x?xf32, stride_specification>,
                 memref<?x?xf32, stride_specification>)
    outs(%C : memref<?x?xf32, stride_specification>)
    {other-optional-attributes} {
    ^bb0(%a: f32, %b: f32, %c: f32) :
      %d = arith.mulf %a, %b: f32
      %e = arith.addf %c, %d: f32
      linalg.yield %e : f32
  }

This may lower to either:

  call @linalg_matmul(%A, %B, %C) :
    (memref<?x?xf32, stride_specification>,
     memref<?x?xf32, stride_specification>,
     memref<?x?xf32, stride_specification>)
    -> ()

or IR resembling:

scf.for %m = %c0 to %M step %c1 {
  scf.for %n = %c0 to %N step %c1 {
    scf.for %k = %c0 to %K step %c1 {
      %a = load %A[%m, %k] : memref<?x?xf32, stride_specification>
      %b = load %B[%k, %n] : memref<?x?xf32, stride_specification>
      %c = load %C[%m, %n] : memref<?x?xf32, stride_specification>
      %d = arith.mulf %a, %b: f32
      %e = arith.addf %c, %d: f32
      store %e, %C[%m, %n] : memref<?x?x?xf32, stride_specification>
    }
  }
}

index()

Return op name linalg.index as a bitstring.

index(ssa)

linalg.index - linalg index operation

This op has support for result type inference.

Attributes

  • dim - Single, I64Attr, 64-bit signless integer attribute whose minimum value is 0

Results

  • result - Single, Index, index

Description

The linalg.index operation returns the iteration index of the immediately enclosing linalg structured operation for the iteration dimension dim. The dim attribute specifies the position of the accessed dimension in the indexing map domain.

Example:

#map = affine_map<(i, j) -> (i, j)>
linalg.generic {indexing_maps = [#map, #map],
                iterator_types = ["parallel", "parallel"]}
  outs(%I, %J : memref<?x?xindex>, memref<?x?xindex>) {
  ^bb0(%arg0 : index, %arg1 : index):
  // Access the outer iteration dimension i
  %i = linalg.index 0 : index
  // Access the inner iteration dimension j
  %j = linalg.index 1 : index
  linalg.yield %i, %j : index, index
}

This may lower to IR resembling:

%0 = dim %I, %c0 : memref<?x?xindex>
%1 = dim %I, %c1 : memref<?x?xindex>
scf.for %i = %c0 to %0 step %c1 {
  scf.for %j = %c0 to %1 step %c1 {
    store %i, %I[%i, %j] : memref<?x?xindex>
    store %j, %J[%i, %j] : memref<?x?xindex>
  }
}

log()

Return op name linalg.log as a bitstring.

log(ssa)

linalg.log - Applies log(x) elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

No numeric casting is performed on the input operand.

map()

Return op name linalg.map as a bitstring.

map(ssa)

linalg.map - Elementwise operations

Operands

  • inputs - Variadic, TensorOrMemref, variadic of memref of any non-token type values or ranked tensor of any non-token type values
  • init - Single, TensorOrMemref, memref of any non-token type values or ranked tensor of any non-token type values

Results

  • result - Variadic, AnyTensor, variadic of tensor of any non-token type values

Description

Models elementwise operations on tensors in terms of arithmetic operations on the corresponding elements.

Example:

  %add = linalg.map
      ins(%lhs, %rhs : tensor<64xf32>, tensor<64xf32>)
      outs(%init: tensor<64xf32>)
      (%lhs_elem: f32, %rhs_elem: f32) {
        %0 = arith.addf %lhs_elem, %rhs_elem: f32
        linalg.yield %0: f32
      }

Shortened print form is available for simple maps where the body contains exactly two operations (the payload operation and a yield), the payload operation has the same number of operands as block arguments with operands matching block arguments in order, and the yield operand is the result of the payload operation.

The example above will be printed using the shortened form as:

  %add = linalg.map { arith.addf }
      ins(%lhs, %rhs : tensor<64xf32>, tensor<64xf32>)
      outs(%init: tensor<64xf32>)

matmul()

Return op name linalg.matmul as a bitstring.

matmul(ssa)

linalg.matmul -

Performs a matrix multiplication of two 2D inputs without broadcast or transpose.

Attributes

  • indexing_maps - Optional, AffineMapArrayAttr, AffineMap array attribute
  • cast - Optional, TypeFnAttr, allowed 32-bit signless integer cases: 0, 1

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

Broadcast and Transpose semantics can be appiled by specifying the explicit attribute 'indexing_maps' as shown below.This is a list attribute, so the list must include all the maps if specified.

Example Transpose:

linalg.matmul
    indexing_maps = [affine_map<(m, n, k) -> (k, m)>, // transpose
                     affine_map<(m, n, k) -> (k, n)>,
                     affine_map<(m, n, k) -> (m, n)>]
    ins(%arg0, %arg1 : memref<5x3xf32>,memref<5x7xf32>)
    outs(%arg2: memref<3x7xf32>)

Example Broadcast:

linalg.matmul
    indexing_maps = [affine_map<(m, n, k) -> (k)>,     // broadcast
                     affine_map<(m, n, k) -> (k, n)>,
                     affine_map<(m, n, k) -> (m, n)>]
    ins(%arg0, %arg1 : memref<3xf32>, memref<5x7xf32>)
    outs(%arg2: memref<3x7xf32>)

Example Broadcast and transpose:

linalg.matmul
    indexing_maps = [affine_map<(m, n, k) -> (k, m)>, // transpose
                     affine_map<(m, n, k) -> (k)>,    // broadcast
                     affine_map<(m, n, k) -> (m, n)>]
    ins(%arg0, %arg1 : memref<5x3xf32>, memref<7xf32>)
    outs(%arg2: memref<3x7xf32>)

matvec()

Return op name linalg.matvec as a bitstring.

matvec(ssa)

linalg.matvec - Performs a matrix-vector multiplication.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

max()

Return op name linalg.max as a bitstring.

max(ssa)

linalg.max - Takes the max (signed) between two inputs, elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

The shapes and element types must be identical. The appropriate casts, broadcasts and reductions should be done previously to calling this op.

This means reduction/broadcast/element cast semantics is explicit. Further passes can take that into account when lowering this code. For example, a linalg.broadcast + linalg.max sequence can be lowered to a linalg.generic with different affine maps for the two operands.

min()

Return op name linalg.min as a bitstring.

min(ssa)

linalg.min - Takes the min (signed) between two inputs, elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

The shapes and element types must be identical. The appropriate casts, broadcasts and reductions should be done previously to calling this op.

This means reduction/broadcast/element cast semantics is explicit. Further passes can take that into account when lowering this code. For example, a linalg.broadcast + linalg.min sequence can be lowered to a linalg.generic with different affine maps for the two operands.

mmt4d()

Return op name linalg.mmt4d as a bitstring.

mmt4d(ssa)

linalg.mmt4d - Performs a matrix-matrix-transpose multiplication of two 4D inputs.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Differences from linalg.matmul:

  • The right hand side is transposed, whence the 't' in 'mmt'.
  • The input and output tensors have a 4D shape instead of a 2D shape. They are interpreted as 2D matrices with one level of 2D tile subdivision, whence the 2+2=4 dimensions. The inner tile dimensions are identified with '0' suffixes below, for instance the LHS matrix shape (M, K, M0, K0) reads as: MxK tiles, each of shape M0xK0.

mul()

Return op name linalg.mul as a bitstring.

mul(ssa)

linalg.mul - Multiplies two tensors elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

The shapes and element types must be identical. The appropriate casts, broadcasts and reductions should be done previously to calling this op.

This means reduction/broadcast/element cast semantics is explicit. Further passes can take that into account when lowering this code. For example, a linalg.broadcast + linalg.mul sequence can be lowered to a linalg.generic with different affine maps for the two operands.

negf()

Return op name linalg.negf as a bitstring.

negf(ssa)

linalg.negf - Applies negf(x) elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

No numeric casting is performed on the input operand.

pack()

Return op name linalg.pack as a bitstring.

pack(ssa)

linalg.pack - linalg.pack operation

Attributes

  • outer_dims_perm - Optional, DenseI64ArrayAttr, i64 dense array attribute
  • inner_dims_pos - Single, DenseI64ArrayAttr, i64 dense array attribute
  • static_inner_tiles - Single, DenseI64ArrayAttr, i64 dense array attribute

Operands

  • source - Single, anonymous/composite constraint, Tensor or MemRef of any non-token type values
  • dest - Single, anonymous/composite constraint, Tensor or MemRef of any non-token type values
  • padding_value - Optional, AnyType, any non-token type
  • inner_tiles - Variadic, Index, variadic of index

Results

  • result - Optional, AnyRankedTensor, ranked tensor of any non-token type values

Description

The "pack" operation converts a source tensor of rank n into a result tensor of rank n + k with a tiled and packed layout (maybe with padding) and optionally transposes the tiled source tensor dimensions.

inner_tiles (mandatory) specifies k tile sizes. These tile sizes correspond to the least significant ("inner") result tensor dimension sizes, in the same order. Tile sizes can be static or dynamic.

inner_dims_pos (mandatory) specifies k source tensor dimensions that are being tiled, where 0 <= k <= n.

  • inner_dims_pos[i] specifies the source tensor dimension tiled by inner_tiles[i] where 0 <= i < k. All the values in inner_dims_pos are within [0, n).
  • The tiled dimensions (of size inner_tiles) are added to the end of the result tensor in the order in which they appear, i.e. shape(result)[rank(source) + i] = inner_tiles[i] for 0 <= i < k.
  • The following relationship for the tiled dimensions holds: shape(result)[inner_dims_pos[i]] = shape(source)[inner_dims_pos[i]] / inner_tiles[i], where (⌈/⌉ indicates CeilDiv).

Example: If inner_tiles = [16, 32], the result tensor has a shape of ...x16x32. If inner_dims_pos = [0, 1], the 0th source dimension is tiled by 16 and the 1st source dimension is tiled by 32. Other source dimensions (if any) are not tiled. If inner_dims_pos = [1, 0], the 1st dimension is tiled by 16 and the 0th dimension is tiled by 32.

Example:

// NC to NCnc
%0 = linalg.pack %source inner_dims_pos = [0, 1] inner_tiles = [8, 32]
    into %dest : tensor<128x256xf32> -> tensor<16x8 x 8x32 xf32>
//                                             \  /   \  /
//                                 Outer Dims: 16x8   Inner Dims: 8x32

// CHW to CHWhw
%0 = linalg.pack %source inner_dims_pos = [2, 1] inner_tiles = [4, 2]
    into %dest : tensor<3x20x24xf32> -> tensor<3x10x6 x 4x2 xf32>
//                                              \  /    \ /
//                                 Outer Dims: 3x10x6  Inner Dims: 4x2

// HCW to HCWhw
%0 = linalg.pack %source inner_dims_pos = [2, 0] inner_tiles = [4, 2]
    into %dest : tensor<18x3x32xf32> -> tensor<9x3x8 x 4x2 xf32>
//                                              \  /   \ /
//                                 Outer Dims: 9x3x8  Inner Dims: 4x2

outer_dims_perm (optional) specifies a permutation for the outer dimensions. If specified, it must have n elements.

Example:

// CK to KCck
%0 = linalg.pack %source outer_dims_perm = [1, 0] inner_dims_pos = [0, 1]
    inner_tiles = [8, 32] into %dest
    : tensor<128x256xf32> -> tensor<8x16 x 8x32 xf32>
//                                  \  /
//            compare with "NC to NCnc": outer dims are transposed

padding_value specifies a padding value at the boundary on non-perfectly divisible dimensions. Padding is optional:

  • If absent, it is assumed that for all inner tiles, shape(source)[inner_dims_pos[i]] % inner_tiles[i] == 0, i.e. all inner tiles divide perfectly the corresponding outer dimension in the result tensor. It is UB if the tile does not perfectly divide the dimension.
  • If present, it will pad along high dimensions (high-padding) to make the tile complete. Note that it is not allowed to have artificial padding that is not strictly required by linalg.pack (i.e., padding past what is needed to complete the last tile along each packed dimension). It is UB if extra padding is requested. It is not possible to verify the requirements statically with dynamic shapes, so they are treated as UB.

Example:

%0 = linalg.pack %arg0 padding_value(%pad : f32) outer_dims_perm = [2, 1, 0]
    inner_dims_pos = [1] inner_tiles = [2] into %arg1
    : tensor<200x127x256xf32> -> tensor<256x64x200x2xf32>
//                 \
//                padded and tiled dim
//
// Source dimension 1 is tiled. 64 does not divide 127 evenly, so 1 padded
// element is added at the end.
//
// Note: Only tiled dimensions can be padded.

Invalid example that has artificial padding:

%0 = linalg.pack %src padding_value(%cst : f32) inner_dims_pos = [0]
    inner_tiles = [8] into %dest
    : tensor<9xf32> -> tensor<3x8xf32>
//                             \
//            expect tensor<2x8xf32> because CeilDiv(9, 8) = 2

pooling_nchw_max()

Return op name linalg.pooling_nchw_max as a bitstring.

pooling_nchw_max(ssa)

linalg.pooling_nchw_max - Performs max pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_nchw_sum()

Return op name linalg.pooling_nchw_sum as a bitstring.

pooling_nchw_sum(ssa)

linalg.pooling_nchw_sum - Performs sum pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NCHW.
  • Kernel: HW.

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_ncw_max()

Return op name linalg.pooling_ncw_max as a bitstring.

pooling_ncw_max(ssa)

linalg.pooling_ncw_max - Performs max pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_ncw_sum()

Return op name linalg.pooling_ncw_sum as a bitstring.

pooling_ncw_sum(ssa)

linalg.pooling_ncw_sum - Performs sum pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NCW.
  • Kernel: W.

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_ndhwc_max()

Return op name linalg.pooling_ndhwc_max as a bitstring.

pooling_ndhwc_max(ssa)

linalg.pooling_ndhwc_max - Performs 3D max pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_ndhwc_min()

Return op name linalg.pooling_ndhwc_min as a bitstring.

pooling_ndhwc_min(ssa)

linalg.pooling_ndhwc_min - Performs 3D min pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_ndhwc_sum()

Return op name linalg.pooling_ndhwc_sum as a bitstring.

pooling_ndhwc_sum(ssa)

linalg.pooling_ndhwc_sum - Performs 3D sum pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [3]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_nhwc_max()

Return op name linalg.pooling_nhwc_max as a bitstring.

pooling_nhwc_max(ssa)

linalg.pooling_nhwc_max - Performs max pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_nhwc_max_unsigned()

Return op name linalg.pooling_nhwc_max_unsigned as a bitstring.

pooling_nhwc_max_unsigned(ssa)

linalg.pooling_nhwc_max_unsigned - Performs unsigned max pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_nhwc_min()

Return op name linalg.pooling_nhwc_min as a bitstring.

pooling_nhwc_min(ssa)

linalg.pooling_nhwc_min - Performs min pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_nhwc_min_unsigned()

Return op name linalg.pooling_nhwc_min_unsigned as a bitstring.

pooling_nhwc_min_unsigned(ssa)

linalg.pooling_nhwc_min_unsigned - Performs unsigned min pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_nhwc_sum()

Return op name linalg.pooling_nhwc_sum as a bitstring.

pooling_nhwc_sum(ssa)

linalg.pooling_nhwc_sum - Performs sum pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [2]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NHWC.
  • Kernel: HW.

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_nwc_max()

Return op name linalg.pooling_nwc_max as a bitstring.

pooling_nwc_max(ssa)

linalg.pooling_nwc_max - Performs max pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_nwc_max_unsigned()

Return op name linalg.pooling_nwc_max_unsigned as a bitstring.

pooling_nwc_max_unsigned(ssa)

linalg.pooling_nwc_max_unsigned - Performs unsigned max pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_nwc_min()

Return op name linalg.pooling_nwc_min as a bitstring.

pooling_nwc_min(ssa)

linalg.pooling_nwc_min - Performs min pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_nwc_min_unsigned()

Return op name linalg.pooling_nwc_min_unsigned as a bitstring.

pooling_nwc_min_unsigned(ssa)

linalg.pooling_nwc_min_unsigned - Performs unsigned min pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

pooling_nwc_sum()

Return op name linalg.pooling_nwc_sum as a bitstring.

pooling_nwc_sum(ssa)

linalg.pooling_nwc_sum - Performs sum pooling.

Attributes

  • strides - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]
  • dilations - Optional, anonymous/composite constraint, 64-bit signless int elements attribute of shape [1]

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Layout:

  • Input: NWC.
  • Kernel: W.

Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output.

powf()

Return op name linalg.powf as a bitstring.

powf(ssa)

linalg.powf - Takes the powf(lhs, rhs) between two inputs, elementwise. For powf(arg, 2) use linalg.square.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Only applies to floating point values.

The shapes and element types must be identical. The appropriate casts, broadcasts and reductions should be done previously to calling this op.

This means reduction/broadcast/element cast semantics is explicit. Further passes can take that into account when lowering this code. For example, a linalg.broadcast + linalg.powf sequence can be lowered to a linalg.generic with different affine maps for the two operands.

quantized_batch_matmul()

Return op name linalg.quantized_batch_matmul as a bitstring.

quantized_batch_matmul(ssa)

linalg.quantized_batch_matmul - Performs a batched matrix multiplication of two 3D inputs.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. The quantized variant includes zero-point adjustments for the left and right operands of the matmul.

quantized_matmul()

Return op name linalg.quantized_matmul as a bitstring.

quantized_matmul(ssa)

linalg.quantized_matmul - Performs a matrix multiplication of two 2D inputs.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. The quantized variant includes zero-point adjustments for the left and right operands of the matmul.

reciprocal()

Return op name linalg.reciprocal as a bitstring.

reciprocal(ssa)

linalg.reciprocal - Applies reciprocal(x) elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

No numeric casting is performed on the input operand.

reduce()

Return op name linalg.reduce as a bitstring.

reduce(ssa)

linalg.reduce - Reduce operator

Attributes

  • dimensions - Single, DenseI64ArrayAttr, i64 dense array attribute should be in increasing order

Operands

  • inputs - Variadic, TensorOrMemref, variadic of memref of any non-token type values or ranked tensor of any non-token type values
  • inits - Variadic, TensorOrMemref, variadic of memref of any non-token type values or ranked tensor of any non-token type values

Results

  • anonymous - Variadic, AnyTensor, variadic of tensor of any non-token type values

Description

Executes combiner on the dimensions of inputs and returns the reduced result. The dimensions attribute needs to list the reduction dimensions in increasing order.

Example:

  %reduce = linalg.reduce
      ins(%input:tensor<16x32x64xf32>)
      outs(%init:tensor<16x64xf32>)
      dimensions = [1]
      (%in: f32, %out: f32) {
        %0 = arith.addf %out, %in: f32
        linalg.yield %0: f32
      }

Shortened print form is available for simple reduces where the body contains exactly two operations (the payload operation and a yield), the payload operation has the same number of operands as block arguments, the first block argument (init) is the last operand of the payload operation with remaining operands matching remaining block arguments in order, and the yield operand is the result of the payload operation.

The example above will be printed using the shortened form as:

  %reduce = linalg.reduce { arith.addf }
      ins(%input:tensor<16x32x64xf32>)
      outs(%init:tensor<16x64xf32>)
      dimensions = [1]

round()

Return op name linalg.round as a bitstring.

round(ssa)

linalg.round - Applies round(x) elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

No numeric casting is performed on the input operand.

rsqrt()

Return op name linalg.rsqrt as a bitstring.

rsqrt(ssa)

linalg.rsqrt - Applies rsqrt(x) elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

No numeric casting is performed on the input operand.

select()

Return op name linalg.select as a bitstring.

select(ssa)

linalg.select - Chooses one value based on a binary condition supplied as its first operand.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

The shapes and element types must be identical. The appropriate casts, broadcasts and reductions should be done previously to calling this op.

This means reduction/broadcast/element cast semantics is explicit. Further passes can take that into account when lowering this code. For example, a linalg.broadcast + linalg.select sequence can be lowered to a linalg.generic with different affine maps for the two operands.

softmax()

Return op name linalg.softmax as a bitstring.

softmax(ssa)

linalg.softmax - Softmax operator

Attributes

  • dimension - Single, I64Attr, 64-bit signless integer attribute

Operands

  • input - Single, AnyShaped, shaped of any non-token type values
  • output - Single, AnyShaped, shaped of any non-token type values

Results

  • result - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

linalg.softmax computes a numerically stable version of softmax.

For a given input tensor and a specified dimension d, compute:

  1. the max m along that dimension d
  2. f(x) = exp(x - m)
  3. sum f(x) along dimension d to get l(x).
  4. compute the final result f(x) / l(x).

This is an aggregate linalg operation that further reduces to a small DAG of structured operations.

Warning: Regarding the tiling capabilities, the implementation doesn't check that the provided dimensions make sense. This is the responsability of the transformation calling the tiling to ensure that the provided sizes for each dimension make sense with respect to the semantic of softmax.

sqrt()

Return op name linalg.sqrt as a bitstring.

sqrt(ssa)

linalg.sqrt - Applies sqrt(x) elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

No numeric casting is performed on the input operand.

square()

Return op name linalg.square as a bitstring.

square(ssa)

linalg.square - Applies square(x) elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

No numeric casting is performed on the input operand.

sub()

Return op name linalg.sub as a bitstring.

sub(ssa)

linalg.sub - Subtracts two tensors elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

The shapes and element types must be identical. The appropriate casts, broadcasts and reductions should be done previously to calling this op.

This means reduction/broadcast/element cast semantics is explicit. Further passes can take that into account when lowering this code. For example, a linalg.broadcast + linalg.sub sequence can be lowered to a linalg.generic with different affine maps for the two operands.

tanh()

Return op name linalg.tanh as a bitstring.

tanh(ssa)

linalg.tanh - Applies tanh(x) elementwise.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

No numeric casting is performed on the input operand.

transpose()

Return op name linalg.transpose as a bitstring.

transpose(ssa)

linalg.transpose - Transpose operator

Attributes

  • permutation - Single, DenseI64ArrayAttr, i64 dense array attribute

Operands

  • input - Single, TensorOrMemref, memref of any non-token type values or ranked tensor of any non-token type values
  • init - Single, TensorOrMemref, memref of any non-token type values or ranked tensor of any non-token type values

Results

  • result - Variadic, AnyTensor, variadic of tensor of any non-token type values

Description

Permutes the dimensions of input according to the given permutation. dim(result, i) = dim(input, permutation[i])

This op actually moves data, unlike memref.transpose which is a metadata operation only that produces a transposed "view".

Example:

  %transpose = linalg.transpose
      ins(%input:tensor<16x64xf32>)
      outs(%init:tensor<64x16xf32>)
      permutation = [1, 0]

unpack()

Return op name linalg.unpack as a bitstring.

unpack(ssa)

linalg.unpack - linalg.unpack operation

Attributes

  • outer_dims_perm - Optional, DenseI64ArrayAttr, i64 dense array attribute
  • inner_dims_pos - Single, DenseI64ArrayAttr, i64 dense array attribute
  • static_inner_tiles - Single, DenseI64ArrayAttr, i64 dense array attribute

Operands

  • source - Single, anonymous/composite constraint, Tensor or MemRef of any non-token type values
  • dest - Single, anonymous/composite constraint, Tensor or MemRef of any non-token type values
  • inner_tiles - Variadic, Index, variadic of index

Results

  • result - Optional, AnyRankedTensor, ranked tensor of any non-token type values

Description

The "unpack" operation converts a source tensor of rank n with a tiled and packed layout to a result tensor of rank n - k.

inner_tiles (mandatory) specifies k tile sizes. These tile sizes correspond to the least significant ("inner") source tensor dimension sizes. The behavior of this op is undefined if:

  • inner_tiles do not exactly match with the corresponding source tensor dimension sizes.
  • Or, inner_tiles[i] does not divide the size of dimension inner_dims_pos[i] (assuming that outer_dims_perm is not specified) evenly.

inner_dims_pos (mandatory) specifies k result tensor (i.e. unpacked tensor) dimensions that were tiled with the inner_tiles to create the packed source tensor. The source tensor (i.e. packed tensor) dimensions can be unpacked given inner_dims_pos as follows.

  • For 0 <= i < k the following relationship holds: shape(result)[inner_dims_pos[i]] <= shape(source)[n-k+i] * shape(source)[inner_dims_pos[i]].
  • For 0 <= j < n-k and j not in inner_dims_pos the following relationship holds: shape(result)[j] = shape(source)[j].

outer_dims_perm (optional) specifies a permutation for the outer dimensions. If specified, it must have n - k elements. If specified, this permutation is applied before combining any dimensions.

Note, the unpack operation may drop any padding introduced by the pack operation and hence the following holds NumElementsOf(source) >= NumElementsOf(result).

Examples:

// NCnc to NC:
%0 = linalg.unpack %source inner_dims_pos = [0, 1] inner_tiles = [8, 32]
    into %dest : tensor<16x8 x 8x32 xf32> -> tensor<128x256xf32>
//                      \  /   \  /
//          Outer Dims: 16x8  Inner Dims: 8x32

// CK to KCck:
%0 = linalg.unpack %source outer_dims_perm = [1, 0] inner_dims_pos = [0, 1]
    inner_tiles = [8, 32]
    into %dest : tensor<8x16 x 8x32 xf32> -> tensor<128x256xf32>
//                      \  /   \  /
//          Outer Dims: 8x16  Inner Dims: 8x32

// CHW to CHWhw:
%0 = linalg.unpack %source inner_dims_pos = [2, 1] inner_tiles = [4, 2]
    into %dest : tensor<3x10x6 x 4x2 xf32> -> tensor<3x20x24xf32>
//                       \  /    \ /
//          Outer Dims: 3x10x6  Inner Dims: 4x2

// HCW to HCWhw
%0 = linalg.unpack %source inner_dims_pos = [2, 0] inner_tiles = [4, 2]
    into %dest : tensor<9x3x8 x 4x2 xf32> -> tensor<18x3x32xf32>
//                       \  /   \ /
//          Outer Dims: 9x3x8   Inner Dims: 4x2

vecmat()

Return op name linalg.vecmat as a bitstring.

vecmat(ssa)

linalg.vecmat - Performs a vector-matrix multiplication.

Operands

  • inputs - Variadic, AnyType, variadic of any non-token type
  • outputs - Variadic, AnyShaped, variadic of shaped of any non-token type values

Results

  • result_tensors - Variadic, AnyRankedTensor, variadic of ranked tensor of any non-token type values

Description

Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output.

winograd_filter_transform()

Return op name linalg.winograd_filter_transform as a bitstring.

winograd_filter_transform(ssa)

linalg.winograd_filter_transform - Winograd filter transform operator

Attributes

  • fmr - Single, WinogradConv2DFmr, allowed 32-bit signless integer cases: 0, 1, 2

Operands

  • filter - Single, anonymous/composite constraint, 4D tensor of any non-token type values
  • output - Single, anonymous/composite constraint, 4D tensor of any non-token type values

Results

  • result - Single, anonymous/composite constraint, 4D tensor of any non-token type values

Description

Winograd Conv2D algorithm will convert linalg Conv2D operator into batched matrix multiply. Before the matrix multiply, it will convert filter and input into a format suitable for batched matrix multiply. After the matrix multiply, it will convert output to the final result tensor.

The algorithm F(m x m, r x r) is

Y = A^T x [(G x g x G^T) @ (B^T x d x B)] x A

The size of output Y is m x m. The size of filter g is r x r. The size of input d is (m + r - 1) x (m + r - 1). A^T, A, G^T, G, B^T, and B are transformation matrices.

This operator is defined to represent the high level concept of filter transformation (G x g x G^T) in the Winograd Conv2D algorithm.

winograd_input_transform()

Return op name linalg.winograd_input_transform as a bitstring.

winograd_input_transform(ssa)

linalg.winograd_input_transform - Winograd input transform operator

Attributes

  • fmr - Single, WinogradConv2DFmr, allowed 32-bit signless integer cases: 0, 1, 2

Operands

  • input - Single, anonymous/composite constraint, 4D tensor of any non-token type values
  • output - Single, anonymous/composite constraint, 6D tensor of any non-token type values

Results

  • result - Single, anonymous/composite constraint, 6D tensor of any non-token type values

Description

Winograd Conv2D algorithm will convert linalg Conv2D operator into batched matrix multiply. Before the matrix multiply, it will convert filter and input into a format suitable for batched matrix multiply. After the matrix multiply, it will convert output to the final result tensor.

The algorithm F(m x m, r x r) is

Y = A^T x [(G x g x G^T) @ (B^T x d x B)] x A

The size of output Y is m x m. The size of filter g is r x r. The size of input d is (m + r - 1) x (m + r - 1). A^T, A, G^T, G, B^T, and B are transformation matrices.

This operator is defined to represent the high level concept of input transformation (B^T x d x B) in the Winograd Conv2D algorithm.

winograd_output_transform()

Return op name linalg.winograd_output_transform as a bitstring.

winograd_output_transform(ssa)

linalg.winograd_output_transform - Winograd output transform operator

Attributes

  • fmr - Single, WinogradConv2DFmr, allowed 32-bit signless integer cases: 0, 1, 2

Operands

  • value - Single, anonymous/composite constraint, 6D tensor of any non-token type values
  • output - Single, anonymous/composite constraint, 4D tensor of any non-token type values

Results

  • result - Single, anonymous/composite constraint, 4D tensor of any non-token type values

Description

Winograd Conv2D algorithm will convert linalg Conv2D operator into batched matrix multiply. Before the matrix multiply, it will convert filter and input into a format suitable for batched matrix multiply. After the matrix multiply, it will convert output to the final result tensor.

The algorithm F(m x m, r x r) is

Y = A^T x [(G x g x G^T) @ (B^T x d x B)] x A

The size of output Y is m x m. The size of filter g is r x r. The size of input d is (m + r - 1) x (m + r - 1). A^T, A, G^T, G, B^T, and B are transformation matrices.

This operator is defined to represent the high level concept of output transformation (A^T x y x A) in the Winograd Conv2D algorithm.

yield()

Return op name linalg.yield as a bitstring.

yield(ssa)

linalg.yield - Linalg yield operation

Operands

  • values - Variadic, AnyType, variadic of any non-token type

Description

linalg.yield is a special terminator operation for blocks inside regions in linalg generic ops. It returns values to the immediately enclosing linalg generic op.

Example:

linalg.yield %f0, %f1 : f32, f32