Lines Matching full:linalg
1 # 'linalg' Dialect
9 Linalg is designed to solve the High-level Hierarchical Optimization (HHO box)
19 Linalg. They are all implemented in terms of the properties of the
20 `linalg.generic` OpInterface and avoid the pitfall of relying on hardcoded
25 Linalg IR and that have influenced its design:
35 1. Partially Lower to Iterations Over a Finer-Grained Linalg Op.
37 ## High-Level Description of Linalg Ops<a name="linalg_ops"></a>
39 Linalg takes at least some inspiration from all previously
62 [Linalg and Shapes](https://llvm.discourse.group/t/linalg-and-shapes/2421)
67 Linalg defines a payload carrying operation that implements the
69 abstraction on tensors and buffers. This `linalg.generic` operation can express
71 iteration indices using the `linalg.index` operation). The properties of
72 `linalg.generic` are the result of applying the guiding principles described in
78 A `linalg.generic` op fully *derives* the specification of its iteration space
85 Consider the following fully specified `linalg.generic` example. Here, the first
104 linalg.generic #attrs
109 linalg.yield %c: vector<4xf32>
119 // Run: mlir-opt example1.mlir -allow-unregistered-dialect -convert-linalg-to-loops
156 about mixing different levels of abstractions in the same IR. As long as Linalg
169 A `linalg.generic` *defines* the mapping between the iteration space (i.e. the
172 Consider the following fully specified `linalg.generic` example. Here, the first
190 linalg.generic #attrs
195 linalg.yield %c: vector<4xf32>
205 // Run: mlir-opt example2.mlir -allow-unregistered-dialect -convert-linalg-to-loops
232 Answering these `2` questions is one of the main analyses that Linalg uses to
236 In the current implementation, `linalg.generic` uses a list of
244 A `linalg.generic` op fully *declares* the type of its iterators. This
263 Specifying the information declaratively in a `linalg.generic` allows conveying
275 At this time, Linalg only has an explicit use for *parallel* and *reduction*
280 A `linalg.generic` op has a compute payload that is fully generic thanks to the
285 operands of the `linalg.generic`. For flexibility and ability to match library
286 calls, additional special values may be passed. For instance, a `linalg.fill`
311 linalg.generic #attrs
316 linalg.yield %d : f32
355 A `linalg.generic` op may map to an external library call by specifying a
384 linalg.generic #attrs
389 linalg.yield %d : f32
399 // Run: mlir-opt example4.mlir -convert-linalg-to-std
417 // Run: mlir-opt example4.mlir -convert-linalg-to-std | mlir-opt -convert-func-to-llvm
436 The `linalg` dialect adopts a convention that is similar to `BLAS` when
443 Generally, `linalg` passes non-owning pointers to View data structures to
447 [ongoing discussion](https://llvm.discourse.group/t/lowering-optional-attributes-in-linalg-structuredops-to-standard-dialect/333/3)
456 challenging, or even infeasible. Linalg ops adopt perfect-nestedness as a
460 A `linalg.generic` op represents a perfectly nested loop nest that writes the
475 `linalg.generic` just forces the semantics for now.
478 undone once we are done with Linalg transformations. After iterators and
480 `linalg.generic` occurred), the overall performance will be greatly influenced
489 `linalg.generic` op. It is an open question whether all of these semantics are
503 abstraction. The name *View* is used interchangeably in `linalg` to signify
520 * `linalg.slice`,
521 * `linalg.reshape`,
527 * `linalg.tile`,
528 * `linalg.intersection`,
529 * `linalg.convex_union`,
530 * `linalg.difference` (would need to work on a list of views).
542 Additionally, `linalg` provides a small subset of commonly named operations:
545 * `linalg.fill`,
546 * `linalg.dot`,
547 * `linalg.matmul`,
548 * `linalg.conv`.
551 These named operations adhere to the `linalg.generic` op interface. Work is in
560 Linalg provides a declarative specification and a generation tool
561 (`mlir-linalg-ods-gen`) to automatically produce named ops from a notation that
564 The syntax and semantics used in `mlir-linalg-ods-gen` are very much in flight
566 better adapt to Linalg:
621 When `mlir-linalg-ods-gen -gen-ods-decl=1` is called, the following ODS is
631 When `mlir-linalg-ods-gen -gen-impl=1` is called, the following C++ is produced:
662 Linalg provides a declarative generation tool (`mlir-linalg-ods-yaml-gen`) to
670 `mlir-linalg-ods-yaml-gen.cpp` as the source of truth for the schema.
680 1. Should `linalg.generic` support nesting?
681 1. Should `linalg.generic` regions take views or only scalars?