diff options
| author | Alex Zinenko <zinenko@google.com> | 2024-01-04 09:45:30 +0000 |
|---|---|---|
| committer | Alex Zinenko <zinenko@google.com> | 2024-01-04 09:49:34 +0000 |
| commit | 985bb3a20a788b3cda3256084fbdef20296ba8cb (patch) | |
| tree | 494996a17f5e4e278a25422f74bc6c8648be3636 /mlir/lib/Bytecode | |
| parent | 26993f61673e3d9b29785f9baa5bac50c09f8bcf (diff) | |
[mlir] fix bytecode writer after c1eab57673ef3eb28
The change in c1eab57 fixed the
behavior of `getDiscardableAttrDictionary` for ops that are not using
properties to only return discardable attributes. Bytecode writer was
relying on the wrong behavior and would assume all attributes are
discardable, without appropriate testing. Fix that and add a test.
Diffstat (limited to 'mlir/lib/Bytecode')
| -rw-r--r-- | mlir/lib/Bytecode/Writer/BytecodeWriter.cpp | 7 | ||||
| -rw-r--r-- | mlir/lib/Bytecode/Writer/IRNumbering.cpp | 7 |
2 files changed, 9 insertions, 5 deletions
diff --git a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp index 6097f0eda469..9493a6c19a10 100644 --- a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp +++ b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp @@ -962,9 +962,12 @@ LogicalResult BytecodeWriter::writeOp(EncodingEmitter &emitter, Operation *op) { DictionaryAttr attrs = op->getDiscardableAttrDictionary(); // Allow deployment to version <kNativePropertiesEncoding by merging inherent // attribute with the discardable ones. We should fail if there are any - // conflicts. - if (config.bytecodeVersion < bytecode::kNativePropertiesEncoding) + // conflicts. When properties are not used by the op, also store everything as + // attributes. + if (config.bytecodeVersion < bytecode::kNativePropertiesEncoding || + !op->getPropertiesStorage()) { attrs = op->getAttrDictionary(); + } if (!attrs.empty()) { opEncodingMask |= bytecode::OpEncodingMask::kHasAttrs; emitter.emitVarInt(numberingState.getNumber(attrs)); diff --git a/mlir/lib/Bytecode/Writer/IRNumbering.cpp b/mlir/lib/Bytecode/Writer/IRNumbering.cpp index 036a9477cce6..a306010698f2 100644 --- a/mlir/lib/Bytecode/Writer/IRNumbering.cpp +++ b/mlir/lib/Bytecode/Writer/IRNumbering.cpp @@ -425,9 +425,10 @@ void IRNumberingState::number(Operation &op) { // Only number the operation's dictionary if it isn't empty. DictionaryAttr dictAttr = op.getDiscardableAttrDictionary(); - // Prior to version 5 we need to number also the merged dictionnary - // containing both the inherent and discardable attribute. - if (config.getDesiredBytecodeVersion() < 5) + // Prior to version 5, or when properties are not used, we need to number also + // the merged dictionary containing both the inherent and discardable + // attribute. + if (config.getDesiredBytecodeVersion() < 5 || !op.getPropertiesStorage()) dictAttr = op.getAttrDictionary(); if (!dictAttr.empty()) number(dictAttr); |
