Files
clang-p2996/mlir/test/Bytecode/bytecode_callback_full_override.mlir
Matteo Franciolini bff6a4292f Expose callbacks for encoding of types/attributes
[mlir] Expose a mechanism to provide a callback for encoding types and attributes in MLIR bytecode.

Two callbacks are exposed, respectively, to the BytecodeWriterConfig and to the ParserConfig. At bytecode parsing/printing, clients have the ability to specify a callback to be used to optionally read/write the encoding. On failure, fallback path will execute the default parsers and printers for the dialect.

Testing shows how to leverage this functionality to support back-deployment and backward-compatibility usecases when roundtripping to bytecode a client dialect with type/attributes dependencies on upstream.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D153383
2023-07-28 16:45:42 -07:00

19 lines
577 B
MLIR

// RUN: not mlir-opt %s -split-input-file --test-bytecode-callback="callback-test=5" 2>&1 | FileCheck %s
// CHECK-NOT: failed to read bytecode
func.func @base_test(%arg0 : i32) -> f32 {
%0 = "test.addi"(%arg0, %arg0) : (i32, i32) -> i32
%1 = "test.cast"(%0) : (i32) -> f32
return %1 : f32
}
// -----
// CHECK-LABEL: error: unknown attribute code: 99
// CHECK: failed to read bytecode
func.func @base_test(%arg0 : !test.i32) -> f32 {
%0 = "test.addi"(%arg0, %arg0) : (!test.i32, !test.i32) -> !test.i32
%1 = "test.cast"(%0) : (!test.i32) -> f32
return %1 : f32
}