[Mlir-commits] [mlir] [MLIR][Mesh] Add sharding propagation pass (PR #69665)
Mehdi Amini
llvmlistbot at llvm.org
Thu Oct 19 22:25:19 PDT 2023
================
@@ -0,0 +1,544 @@
+//===- ShardingInterface.cpp -------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Dialect/Mesh/Interfaces/ShardingInterface.h"
+#include "mlir/Dialect/Mesh/IR/MeshOps.h"
+#include "mlir/Dialect/Utils/IndexingUtils.h"
+#include "mlir/IR/AffineMap.h"
+#include "mlir/Support/LLVM.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/Support/Debug.h"
+
+#include <algorithm>
+#include <utility>
+
+#define DEBUG_TYPE "sharding-interface"
+#define DBGS() (llvm::dbgs() << "[" DEBUG_TYPE << "]: ")
+
+using namespace mlir;
+using namespace mlir::mesh;
+
+#include "mlir/Dialect/Mesh/Interfaces/ShardingInterface.cpp.inc"
+
+//===----------------------------------------------------------------------===//
+// common util functions
+//===----------------------------------------------------------------------===//
+
+static FailureOr<ShardingOption> getShardingOptionFromAttr(Operation *op) {
+ auto arrayAttr = op->getAttrOfType<ArrayAttr>(getShardingArrayName());
+ if (!arrayAttr)
+ return failure();
+ auto symbolRefAttr = op->getAttrOfType<SymbolRefAttr>(getMeshClusterName());
+ if (!symbolRefAttr)
+ return failure();
----------------
joker-eph wrote:
This should move directly behind an API, the `getAttr` method of Operation are intended to be deprecated (to use `getDiscardableAttr` /`getInherentAttr` instead) and implementer of this interface could put these in the Properties storage, and so the best way is to expose all these accessors through the `OpInterface`.
https://github.com/llvm/llvm-project/pull/69665
More information about the Mlir-commits
mailing list