[all-commits] [llvm/llvm-project] 2bb252: [mlir] Add GlobalOp, GlobalLoadConstOp to ml_program.

Stella Laurenzo via All-commits all-commits at lists.llvm.org
Wed May 18 23:09:35 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2bb252852c72a4563fd7cd36604a1698c34d22a8
      https://github.com/llvm/llvm-project/commit/2bb252852c72a4563fd7cd36604a1698c34d22a8
  Author: Stella Laurenzo <stellaraccident at gmail.com>
  Date:   2022-05-18 (Wed, 18 May 2022)

  Changed paths:
    M mlir/include/mlir/Dialect/MLProgram/IR/CMakeLists.txt
    M mlir/include/mlir/Dialect/MLProgram/IR/MLProgram.h
    A mlir/include/mlir/Dialect/MLProgram/IR/MLProgramAttributes.h
    A mlir/include/mlir/Dialect/MLProgram/IR/MLProgramAttributes.td
    M mlir/include/mlir/Dialect/MLProgram/IR/MLProgramBase.td
    M mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td
    M mlir/lib/Dialect/MLProgram/IR/CMakeLists.txt
    M mlir/lib/Dialect/MLProgram/IR/MLProgramDialect.cpp
    M mlir/lib/Dialect/MLProgram/IR/MLProgramOps.cpp
    A mlir/test/Dialect/MLProgram/attrs.mlir
    M mlir/test/Dialect/MLProgram/invalid.mlir
    M mlir/test/Dialect/MLProgram/ops.mlir
    M utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

  Log Message:
  -----------
  [mlir] Add GlobalOp, GlobalLoadConstOp to ml_program.

The approach I took was to define a dialect 'extern' attribute that a GlobalOp can take as a value to signify external linkage. I think this approach should compose well and should also work with wherever the OpaqueElements work goes in the future (since that is just another kind of attribute). I special cased the GlobalOp parser/printer for this case because it is significantly easier on the eyes.

In the discussion, Jeff Niu had proposed an alternative syntax for GlobalOp that I ended up not taking. I did try to implement it but a) I don't think it made anything easier to read in the common case, and b) it made the parsing/printing logic a lot more complicated (I think I would need a completely custom parser/printer to do it well). Please have a look at the common cases where the global type and initial value type match: I don't think how I have it is too bad. The less common cases seem ok to me.

I chose to only implement the direct, constant load op since that is non side effecting and there was still discussion pending on that.

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


  Commit: 8b7e85f4f8403bd08e724178777df329aed6526e
      https://github.com/llvm/llvm-project/commit/8b7e85f4f8403bd08e724178777df329aed6526e
  Author: Stella Laurenzo <stellaraccident at gmail.com>
  Date:   2022-05-18 (Wed, 18 May 2022)

  Changed paths:
    M mlir/python/CMakeLists.txt
    A mlir/python/mlir/dialects/MLProgramOps.td
    A mlir/python/mlir/dialects/_ml_program_ops_ext.py
    A mlir/python/mlir/dialects/ml_program.py
    A mlir/test/python/dialects/ml_program.py
    M utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel

  Log Message:
  -----------
  [mlir][python] Add Python bindings for ml_program dialect.

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


Compare: https://github.com/llvm/llvm-project/compare/b21c03854cee...8b7e85f4f840


More information about the All-commits mailing list