
This commit enables support for providing and processing external resources within MLIR assembly formats. This is a mechanism with which dialects, and external clients, may attach additional information when printing IR without that information being encoded in the IR itself. External resources are not uniqued within the MLIR context, are not attached directly to any operation, and are solely intended to live and be processed outside of the immediate IR. There are many potential uses of this functionality, for example MLIR's pass crash reproducer could utilize this to attach the pass resource executing when a crash occurs. Other types of uses may be embedding large amounts of binary data, such as weights in ML applications, that shouldn't be copied directly into the MLIR context, but need to be kept adjacent to the IR. External resources are encoded using a key-value pair nested within a dictionary anchored by name either on a dialect, or an externally registered entity. The key is an identifier used to disambiguate the data. The value may be stored in various limited forms, but general encodings use a string (human readable) or blob format (binary). Within the textual format, an example may be of the form: ```mlir {-# // The `dialect_resources` section within the file-level metadata // dictionary is used to contain any dialect resource entries. dialect_resources: { // Here is a dictionary anchored on "foo_dialect", which is a dialect // namespace. foo_dialect: { // `some_dialect_resource` is a key to be interpreted by the dialect, // and used to initialize/configure/etc. some_dialect_resource: "Some important resource value" } }, // The `external_resources` section within the file-level metadata // dictionary is used to contain any non-dialect resource entries. external_resources: { // Here is a dictionary anchored on "mlir_reproducer", which is an // external entity representing MLIR's crash reproducer functionality. mlir_reproducer: { // `pipeline` is an entry that holds a crash reproducer pipeline // resource. pipeline: "func.func(canonicalize,cse)" } } ``` Differential Revision: https://reviews.llvm.org/D126446
36 lines
1.0 KiB
C++
36 lines
1.0 KiB
C++
//===- TestTypes.h - MLIR Test Dialect Types --------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file contains types defined by the TestDialect for testing various
|
|
// features of MLIR.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef MLIR_TESTATTRIBUTES_H
|
|
#define MLIR_TESTATTRIBUTES_H
|
|
|
|
#include <tuple>
|
|
|
|
#include "TestTraits.h"
|
|
#include "mlir/IR/Attributes.h"
|
|
#include "mlir/IR/Diagnostics.h"
|
|
#include "mlir/IR/Dialect.h"
|
|
#include "mlir/IR/DialectImplementation.h"
|
|
|
|
#include "TestAttrInterfaces.h.inc"
|
|
#include "TestOpEnums.h.inc"
|
|
|
|
namespace test {
|
|
struct TestExternalElementsDataHandle;
|
|
} // namespace test
|
|
|
|
#define GET_ATTRDEF_CLASSES
|
|
#include "TestAttrDefs.h.inc"
|
|
|
|
#endif // MLIR_TESTATTRIBUTES_H
|