summaryrefslogtreecommitdiff
path: root/mlir/docs/BytecodeFormat.md
AgeCommit message (Collapse)Author
2025-09-11[MLIR][Bytecode] Followup 8106c81 (#157136)Nikhil Kalra
Addressed code review feedback: - Fixed some issues in the unit test - Adjusted line wrapping in the docs - Clarified comments in the bytecode reader
2025-09-04[MLIR][Bytecode] Enforce alignment requirements (#157004)Nikhil Kalra
Adds a check that the bytecode buffer is aligned to any section alignment requirements. Without this check, if the source buffer is not sufficiently aligned, we may return early when aligning the data pointer. In that case, we may end up trying to read successive sections from an incorrect offset, giving the appearance of invalid bytecode. This requirement is documented in the bytecode unit tests, but is not otherwise documented in the code or bytecode reference.
2024-08-19[mlir][docs] Update Bytecode documentation (#99854)Matthias Springer
There were some discrepancies between the dialect section documentation and the implementation.
2024-02-16[MLIR] Document the stability and versioning aspect of the Bytecode (#81969)Mehdi Amini
See the two RFCs: https://discourse.llvm.org/t/rfc-mlir-bytecode-a-stable-serialization-format/71062 https://discourse.llvm.org/t/rfc-ir-versioning/5893
2023-05-25[mlir][bytecode] Avoid recording null arglocs & realloc opnames.Jacques Pienaar
For block arg locs a common case is no/uknown location (where the producer signifies they don't care about blockarg location). Also avoid needing to dynamically resize opnames during parsing. Assumed to be post lazy loading change, so chose version 3. Differential Revision: https://reviews.llvm.org/D151038
2023-05-21Preserve use-list orders in mlir bytecodeMatteo Franciolini
This patch implements a mechanism to read/write use-list orders from/to the mlir bytecode format. When producing bytecode, use-list orders are appended to each value of the IR. When reading bytecode, use-lists orders are loaded in memory and used at the end of parsing to sort the existing use-list chains. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D149755
2023-05-20Add support for Lazyloading to the MLIR bytecodeMehdi Amini
IsolatedRegions are emitted in sections in order for the reader to be able to skip over them. A new class is exposed to manage the state and allow the readers to load these IsolatedRegions on-demand. Differential Revision: https://reviews.llvm.org/D149515
2023-03-10Implements MLIR Bytecode versioning capabilityMatteo Franciolini
A dialect can opt-in to handle versioning through the `BytecodeDialectInterface`. Few hooks are exposed to the dialect to allow managing a version encoded into the bytecode file. The version is loaded lazily and allows to retrieve the version information while parsing the input IR, and gives an opportunity to each dialect for which a version is present to perform IR upgrades post-parsing through the `upgradeFromVersion` method. Custom Attribute and Type encodings can also be upgraded according to the dialect version using readAttribute and readType methods. There is no restriction on what kind of information a dialect is allowed to encode to model its versioning. Currently, versioning is supported only for bytecode formats. Reviewed By: rriddle, mehdi_amini Differential Revision: https://reviews.llvm.org/D143647
2022-10-07[mlir][doc] Remove trailing whitespace (NFC)Jacques Pienaar
2022-09-13[mlir:Bytecode] Add support for encoding resourcesRiver Riddle
Resources are encoded in two separate sections similarly to attributes/types, one for the actual data and one for the data offsets. Unlike other sections, the resource sections are optional given that in many cases they won't be present. For testing, bytecode serialization is added for DenseResourceElementsAttr. Differential Revision: https://reviews.llvm.org/D132729
2022-08-26[mlir:Bytecode] Add encoding support for a majority of the builtin attributesRiver Riddle
This adds support for the non-location, non-elements, non-affine builtin attributes. Differential Revision: https://reviews.llvm.org/D132539
2022-08-23[mlir:Bytecode] Add initial support for dialect defined attribute/type encodingsRiver Riddle
Dialects can opt-in to providing custom encodings by implementing the `BytecodeDialectInterface`. This interface provides hooks, namely `readAttribute`/`readType` and `writeAttribute`/`writeType`, that will be used by the bytecode reader and writer. These hooks are provided a reader and writer implementation that can be used to encode various constructs in the underlying bytecode format. A unique feature of this interface is that dialects may choose to only encode a subset of their attributes and types in a custom bytecode format, which can simplify adding new or experimental components that aren't fully baked. Differential Revision: https://reviews.llvm.org/D132498
2022-08-22[mlir] Add initial support for a binary serialization formatRiver Riddle
This commit adds a new bytecode serialization format for MLIR. The actual serialization of MLIR to binary is relatively straightforward, given the very very general structure of MLIR. The underlying basis for this format is a variable-length encoding for integers, which gets heavily used for nearly all aspects of the encoding (given that most of the encoding is just indexing into lists). The format currently does not provide support for custom attribute/type serialization, and thus always uses an assembly format fallback. It also doesn't provide support for resources. These will be added in followups, the intention for this patch is to provide something that supports the basic cases, and can be built on top of. https://discourse.llvm.org/t/rfc-a-binary-serialization-format-for-mlir/63518 Differential Revision: https://reviews.llvm.org/D131747