From 1c9964097dde21b8dd9fdeae29086ebba1e52fa0 Mon Sep 17 00:00:00 2001 From: Andy Ly Date: Wed, 30 Sep 2020 08:10:27 -0700 Subject: [PATCH] Removed unused dependencies in side effect analysis and converted some pointers to refs (NFC). PiperOrigin-RevId: 334600822 Change-Id: I93ae888692433dc27ff73a4152ea16d261c1e461 --- tensorflow/compiler/mlir/tensorflow/BUILD | 1 - .../analysis/resource_alias_analysis.cc | 28 +++++++++---------- .../analysis/side_effect_analysis.cc | 1 - 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/tensorflow/compiler/mlir/tensorflow/BUILD b/tensorflow/compiler/mlir/tensorflow/BUILD index 01f162cf8e5..e662fe4132d 100644 --- a/tensorflow/compiler/mlir/tensorflow/BUILD +++ b/tensorflow/compiler/mlir/tensorflow/BUILD @@ -812,7 +812,6 @@ cc_library( ":tensorflow", ":tensorflow_types", "//tensorflow/core:framework", - "@com_google_absl//absl/strings", "@llvm-project//llvm:Support", "@llvm-project//mlir:Analysis", "@llvm-project//mlir:IR", diff --git a/tensorflow/compiler/mlir/tensorflow/analysis/resource_alias_analysis.cc b/tensorflow/compiler/mlir/tensorflow/analysis/resource_alias_analysis.cc index b25014fe09e..93a55cd9289 100644 --- a/tensorflow/compiler/mlir/tensorflow/analysis/resource_alias_analysis.cc +++ b/tensorflow/compiler/mlir/tensorflow/analysis/resource_alias_analysis.cc @@ -18,21 +18,18 @@ limitations under the License. #include #include -#include "absl/strings/str_cat.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SCCIterator.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Support/Casting.h" -#include "llvm/Support/Debug.h" #include "mlir/Analysis/CallGraph.h" // from @llvm-project #include "mlir/IR/Attributes.h" // from @llvm-project #include "mlir/IR/Block.h" // from @llvm-project -#include "mlir/IR/Builders.h" // from @llvm-project -#include "mlir/IR/Location.h" // from @llvm-project #include "mlir/IR/Module.h" // from @llvm-project #include "mlir/IR/Operation.h" // from @llvm-project #include "mlir/IR/StandardTypes.h" // from @llvm-project @@ -248,22 +245,25 @@ bool IsResourceHandleAnonymous(VarHandleOp handle) { // Returns a string unique identifier for a non-anonymous VarHandleOp. std::string GetVarHandleStringId(VarHandleOp handle) { auto device = handle.getAttrOfType("device"); - return absl::StrCat(handle.container().str(), "/", handle.shared_name().str(), - "/", device ? device.getValue().str() : std::string("")); + return llvm::join( + llvm::ArrayRef{ + handle.container(), handle.shared_name(), + device ? device.getValue() : llvm::StringRef()}, + "/"); } // Finds a unique ID for a VarHandleOp's output. If it is anonymous, always // creates a new ID; otherwise, tries to reuse the existing ID for the // referenced variable if it exists, or creates a new one if not. -int64_t GetOrCreateIdForVarHandle(VarHandleOp handle, int64_t* next_id, - llvm::StringMap* name_id_map) { +int64_t GetOrCreateIdForVarHandle(VarHandleOp handle, int64_t& next_id, + llvm::StringMap& name_id_map) { // Always create a new ID for anonymous handle. - if (IsResourceHandleAnonymous(handle)) return (*next_id)++; + if (IsResourceHandleAnonymous(handle)) return next_id++; auto name = GetVarHandleStringId(handle); - auto emplace_res = name_id_map->try_emplace(name, *next_id); + auto emplace_res = name_id_map.try_emplace(name, next_id); // New ID created, increment next_id. - if (emplace_res.second) ++(*next_id); + if (emplace_res.second) ++next_id; return emplace_res.first->second; } @@ -343,8 +343,8 @@ ResourceAliasAnalysisInfo::ResourceAliasAnalysisInfo( if (auto var_handle = dyn_cast(op)) { AddValueUniqueIDMapping( var_handle.resource(), - GetOrCreateIdForVarHandle(var_handle, &next_unique_id, - &var_handle_name_id_map)); + GetOrCreateIdForVarHandle(var_handle, next_unique_id, + var_handle_name_id_map)); } else if (llvm::isa(op)) { for (auto result : filter_resources(op->getResults())) PropagateInputToOutput(op->getOperand(result.getResultNumber()), diff --git a/tensorflow/compiler/mlir/tensorflow/analysis/side_effect_analysis.cc b/tensorflow/compiler/mlir/tensorflow/analysis/side_effect_analysis.cc index 4a2080c5951..4d2c237e9a0 100644 --- a/tensorflow/compiler/mlir/tensorflow/analysis/side_effect_analysis.cc +++ b/tensorflow/compiler/mlir/tensorflow/analysis/side_effect_analysis.cc @@ -18,7 +18,6 @@ limitations under the License. #include #include -#include "absl/strings/str_cat.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/Optional.h"