From db9eef4cadcc9a072f48820e123f24c743cbe26e Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" <gardener@tensorflow.org> Date: Thu, 30 Apr 2020 04:50:47 -0700 Subject: [PATCH] Integrate LLVM at https://github.com/llvm/llvm-project/commit/52eb2f65a7d2 PiperOrigin-RevId: 309203365 Change-Id: Idfec7bc2323705f0c3384fae8f1260849bc212b3 --- tensorflow/compiler/mlir/lite/flatbuffer_export.cc | 4 ++-- .../mlir/tensorflow/transforms/tpu_cluster_formation.cc | 5 +++-- .../compiler/mlir/tensorflow/translate/breakup-islands.cc | 2 +- .../tensorflow/translate/control_to_executor_dialect.cc | 8 ++++---- .../tensorflow/translate/executor_to_control_dialect.cc | 4 ++-- .../mlir/xla/transforms/xla_hlo_to_lhlo_with_xla.cc | 2 +- third_party/mlir/BUILD | 1 + 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tensorflow/compiler/mlir/lite/flatbuffer_export.cc b/tensorflow/compiler/mlir/lite/flatbuffer_export.cc index 94db5400fba..e9192388070 100644 --- a/tensorflow/compiler/mlir/lite/flatbuffer_export.cc +++ b/tensorflow/compiler/mlir/lite/flatbuffer_export.cc @@ -1017,10 +1017,10 @@ Optional<BufferOffset<tflite::Operator>> Translator::BuildOperator( inst->getName().print(os); // Print out attributes except for large elementsattributes (which should // rarely be the cause why the legalization didn't happen). - if (!inst->getAttrList().getAttrs().empty()) { + if (!inst->getMutableAttrDict().getAttrs().empty()) { os << " {"; bool first = true; - for (auto& named_attr : inst->getAttrList().getDictionary()) { + for (auto& named_attr : inst->getMutableAttrDict().getDictionary()) { os << (!first ? ", " : ""); first = false; named_attr.first.print(os); diff --git a/tensorflow/compiler/mlir/tensorflow/transforms/tpu_cluster_formation.cc b/tensorflow/compiler/mlir/tensorflow/transforms/tpu_cluster_formation.cc index 860d537c7ef..0571701413a 100644 --- a/tensorflow/compiler/mlir/tensorflow/transforms/tpu_cluster_formation.cc +++ b/tensorflow/compiler/mlir/tensorflow/transforms/tpu_cluster_formation.cc @@ -65,7 +65,8 @@ constexpr char kBadTPUReplicateAttrMsg[] = "requires '_tpu_replicate' string attribute"; // Mapping for `_tpu_replicate` attribute to TPUReplicateMetadata attributes. -using MetadataMap = llvm::SmallDenseMap<llvm::StringRef, NamedAttributeList, 8>; +using MetadataMap = + llvm::SmallDenseMap<llvm::StringRef, MutableDictionaryAttr, 8>; // Mapping for `_tpu_replicate` attribute to ops of a cluster. using ClusterMap = llvm::SmallDenseMap<llvm::StringRef, @@ -83,7 +84,7 @@ struct TPUClusterFormation LogicalResult CollectMetadata(Operation* op, MetadataMap* metadata_map) { auto result = op->walk([&](TF::TPUReplicateMetadataOp metadata_op) -> WalkResult { - NamedAttributeList attrs = metadata_op.getAttrs(); + MutableDictionaryAttr attrs = metadata_op.getAttrs(); // Missing or bad `_tpu_replicate` attribute. auto tpu_replicate_attr = attrs.get(kTPUReplicateAttr); diff --git a/tensorflow/compiler/mlir/tensorflow/translate/breakup-islands.cc b/tensorflow/compiler/mlir/tensorflow/translate/breakup-islands.cc index 46be9464b83..3245e3b9e6a 100644 --- a/tensorflow/compiler/mlir/tensorflow/translate/breakup-islands.cc +++ b/tensorflow/compiler/mlir/tensorflow/translate/breakup-islands.cc @@ -113,7 +113,7 @@ void BreakUpIslands::runOnFunction() { state.addOperands(operands); Operation* new_op = builder.createOperation(state); item.replaceAllUsesWith(new_op); - new_op->setAttrs(item.getAttrList()); + new_op->setAttrs(item.getMutableAttrDict()); item.erase(); } } diff --git a/tensorflow/compiler/mlir/tensorflow/translate/control_to_executor_dialect.cc b/tensorflow/compiler/mlir/tensorflow/translate/control_to_executor_dialect.cc index b5ebd45936a..9aeaa0ba318 100644 --- a/tensorflow/compiler/mlir/tensorflow/translate/control_to_executor_dialect.cc +++ b/tensorflow/compiler/mlir/tensorflow/translate/control_to_executor_dialect.cc @@ -167,7 +167,7 @@ void ControlToExecutorDialectConversion::runOnFunction() { op.getResult(0).replaceAllUsesWith(replacement->getResult(0)); for (int i : llvm::seq<int>(1, op.getNumResults())) op.getResult(i).replaceAllUsesWith(replacement->getResult(i + 1)); - replacement->setAttrs(op.getAttrList()); + replacement->setAttrs(op.getMutableAttrDict()); op.erase(); continue; } else if (op.getName().getStringRef() == "_tf.NextIteration.sink") { @@ -177,7 +177,7 @@ void ControlToExecutorDialectConversion::runOnFunction() { frame_name_to_loop[frame.getValue()]; replacement = builder.create<tf_executor::NextIterationSinkOp>( loc, srcOp.token(), operands, ArrayRef<NamedAttribute>{}); - replacement->setAttrs(op.getAttrList()); + replacement->setAttrs(op.getMutableAttrDict()); op.erase(); continue; } else if (op.getName().getStringRef() == "_tf.LoopCond") { @@ -220,7 +220,7 @@ void ControlToExecutorDialectConversion::runOnFunction() { // Create the operation inside the island OpBuilder island_builder = OpBuilder::atBlockEnd(&island.GetBody()); Operation *inner_op = island_builder.createOperation(result); - inner_op->setAttrs(op.getAttrList()); + inner_op->setAttrs(op.getMutableAttrDict()); // Add the terminator for the island SmallVector<Value, 8> ret_vals(inner_op->getResults()); @@ -230,7 +230,7 @@ void ControlToExecutorDialectConversion::runOnFunction() { // Copy the attributes from the original operation to the replacement and // remap the results. if (!isa<tf_executor::IslandOp>(replacement)) - replacement->setAttrs(op.getAttrList()); + replacement->setAttrs(op.getMutableAttrDict()); for (int i : llvm::seq<int>(0, op.getNumResults())) op.getResult(i).replaceAllUsesWith(replacement->getResult(i)); op.erase(); diff --git a/tensorflow/compiler/mlir/tensorflow/translate/executor_to_control_dialect.cc b/tensorflow/compiler/mlir/tensorflow/translate/executor_to_control_dialect.cc index 7d0b75006a7..481f1fac7b8 100644 --- a/tensorflow/compiler/mlir/tensorflow/translate/executor_to_control_dialect.cc +++ b/tensorflow/compiler/mlir/tensorflow/translate/executor_to_control_dialect.cc @@ -136,7 +136,7 @@ void ExecutorToControlDialectConversion::runOnFunction() { // Create the replacement operation. auto *replacement = builder.createOperation(state); - replacement->setAttrs(wrapped_op.getAttrList()); + replacement->setAttrs(wrapped_op.getMutableAttrDict()); for (auto ops_and_ret_vals : llvm::zip(wrapped_op.getResults(), replacement->getResults())) @@ -208,7 +208,7 @@ void ExecutorToControlDialectConversion::runOnFunction() { // Create the replacement operation. auto *replacement = builder.createOperation(state); - replacement->setAttrs(op.getAttrList()); + replacement->setAttrs(op.getMutableAttrDict()); if (auto next_iteration = dyn_cast<tf_executor::NextIterationSourceOp>(op)) { diff --git a/tensorflow/compiler/mlir/xla/transforms/xla_hlo_to_lhlo_with_xla.cc b/tensorflow/compiler/mlir/xla/transforms/xla_hlo_to_lhlo_with_xla.cc index aba81886713..ee75ceac2d1 100644 --- a/tensorflow/compiler/mlir/xla/transforms/xla_hlo_to_lhlo_with_xla.cc +++ b/tensorflow/compiler/mlir/xla/transforms/xla_hlo_to_lhlo_with_xla.cc @@ -223,7 +223,7 @@ Status LhloDialectEmitter::Run() { // The function signature will be composed of: // - one memref for each of the parameters. // - one memref for each other buffer allocation. - llvm::SmallVector<NamedAttributeList, 8> args_attrs; + llvm::SmallVector<MutableDictionaryAttr, 8> args_attrs; for (const HloInstruction* param : computation->parameter_instructions()) { TF_ASSIGN_OR_RETURN(auto arg_type, ::xla::ConvertShapeToType<MemRefType>( param->shape(), builder_)); diff --git a/third_party/mlir/BUILD b/third_party/mlir/BUILD index 7ff80eeb0d3..ab7734ef17d 100644 --- a/third_party/mlir/BUILD +++ b/third_party/mlir/BUILD @@ -3070,6 +3070,7 @@ cc_library( ":Support", ":Transforms", ":VectorToLLVM", + ":VectorToLoops", "@llvm-project//llvm:core", "@llvm-project//llvm:support", ],