PiperOrigin-RevId: 309203365
Change-Id: Idfec7bc2323705f0c3384fae8f1260849bc212b3
This commit is contained in:
A. Unique TensorFlower 2020-04-30 04:50:47 -07:00 committed by TensorFlower Gardener
parent 9dfc5b11a5
commit db9eef4cad
7 changed files with 14 additions and 12 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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();
}
}

View File

@ -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();

View File

@ -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)) {

View File

@ -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_));

View File

@ -3070,6 +3070,7 @@ cc_library(
":Support",
":Transforms",
":VectorToLLVM",
":VectorToLoops",
"@llvm-project//llvm:core",
"@llvm-project//llvm:support",
],