[all-commits] [llvm/llvm-project] 5f58e1: [mlir] Add a generic DialectResourceBlobManager to...

River Riddle via All-commits all-commits at lists.llvm.org
Mon Aug 1 12:50:20 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5f58e14b36edbdacef86a2f3fc192b5720b2ba62
      https://github.com/llvm/llvm-project/commit/5f58e14b36edbdacef86a2f3fc192b5720b2ba62
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2022-08-01 (Mon, 01 Aug 2022)

  Changed paths:
    M mlir/include/mlir/IR/AsmState.h
    M mlir/include/mlir/IR/Dialect.h
    A mlir/include/mlir/IR/DialectResourceBlobManager.h
    M mlir/lib/IR/CMakeLists.txt
    A mlir/lib/IR/DialectResourceBlobManager.cpp
    M mlir/test/lib/Dialect/Test/TestAttrDefs.td
    M mlir/test/lib/Dialect/Test/TestAttributes.cpp
    M mlir/test/lib/Dialect/Test/TestAttributes.h
    M mlir/test/lib/Dialect/Test/TestDialect.cpp
    M mlir/test/lib/Dialect/Test/TestDialect.h
    M mlir/test/lib/Dialect/Test/TestDialect.td

  Log Message:
  -----------
  [mlir] Add a generic DialectResourceBlobManager to simplify resource blob management

The DialectResourceBlobManager class provides functionality for managing resource blobs
in a generic, dialect-agnostic fashion. In addition to this class, a dialect interface and custom
resource handle are provided to simplify referencing and interacting with the manager. These
classes intend to simplify the work required for dialects that want to manage resource blobs
during compilation, such as for large elements attrs.  The old manager for the resource example
in the test dialect has been updated to use this, which provides and cleaner and more consistent API.

This commit also adds new HeapAsmResourceBlob and ImmortalAsmResourceBlob to simplify
creating resource blobs in common scenarios.

Differential Revision: https://reviews.llvm.org/D130021


  Commit: 995ab92964d667123efd90d1f8016602c4a9df01
      https://github.com/llvm/llvm-project/commit/995ab92964d667123efd90d1f8016602c4a9df01
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2022-08-01 (Mon, 01 Aug 2022)

  Changed paths:
    M mlir/include/mlir/IR/BuiltinAttributes.h
    M mlir/include/mlir/IR/BuiltinAttributes.td
    M mlir/include/mlir/IR/OpImplementation.h
    M mlir/lib/AsmParser/AsmParserImpl.h
    M mlir/lib/AsmParser/AttributeParser.cpp
    M mlir/lib/AsmParser/Parser.cpp
    M mlir/lib/AsmParser/Parser.h
    M mlir/lib/AsmParser/TokenKinds.def
    M mlir/lib/IR/AsmPrinter.cpp
    M mlir/lib/IR/BuiltinAttributes.cpp
    M mlir/lib/IR/BuiltinDialect.cpp
    M mlir/lib/IR/DialectResourceBlobManager.cpp
    M mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
    A mlir/test/IR/dense-resource-elements-attr.mlir
    M mlir/test/IR/invalid-builtin-attributes.mlir
    M mlir/test/IR/invalid-file-metadata.mlir
    M mlir/unittests/IR/AttributeTest.cpp

  Log Message:
  -----------
  [mlir] Add a new builtin DenseResourceElementsAttr

This attributes is intended cover the current set of use cases that abuse
DenseElementsAttr, e.g. when the data is large. Using resources for large
data is one of the major reasons why they were added; e.g. they can be
deallocated mid-compilation, they support a wide variety of data origins
(e.g, heap allocated, mmap'd, etc.), they can support mutation, etc.

I considered at length not having a builtin variant of this, and instead
having multiple versions of this attribute for dialects that are interested,
but they all boiled down to the exact same attribute definition. Given the
generality of this attribute, it feels more aligned to keep it next to DenseArrayAttr
(given that DenseArrayAttr covers the "small" case, and DenseResourcesElementsAttr
covers the "large" case). The underlying infra used to build this attribute is
general, and having a builtin attribute doesn't preclude users from defining
their own when it makes sense (they can even share a blob manager with the
builtin dialect to avoid data duplication).

Differential Revision: https://reviews.llvm.org/D130022


Compare: https://github.com/llvm/llvm-project/compare/938fe9f277c6...995ab92964d6


More information about the All-commits mailing list