aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/hlo_computation.cc
diff options
context:
space:
mode:
authorGravatar Mark Heffernan <meheff@google.com>2018-10-01 10:35:02 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-10-01 10:40:09 -0700
commita5fc8b064884b926ade9f7973dc096c0677a14e0 (patch)
treedab266bce005373b0b5f62931a88432031dd2206 /tensorflow/compiler/xla/service/hlo_computation.cc
parent03a18ca576410d49e8f0692464e35e900a54f59f (diff)
Name fusion parameters simply "param_X".
Where "X" is the parameter number. Previously, fusion parameter names including the name of the original instruction which produced the value which was confusing. PiperOrigin-RevId: 215238171
Diffstat (limited to 'tensorflow/compiler/xla/service/hlo_computation.cc')
-rw-r--r--tensorflow/compiler/xla/service/hlo_computation.cc36
1 files changed, 4 insertions, 32 deletions
diff --git a/tensorflow/compiler/xla/service/hlo_computation.cc b/tensorflow/compiler/xla/service/hlo_computation.cc
index 0e5920af7a..4613d6762e 100644
--- a/tensorflow/compiler/xla/service/hlo_computation.cc
+++ b/tensorflow/compiler/xla/service/hlo_computation.cc
@@ -122,30 +122,6 @@ HloInstruction* HloComputation::AddParameter(
return instructions_.back().get();
}
-namespace {
-
-// Returns the new name for a fusion parameter when we change its number.
-//
-// Fusion parameters are named foo.param_1, bar.param_2, etc. We are
-// renumbering the parameters, so replace the final number in the name with
-// the updated value.
-string RenameFusionParameter(const string& original_name, int64 new_param_no) {
- const string param_underscore = ".param_";
- size_t index = original_name.rfind(param_underscore);
- if (index == string::npos) {
- return original_name;
- }
- string after_param = original_name.substr(index + param_underscore.size());
- int64 numeric_suffix;
- if (absl::SimpleAtoi(after_param, &numeric_suffix)) {
- return StrCat(original_name.substr(0, index + param_underscore.size()),
- new_param_no);
- }
- return original_name;
-}
-
-} // namespace
-
Status HloComputation::RemoveParameter(int64 param_no) {
CHECK_GE(param_no, 0);
CHECK_LT(param_no, param_instructions_.size());
@@ -158,11 +134,9 @@ Status HloComputation::RemoveParameter(int64 param_no) {
while (param_no < param_instructions_.size()) {
param_instruction = param_instructions_[param_no];
- string param_name =
- RenameFusionParameter(param_instruction->name(), param_no);
HloInstruction* new_instr =
AddInstructionInternal(HloInstruction::CreateParameter(
- param_no, param_instruction->shape(), param_name));
+ param_no, param_instruction->shape(), StrCat("param_", param_no)));
TF_RETURN_IF_ERROR(param_instruction->ReplaceAllUsesWith(new_instr));
param_instructions_[param_no] = new_instr;
TF_RETURN_IF_ERROR(RemoveInstruction(param_instruction));
@@ -186,11 +160,9 @@ Status HloComputation::RemoveUnusedParameters() {
if (removed > 0) {
const int64 param_no = i - removed;
- string param_name =
- RenameFusionParameter(param_instruction->name(), param_no);
- HloInstruction* new_instr =
- AddInstructionInternal(HloInstruction::CreateParameter(
- param_no, param_instruction->shape(), param_name));
+ HloInstruction* new_instr = AddInstructionInternal(
+ HloInstruction::CreateParameter(param_no, param_instruction->shape(),
+ StrCat("param_", param_no)));
TF_RETURN_IF_ERROR(param_instruction->ReplaceAllUsesWith(new_instr));
param_instructions_[param_no] = new_instr;
TF_RETURN_IF_ERROR(RemoveInstruction(param_instruction));