mlir.dialects._affine_ops_gen¶
Attributes¶
Classes¶
The |
|
The |
|
Syntax: |
|
Syntax: |
|
The |
|
Syntax: |
|
The |
|
Syntax: |
|
The |
|
The |
|
Syntax: |
|
The |
|
The |
|
The |
Functions¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Module Contents¶
- mlir.dialects._affine_ops_gen._ods_ir¶
- class mlir.dialects._affine_ops_gen._Dialect(descriptor: object)¶
Bases:
_ods_ir- DIALECT_NAMESPACE = 'affine'¶
- class mlir.dialects._affine_ops_gen.AffineApplyOp(map, mapOperands, *, results=None, loc=None, ip=None)¶
Bases:
_ods_irThe
affine.applyoperation applies an affine mapping to a list of SSA values, yielding a single SSA value. The number of dimension and symbol operands toaffine.applymust be equal to the respective number of dimensional and symbolic inputs to the affine mapping; the affine mapping has to be one-dimensional, and so theaffine.applyoperation always returns one value. The input operands and result must all have ‘index’ type.An operand that is a valid dimension as per the rules on valid affine dimensions and symbols cannot be used as a symbolic operand.
Example:
#map = affine_map<(d0, d1) -> (d0 floordiv 8 + d1 floordiv 128)> ... %1 = affine.apply #map (%s, %t) // Inline example. %2 = affine.apply affine_map<(i)[s0] -> (i + s0)> (%42)[%n]
- OPERATION_NAME = 'affine.apply'¶
- _ODS_REGIONS = (0, True)¶
- mapOperands() _ods_ir¶
- map() _ods_ir¶
- mlir.dialects._affine_ops_gen.apply(map, map_operands, *, results=None, loc=None, ip=None) _ods_ir¶
- class mlir.dialects._affine_ops_gen.AffineDelinearizeIndexOp(multi_index, linear_index, dynamic_basis, static_basis, *, loc=None, ip=None)¶
Bases:
_ods_irThe
affine.delinearize_indexoperation takes a single index value and calculates the multi-index according to the given basis.Example:
%indices:3 = affine.delinearize_index %linear_index into (%c16, %c224, %c224) : index, index, index
In the above example,
%indices:3conceptually holds the following:#map0 = affine_map<()[s0] -> (s0 floordiv 50176)> #map1 = affine_map<()[s0] -> ((s0 mod 50176) floordiv 224)> #map2 = affine_map<()[s0] -> (s0 mod 224)> %indices_0 = affine.apply #map0()[%linear_index] %indices_1 = affine.apply #map1()[%linear_index] %indices_2 = affine.apply #map2()[%linear_index]
In other words,
%0:3 = affine.delinearize_index %x into (B, C)produces%0 = {%x / (B * C), (%x mod (B * C)) / C, %x mod C}.The basis may either contain
NorN-1elements, whereNis the number of results. If there are N basis elements, the first one will not be used during computations, but may be used during analysis and canonicalization to eliminate terms from theaffine.delinearize_indexor to enable conclusions about the total size of%linear_index.If the basis is fully provided, the delinearize_index operation is said to “have an outer bound”. The builders assume that an
affine.delinearize_indexhas an outer bound by default, as this is how the operation was initially defined.That is, the example above could also have been written
%0:3 = affine.delinearize_index %linear_index into (244, 244) : index, index
Note that, for symmetry with
getPaddedBasis(), ifhasOuterBoundistruewhen one of theOpFoldResultbuilders is called but the first element of the basis isnullptr, that first element is ignored and the builder proceeds as if there was no outer bound.Due to the constraints of affine maps, all the basis elements must be strictly positive. A dynamic basis element being 0 or negative causes undefined behavior.
As with other affine operations, lowerings of delinearize_index may assume that the underlying computations do not overflow the index type in a signed sense
that is, the product of all basis elements is positive as an
indexas well.
- OPERATION_NAME = 'affine.delinearize_index'¶
- _ODS_REGIONS = (0, True)¶
- linear_index() _ods_ir¶
- dynamic_basis() _ods_ir¶
- static_basis() _ods_ir¶
- multi_index() _ods_ir¶
- mlir.dialects._affine_ops_gen.delinearize_index(multi_index, linear_index, dynamic_basis, static_basis, *, loc=None, ip=None) _ods_ir | _ods_ir | AffineDelinearizeIndexOp¶
- class mlir.dialects._affine_ops_gen.AffineForOp(results_, lowerBoundOperands, upperBoundOperands, inits, lowerBoundMap, upperBoundMap, step, *, loc=None, ip=None)¶
Bases:
_ods_irSyntax:
operation ::= `affine.for` ssa-id `=` lower-bound `to` upper-bound (`step` integer-literal)? `{` op* `}` lower-bound ::= `max`? affine-map-attribute dim-and-symbol-use-list | shorthand-bound upper-bound ::= `min`? affine-map-attribute dim-and-symbol-use-list | shorthand-bound shorthand-bound ::= ssa-id | `-`? integer-literalThe
affine.foroperation represents an affine loop nest. It has one region containing its body. This region must contain one block that terminates with`affine.yield<#affineyield-mliraffineyieldop>`_. Note: whenaffine.foris printed in custom format, the terminator is omitted. The block has one argument of`index<Builtin.md/#indextype>`_ type that represents the induction variable of the loop.The
affine.foroperation executes its body a number of times iterating from a lower bound to an upper bound by a stride. The stride, represented bystep, is a positive constant integer which defaults to “1” if not present. The lower and upper bounds specify a half-open range: the range includes the lower bound but does not include the upper bound.The lower and upper bounds of a
affine.foroperation are represented as an application of an affine mapping to a list of SSA values passed to the map. The same restrictions hold for these SSA values as for all bindings of SSA values to dimensions and symbols.The affine mappings for the bounds may return multiple results, in which case the
max/minkeywords are required (for the lower/upper bound respectively), and the bound is the maximum/minimum of the returned values. There is no semantic ambiguity, but MLIR syntax requires the use of these keywords to make things more obvious to human readers.Many upper and lower bounds are simple, so MLIR accepts two custom form syntaxes: the form that accepts a single ‘ssa-id’ (e.g.
%N) is shorthand for applying that SSA value to a function that maps a single symbol to itself, e.g.,()[s]->(s)()[%N]. The integer literal form (e.g.-42) is shorthand for a nullary mapping function that returns the constant value (e.g.()->(-42)()).Example showing reverse iteration of the inner loop:
#map57 = affine_map<(d0)[s0] -> (s0 - d0 - 1)> func.func @simple_example(%A: memref<?x?xf32>, %B: memref<?x?xf32>) { %N = dim %A, 0 : memref<?x?xf32> affine.for %i = 0 to %N step 1 { affine.for %j = 0 to %N { // implicitly steps by 1 %0 = affine.apply #map57(%j)[%N] %tmp = call @F1(%A, %i, %0) : (memref<?x?xf32>, index, index)->(f32) call @F2(%tmp, %B, %i, %0) : (f32, memref<?x?xf32>, index, index)->() } } return }
affine.forcan also operate on loop-carried variables (iter_args) and return the final values after loop termination. The initial values of the variables are passed as additional SSA operands to theaffine.forfollowing the operands for the loop’s lower and upper bounds. The operation’s region has equivalent arguments for each variable representing the value of the variable at the current iteration.The region must terminate with an
affine.yieldthat passes all the current iteration variables to the next iteration, or to theaffine.for’s results if at the last iteration. Foraffine.for’s that execute zero iterations, the initial values of the loop-carried variables (corresponding to the SSA operands) will be the op’s results.For example, to sum-reduce a memref:
func.func @reduce(%buffer: memref<1024xf32>) -> (f32) { // Initial sum set to 0. %sum_0 = arith.constant 0.0 : f32 // iter_args binds initial values to the loop's region arguments. %sum = affine.for %i = 0 to 10 step 2 iter_args(%sum_iter = %sum_0) -> (f32) { %t = affine.load %buffer[%i] : memref<1024xf32> %sum_next = arith.addf %sum_iter, %t : f32 // Yield current iteration sum to next iteration %sum_iter or to %sum // if final iteration. affine.yield %sum_next : f32 } return %sum : f32 }
%res:2 = affine.for %i = 0 to 128 iter_args(%arg0 = %init0, %arg1 = %init1) -> (index, index) { %y0 = arith.addi %arg0, %c1 : index %y1 = arith.addi %arg1, %c2 : index affine.yield %y0, %y1 : index, index }
If the
affine.fordefines any values, a yield terminator must be explicitly present. The number and types of the “affine.for” results must match the initial values in theiter_argsbinding and the yield operands.- OPERATION_NAME = 'affine.for'¶
- _ODS_OPERAND_SEGMENTS¶
- _ODS_REGIONS = (1, True)¶
- lowerBoundOperands() _ods_ir¶
- upperBoundOperands() _ods_ir¶
- inits() _ods_ir¶
- lowerBoundMap() _ods_ir¶
- upperBoundMap() _ods_ir¶
- step() _ods_ir¶
- results_() _ods_ir¶
- region() _ods_ir¶
- mlir.dialects._affine_ops_gen.for_(results_, lower_bound_operands, upper_bound_operands, inits, lower_bound_map, upper_bound_map, step, *, loc=None, ip=None) _ods_ir | _ods_ir | AffineForOp¶
- class mlir.dialects._affine_ops_gen.AffineIfOp(results_, _gen_arg_0, condition, *, loc=None, ip=None)¶
Bases:
_ods_irSyntax:
operation ::= `affine.if` if-op-cond `{` op* `}` (`else` `{` op* `}`)? if-op-cond ::= integer-set-attr dim-and-symbol-use-listThe
affine.ifoperation restricts execution to a subset of the loop iteration space defined by an integer set (a conjunction of affine constraints). A singleaffine.ifmay end with an optionalelseclause.The condition of the
affine.ifis represented by an integer set (a conjunction of affine constraints), and the SSA values bound to the dimensions and symbols in the integer set. The same restrictions hold for these SSA values as for all bindings of SSA values to dimensions and symbols.The
affine.ifoperation contains two regions for the “then” and “else” clauses.affine.ifmay return results that are defined in its regions. The values defined are determined by which execution path is taken. Each region of theaffine.ifmust contain a single block with no arguments, and be terminated byaffine.yield. Ifaffine.ifdefines no values, theaffine.yieldcan be left out, and will be inserted implicitly. Otherwise, it must be explicit. If no values are defined, the else block may be empty (i.e. contain no blocks).Example:
#set = affine_set<(d0, d1)[s0]: (d0 - 10 >= 0, s0 - d0 - 9 >= 0, d1 - 10 >= 0, s0 - d1 - 9 >= 0)> func.func @reduced_domain_example(%A, %X, %N) : (memref<10xi32>, i32, i32) { affine.for %i = 0 to %N { affine.for %j = 0 to %N { %0 = affine.apply #map42(%j) %tmp = call @S1(%X, %i, %0) affine.if #set(%i, %j)[%N] { %1 = affine.apply #map43(%i, %j) call @S2(%tmp, %A, %i, %1) } } } return }
Example with an explicit yield (initialization with edge padding):
#interior = affine_set<(i, j) : (i - 1 >= 0, j - 1 >= 0, 10 - i >= 0, 10 - j >= 0)> (%i, %j) func.func @pad_edges(%I : memref<10x10xf32>) -> (memref<12x12xf32) { %O = alloc memref<12x12xf32> affine.parallel (%i, %j) = (0, 0) to (12, 12) { %1 = affine.if #interior (%i, %j) { %2 = load %I[%i - 1, %j - 1] : memref<10x10xf32> affine.yield %2 } else { %2 = arith.constant 0.0 : f32 affine.yield %2 : f32 } affine.store %1, %O[%i, %j] : memref<12x12xf32> } return %O }
- OPERATION_NAME = 'affine.if'¶
- _ODS_REGIONS = (2, True)¶
- condition() _ods_ir¶
- results_() _ods_ir¶
- thenRegion() _ods_ir¶
- elseRegion() _ods_ir¶
- mlir.dialects._affine_ops_gen.if_(results_, _gen_arg_0, condition, *, loc=None, ip=None) _ods_ir | _ods_ir | AffineIfOp¶
- class mlir.dialects._affine_ops_gen.AffineLinearizeIndexOp(multi_index, dynamic_basis, static_basis, disjoint, *, results=None, loc=None, ip=None)¶
Bases:
_ods_irThe
affine.linearize_indexoperation takes a sequence of index values and a basis of the same length and linearizes the indices using that basis.That is, for indices
%idx_0to%idx_{N-1}and basis elementsb_0(orb_1) up tob_{N-1}it computessum(i = 0 to N-1) %idx_i * product(j = i + 1 to N-1) B_j
In other words,
%0 = affine.linearize_index [%z, %y, %x] by (Z, Y, X)gives%0 = %x + %y * X + %z * X * Y, or%0 = %x + X * (%y + Y * (%z)).The basis may either have
NorN-1elements, whereNis the number of inputs to linearize_index. IfNinputs are provided, the first one is not used in computation, but may be used during analysis or canonicalization as a bound on%idx_0.If all
Nbasis elements are provided, the linearize_index operation is said to “have an outer bound”.As a convenience, and for symmetry with
getPaddedBasis(), if the first element of a set ofOpFoldResult``s passed to the builders of this operation is ``nullptr, that element is ignored.If the
disjointproperty is present, this is an optimization hint that, for alli,0 <= %idx_i < B_i- that is, no index affects any other index, except that%idx_0may be negative to make the index as a whole negative. In addition,disjointis an assertion that all bases elements are non-negative.Note that the outputs of
affine.delinearize_indexare, by definition,disjoint.As with other affine ops, undefined behavior occurs if the linearization computation overflows in the signed sense.
Example:
%linear_index = affine.linearize_index [%index_0, %index_1, %index_2] by (2, 3, 5) : index // Same effect %linear_index = affine.linearize_index [%index_0, %index_1, %index_2] by (3, 5) : index
In the above example,
%linear_indexconceptually holds the following:#map = affine_map<()[s0, s1, s2] -> (s0 * 15 + s1 * 5 + s2)> %linear_index = affine.apply #map()[%index_0, %index_1, %index_2]
- OPERATION_NAME = 'affine.linearize_index'¶
- _ODS_OPERAND_SEGMENTS¶
- _ODS_REGIONS = (0, True)¶
- multi_index() _ods_ir¶
- dynamic_basis() _ods_ir¶
- static_basis() _ods_ir¶
- linear_index() _ods_ir¶
- mlir.dialects._affine_ops_gen.linearize_index(multi_index, dynamic_basis, static_basis, disjoint, *, results=None, loc=None, ip=None) _ods_ir¶
- class mlir.dialects._affine_ops_gen.AffineLoadOp(result, memref, indices, map, *, loc=None, ip=None)¶
Bases:
_ods_irSyntax:
operation ::= ssa-id `=` `affine.load` ssa-use `[` multi-dim-affine-map-of-ssa-ids `]` `:` memref-type
The
affine.loadop reads an element from a memref, where the index for each memref dimension is an affine expression of loop induction variables and symbols. The output ofaffine.loadis a new value with the same type as the elements of the memref. An affine expression of loop IVs and symbols must be specified for each dimension of the memref. The keywordsymbolcan be used to indicate SSA identifiers which are symbolic.Example 1:
%1 = affine.load %0[%i0 + 3, %i1 + 7] : memref<100x100xf32>
Example 2: Uses
symbolkeyword for symbols%nand%m.%1 = affine.load %0[%i0 + symbol(%n), %i1 + symbol(%m)] : memref<100x100xf32>
- OPERATION_NAME = 'affine.load'¶
- _ODS_REGIONS = (0, True)¶
- memref() _ods_ir¶
- indices() _ods_ir¶
- map() _ods_ir¶
- result() _ods_ir¶
Shortcut to get an op result if it has only one (throws an error otherwise).
- mlir.dialects._affine_ops_gen.load(result, memref, indices, map, *, loc=None, ip=None) _ods_ir¶
- class mlir.dialects._affine_ops_gen.AffineMaxOp(map, operands_, *, results=None, loc=None, ip=None)¶
Bases:
_ods_irThe
affine.maxoperation computes the maximum value result from a multi-result affine map.Example:
%0 = affine.max (d0) -> (1000, d0 + 512) (%i0) : index
- OPERATION_NAME = 'affine.max'¶
- _ODS_REGIONS = (0, True)¶
- operands_() _ods_ir¶
- map() _ods_ir¶
- mlir.dialects._affine_ops_gen.max(map, operands_, *, results=None, loc=None, ip=None) _ods_ir¶
- class mlir.dialects._affine_ops_gen.AffineMinOp(map, operands_, *, results=None, loc=None, ip=None)¶
Bases:
_ods_irSyntax:
operation ::= ssa-id `=` `affine.min` affine-map-attribute dim-and-symbol-use-list
The
affine.minoperation applies an affine mapping to a list of SSA values, and returns the minimum value of all result expressions. The number of dimension and symbol arguments toaffine.minmust be equal to the respective number of dimensional and symbolic inputs to the affine mapping; theaffine.minoperation always returns one value. The input operands and result must all have ‘index’ type.Example:
%0 = affine.min affine_map<(d0)[s0] -> (1000, d0 + 512, s0)> (%arg0)[%arg1]
- OPERATION_NAME = 'affine.min'¶
- _ODS_REGIONS = (0, True)¶
- operands_() _ods_ir¶
- map() _ods_ir¶
- mlir.dialects._affine_ops_gen.min(map, operands_, *, results=None, loc=None, ip=None) _ods_ir¶
- class mlir.dialects._affine_ops_gen.AffineParallelOp(results_, reductions, lowerBoundsMap, lowerBoundsGroups, upperBoundsMap, upperBoundsGroups, steps, mapOperands, *, loc=None, ip=None)¶
Bases:
_ods_irThe
affine.paralleloperation represents a hyper-rectangular affine parallel band, defining zero or more SSA values for its induction variables. It has one region capturing the parallel band body. The induction variables are represented as arguments of this region. These SSA values always have type index, which is the size of the machine word. The strides, represented by steps, are positive constant integers which defaults to “1” if not present. The lower and upper bounds specify a half-open range: the range includes the lower bound but does not include the upper bound. The body region must contain exactly one block that terminates withaffine.yield.The lower and upper bounds of a parallel operation are represented as an application of an affine mapping to a list of SSA values passed to the map. The same restrictions hold for these SSA values as for all bindings of SSA values to dimensions and symbols. The list of expressions in each map is interpreted according to the respective bounds group attribute. If a single expression belongs to the group, then the result of this expression is taken as a lower(upper) bound of the corresponding loop induction variable. If multiple expressions belong to the group, then the lower(upper) bound is the max(min) of these values obtained from these expressions. The loop band has as many loops as elements in the group bounds attributes.
Each value yielded by
affine.yieldwill be accumulated/reduced via one of the reduction methods defined in the AtomicRMWKind enum. The order of reduction is unspecified, and lowering may produce any valid ordering. Loops with a 0 trip count will produce as a result the identity value associated with each reduction (i.e. 0.0 for addf, 1.0 for mulf). Assign reductions for loops with a trip count != 1 produces undefined results.Note: Calling
AffineParallelOp::buildwill create the required region and block, and insert the required terminator if it is trivial (i.e. no values are yielded). Parsing will also create the required region, block, and terminator, even when they are missing from the textual representation.Example (3x3 valid convolution):
func.func @conv_2d(%D : memref<100x100xf32>, %K : memref<3x3xf32>) -> (memref<98x98xf32>) { %O = memref.alloc() : memref<98x98xf32> affine.parallel (%x, %y) = (0, 0) to (98, 98) { %0 = affine.parallel (%kx, %ky) = (0, 0) to (2, 2) reduce ("addf") -> f32 { %1 = affine.load %D[%x + %kx, %y + %ky] : memref<100x100xf32> %2 = affine.load %K[%kx, %ky] : memref<3x3xf32> %3 = arith.mulf %1, %2 : f32 affine.yield %3 : f32 } affine.store %0, %O[%x, %y] : memref<98x98xf32> } return %O : memref<98x98xf32> }
Example (tiling by potentially imperfectly dividing sizes):
affine.parallel (%ii, %jj) = (0, 0) to (%N, %M) step (32, 32) { affine.parallel (%i, %j) = (%ii, %jj) to (min(%ii + 32, %N), min(%jj + 32, %M)) { call @f(%i, %j) : (index, index) -> () } }
- OPERATION_NAME = 'affine.parallel'¶
- _ODS_REGIONS = (1, True)¶
- mapOperands() _ods_ir¶
- reductions() _ods_ir¶
- lowerBoundsMap() _ods_ir¶
- lowerBoundsGroups() _ods_ir¶
- upperBoundsMap() _ods_ir¶
- upperBoundsGroups() _ods_ir¶
- steps() _ods_ir¶
- results_() _ods_ir¶
- region() _ods_ir¶
- mlir.dialects._affine_ops_gen.parallel(results_, reductions, lower_bounds_map, lower_bounds_groups, upper_bounds_map, upper_bounds_groups, steps, map_operands, *, loc=None, ip=None) _ods_ir | _ods_ir | AffineParallelOp¶
- class mlir.dialects._affine_ops_gen.AffinePrefetchOp(memref, indices, isWrite, localityHint, isDataCache, map, *, loc=None, ip=None)¶
Bases:
_ods_irThe
affine.prefetchop prefetches data from a memref location described with an affine subscript similar to affine.load, and has three attributes: a read/write specifier, a locality hint, and a cache type specifier as shown below:affine.prefetch %0[%i, %j + 5], read, locality<3>, data : memref<400x400xi32>
The read/write specifier is either ‘read’ or ‘write’, the locality hint specifier ranges from locality<0> (no locality) to locality<3> (extremely local keep in cache). The cache type specifier is either ‘data’ or ‘instr’ and specifies whether the prefetch is performed on data cache or on instruction cache.
- OPERATION_NAME = 'affine.prefetch'¶
- _ODS_REGIONS = (0, True)¶
- memref() _ods_ir¶
- indices() _ods_ir¶
- isWrite() _ods_ir¶
- localityHint() _ods_ir¶
- isDataCache() _ods_ir¶
- map() _ods_ir¶
- mlir.dialects._affine_ops_gen.prefetch(memref, indices, is_write, locality_hint, is_data_cache, map, *, loc=None, ip=None) AffinePrefetchOp¶
- class mlir.dialects._affine_ops_gen.AffineStoreOp(value, memref, indices, map, *, loc=None, ip=None)¶
Bases:
_ods_irSyntax:
operation ::= `affine.store` ssa-use, ssa-use `[` multi-dim-affine-map-of-ssa-ids `]` `:` memref-type
The
affine.storeop writes an element to a memref, where the index for each memref dimension is an affine expression of loop induction variables and symbols. Theaffine.storeop stores a new value which is the same type as the elements of the memref. An affine expression of loop IVs and symbols must be specified for each dimension of the memref. The keywordsymbolcan be used to indicate SSA identifiers which are symbolic.Example 1:
affine.store %v0, %0[%i0 + 3, %i1 + 7] : memref<100x100xf32>
Example 2: Uses
symbolkeyword for symbols%nand%m.affine.store %v0, %0[%i0 + symbol(%n), %i1 + symbol(%m)] : memref<100x100xf32>
- OPERATION_NAME = 'affine.store'¶
- _ODS_REGIONS = (0, True)¶
- value() _ods_ir¶
- memref() _ods_ir¶
- indices() _ods_ir¶
- map() _ods_ir¶
- mlir.dialects._affine_ops_gen.store(value, memref, indices, map, *, loc=None, ip=None) AffineStoreOp¶
- class mlir.dialects._affine_ops_gen.AffineVectorLoadOp(result, memref, indices, map, *, loc=None, ip=None)¶
Bases:
_ods_irThe
affine.vector_loadis the vector counterpart of affine.load. It reads a slice from a MemRef, supplied as its first operand, into a vector of the same base elemental type. The index for each memref dimension is an affine expression of loop induction variables and symbols. These indices determine the start position of the read within the memref. The shape of the return vector type determines the shape of the slice read from the memref. This slice is contiguous along the respective dimensions of the shape. Strided vector loads will be supported in the future. An affine expression of loop IVs and symbols must be specified for each dimension of the memref. The keywordsymbolcan be used to indicate SSA identifiers which are symbolic.Example 1: 8-wide f32 vector load.
%1 = affine.vector_load %0[%i0 + 3, %i1 + 7] : memref<100x100xf32>, vector<8xf32>
Example 2: 4-wide f32 vector load. Uses
symbolkeyword for symbols%nand%m.%1 = affine.vector_load %0[%i0 + symbol(%n), %i1 + symbol(%m)] : memref<100x100xf32>, vector<4xf32>
Example 3: 2-dim f32 vector load.
%1 = affine.vector_load %0[%i0, %i1] : memref<100x100xf32>, vector<2x8xf32>
TODOs:
Add support for strided vector loads.
Consider adding a permutation map to permute the slice that is read from memory
(see vector.transfer_read).
- OPERATION_NAME = 'affine.vector_load'¶
- _ODS_REGIONS = (0, True)¶
- memref() _ods_ir¶
- indices() _ods_ir¶
- map() _ods_ir¶
- result() _ods_ir¶
Shortcut to get an op result if it has only one (throws an error otherwise).
- mlir.dialects._affine_ops_gen.vector_load(result, memref, indices, map, *, loc=None, ip=None) _ods_ir¶
- class mlir.dialects._affine_ops_gen.AffineVectorStoreOp(value, memref, indices, map, *, loc=None, ip=None)¶
Bases:
_ods_irThe
affine.vector_storeis the vector counterpart of affine.store. It writes a vector, supplied as its first operand, into a slice within a MemRef of the same base elemental type, supplied as its second operand. The index for each memref dimension is an affine expression of loop induction variables and symbols. These indices determine the start position of the write within the memref. The shape of the input vector determines the shape of the slice written to the memref. This slice is contiguous along the respective dimensions of the shape. Strided vector stores will be supported in the future. An affine expression of loop IVs and symbols must be specified for each dimension of the memref. The keywordsymbolcan be used to indicate SSA identifiers which are symbolic.Example 1: 8-wide f32 vector store.
affine.vector_store %v0, %0[%i0 + 3, %i1 + 7] : memref<100x100xf32>, vector<8xf32>
Example 2: 4-wide f32 vector store. Uses
symbolkeyword for symbols%nand%m.affine.vector_store %v0, %0[%i0 + symbol(%n), %i1 + symbol(%m)] : memref<100x100xf32>, vector<4xf32>
Example 3: 2-dim f32 vector store.
affine.vector_store %v0, %0[%i0, %i1] : memref<100x100xf32>, vector<2x8xf32>
TODOs:
Add support for strided vector stores.
Consider adding a permutation map to permute the slice that is written to memory
(see vector.transfer_write).
- OPERATION_NAME = 'affine.vector_store'¶
- _ODS_REGIONS = (0, True)¶
- value() _ods_ir¶
- memref() _ods_ir¶
- indices() _ods_ir¶
- map() _ods_ir¶
- mlir.dialects._affine_ops_gen.vector_store(value, memref, indices, map, *, loc=None, ip=None) AffineVectorStoreOp¶
- class mlir.dialects._affine_ops_gen.AffineYieldOp(operands_, *, loc=None, ip=None)¶
Bases:
_ods_irThe
affine.yieldyields zero or more SSA values from an affine op region and terminates the region. The semantics of how the values yielded are used is defined by the parent operation. Ifaffine.yieldhas any operands, the operands must match the parent operation’s results. If the parent operation defines no values, then theaffine.yieldmay be left out in the custom syntax and the builders will insert one implicitly. Otherwise, it has to be present in the syntax to indicate which values are yielded.- OPERATION_NAME = 'affine.yield'¶
- _ODS_REGIONS = (0, True)¶
- operands_() _ods_ir¶
- mlir.dialects._affine_ops_gen.yield_(operands_, *, loc=None, ip=None) AffineYieldOp¶