MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetName

Method GetName

tensorflow/compiler/mlir/op_or_arg_name_mapper.cc:150–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148} // anonymous namespace
149
150std::string OpOrArgLocNameMapper::GetName(OpOrVal op_or_val) {
151 if (auto* op = op_or_val.dyn_cast<mlir::Operation*>()) {
152 auto name_from_loc = GetNameFromLoc(op->getLoc());
153 if (!name_from_loc.empty()) return name_from_loc;
154 // If the location is none of the expected types, then simply use name
155 // generated using the op type.
156 return std::string(op->getName().getStringRef());
157 }
158 auto val = op_or_val.dyn_cast<mlir::Value>();
159 auto name_from_loc = GetNameFromLoc(val.getLoc());
160 if (!name_from_loc.empty()) return name_from_loc;
161 // If the location is none of the expected types, then simply use name
162 // generated using the op type. Follow TF convention and append the result
163 // index unless 0.
164 if (auto result = val.dyn_cast<mlir::OpResult>()) {
165 if (result.getResultNumber() > 0)
166 return llvm::formatv("{0}:{1}",
167 result.getOwner()->getName().getStringRef(),
168 result.getResultNumber());
169 return std::string(result.getOwner()->getName().getStringRef());
170 }
171 // Use the ASM syntax for BloackArgument
172 if (auto arg = val.dyn_cast<mlir::BlockArgument>()) {
173 return "arg" + std::to_string(arg.getArgNumber());
174 }
175 return "";
176}
177
178std::string OpOrArgStripNameMapper::GetName(OpOrVal op_or_val) {
179 return llvm::APInt(32, count_++).toString(/*Radix=*/36, /*Signed=*/false);

Callers 2

MaybeAddObjectMethod · 0.45

Calls 5

GetNameFromLocFunction · 0.85
to_stringFunction · 0.85
emptyMethod · 0.45
getNameMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected