[spirv] Provide decorations in batch for op construction

Instead of setting the attributes for decorations one by one
after constructing the op, this CL changes to attach all
the attributes for decorations to the attribute vector for
constructing the op. This should be simpler and more
efficient.

PiperOrigin-RevId: 261905578
This commit is contained in:
Lei Zhang 2019-08-06 07:02:35 -07:00 committed by A. Unique TensorFlower
parent 4b422a51ed
commit cd1c488ecd
1 changed files with 10 additions and 11 deletions

View File

@ -307,7 +307,16 @@ static void emitDeserializationFunction(const Record *attrClass,
<< op.getQualCppClassName()
<< ", only \") << wordIndex << \" of \" << words.size() << \" "
"processed\";\n";
os << " }\n";
os << " }\n\n";
// Import decorations parsed
if (op.getNumResults() == 1) {
os << " if (decorations.count(valueID)) {\n"
<< " auto attrs = decorations[valueID].getAttrs();\n"
<< " attributes.append(attrs.begin(), attrs.end());\n"
<< " }\n";
}
os << formatv(" auto op = opBuilder.create<{0}>(unknownLoc, resultTypes, "
"operands, attributes); (void)op;\n",
op.getQualCppClassName());
@ -315,16 +324,6 @@ static void emitDeserializationFunction(const Record *attrClass,
os << " valueMap[valueID] = op.getResult();\n\n";
}
// Import decorations parsed
if (op.getNumResults() == 1) {
os << " if (decorations.count(valueID)) {\n";
os << " auto decorationAttrs = decorations[valueID];\n";
os << " for (auto attr : decorationAttrs.getAttrs()) {\n";
os << " op.setAttr(attr.first, attr.second);\n";
os << " }\n";
os << " }\n";
}
os << " return success();\n";
os << "}\n\n";
}