[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
15 lines
693 B
MLIR
15 lines
693 B
MLIR
// RUN: mlir-opt %s -split-input-file --test-bytecode-callback="callback-test=3" | FileCheck %s --check-prefix=TEST_3
|
|
// RUN: mlir-opt %s -split-input-file --test-bytecode-callback="callback-test=4" | FileCheck %s --check-prefix=TEST_4
|
|
|
|
"test.versionedC"() <{attribute = #test.attr_params<42, 24>}> : () -> ()
|
|
|
|
// TEST_3: Overriding TestAttrParamsAttr encoding...
|
|
// TEST_3: "test.versionedC"() <{attribute = dense<[42, 24]> : tensor<2xi32>}> : () -> ()
|
|
|
|
// -----
|
|
|
|
"test.versionedC"() <{attribute = dense<[42, 24]> : tensor<2xi32>}> : () -> ()
|
|
|
|
// TEST_4: Overriding parsing of TestAttrParamsAttr encoding...
|
|
// TEST_4: "test.versionedC"() <{attribute = #test.attr_params<42, 24>}> : () -> ()
|