Add an interface to add separator before appending numbers in OpOrArgNameMapper.
PiperOrigin-RevId: 307725706 Change-Id: If75e1eb68eb37ece533de7cceccf1cc7da290be8
This commit is contained in:
parent
e6f22ee5f4
commit
a3f1c2a668
tensorflow/compiler/mlir
@ -55,8 +55,10 @@ llvm::StringRef OpOrArgNameMapper::GetUniqueName(llvm::StringRef prefix) {
|
|||||||
// to be unique.
|
// to be unique.
|
||||||
auto& val = prefix_it.first->second;
|
auto& val = prefix_it.first->second;
|
||||||
llvm::SmallString<64> probe_name(prefix);
|
llvm::SmallString<64> probe_name(prefix);
|
||||||
|
probe_name.append(GetSuffixSeparator());
|
||||||
|
const int probe_prefix_size = probe_name.size();
|
||||||
while (true) {
|
while (true) {
|
||||||
probe_name.resize(prefix.size());
|
probe_name.resize(probe_prefix_size);
|
||||||
// TODO(jpienaar): Subtract one so that the initial suffix is 0 instead
|
// TODO(jpienaar): Subtract one so that the initial suffix is 0 instead
|
||||||
// of 1.
|
// of 1.
|
||||||
// TODO(jpienaar): Switch to radix 36 and update tests.
|
// TODO(jpienaar): Switch to radix 36 and update tests.
|
||||||
|
@ -64,6 +64,9 @@ class OpOrArgNameMapper {
|
|||||||
return op_or_val_to_name_;
|
return op_or_val_to_name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the separator used before uniqueing suffix.
|
||||||
|
virtual llvm::StringRef GetSuffixSeparator() { return ""; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Returns name from the location of the operation or value.
|
// Returns name from the location of the operation or value.
|
||||||
virtual std::string GetName(OpOrVal op_or_val) = 0;
|
virtual std::string GetName(OpOrVal op_or_val) = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user