[XLA] Add reasonable error messages to Builder::Build for bad parameter numbers.
PiperOrigin-RevId: 161136262
This commit is contained in:
parent
0cbd249e8b
commit
dabcb60bc9
@ -73,15 +73,19 @@ HloComputation::HloComputation(
|
|||||||
for (auto& instruction : *instructions) {
|
for (auto& instruction : *instructions) {
|
||||||
if (instruction->opcode() == HloOpcode::kParameter) {
|
if (instruction->opcode() == HloOpcode::kParameter) {
|
||||||
int64 param_no = instruction->parameter_number();
|
int64 param_no = instruction->parameter_number();
|
||||||
CHECK_GE(param_no, 0);
|
CHECK(param_no >= 0 && param_no < parameter_count)
|
||||||
CHECK_LT(param_no, param_instructions_.size());
|
<< "\nERROR: invalid parameter number. Expected [0, "
|
||||||
CHECK_EQ(nullptr, param_instructions_[param_no]);
|
<< parameter_count << "), got " << param_no;
|
||||||
|
CHECK(param_instructions_[param_no] == nullptr)
|
||||||
|
<< "\nERROR: parameter number " << param_no
|
||||||
|
<< " already allocated in this computation";
|
||||||
param_instructions_[param_no] = instruction.get();
|
param_instructions_[param_no] = instruction.get();
|
||||||
}
|
}
|
||||||
root_found |= instruction.get() == root_instruction_;
|
root_found |= instruction.get() == root_instruction_;
|
||||||
AddInstructionInternal(std::move(instruction));
|
AddInstructionInternal(std::move(instruction));
|
||||||
}
|
}
|
||||||
CHECK(root_found);
|
CHECK(root_found)
|
||||||
|
<< "\nERROR: root instruction is not present in computation.";
|
||||||
}
|
}
|
||||||
|
|
||||||
HloInstruction* HloComputation::AddInstruction(
|
HloInstruction* HloComputation::AddInstruction(
|
||||||
|
Loading…
Reference in New Issue
Block a user