[XLA] Verify instruction IDs don't over/under-flow int.

The proto field is int64, but the class field is int.

PiperOrigin-RevId: 225044350
This commit is contained in:
Michael Kuperstein 2018-12-11 11:55:47 -08:00 committed by TensorFlower Gardener
parent 74ba359321
commit a3ad14bbd2
2 changed files with 6 additions and 0 deletions

View File

@ -569,6 +569,11 @@ StatusOr<std::unique_ptr<HloInstruction>> HloInstruction::CreateFromProto(
instruction->SetAndSanitizeName(proto.name());
instruction->metadata_ = proto.metadata();
instruction->backend_config_ = proto.backend_config();
TF_RET_CHECK(proto.id() >= 0)
<< "Instruction with negative id: " << proto.id();
TF_RET_CHECK(proto.id() <= INT_MAX)
<< "Instruction with id > INT_MAX: " << proto.id();
instruction->unique_id_ = proto.id();
if (proto.has_sharding()) {

View File

@ -39,6 +39,7 @@ HloProto MakeHloProto(const HloModule& module) {
StatusOr<std::unique_ptr<HloModule>> CreateModuleFromProto(
const HloModuleProto& proto, const HloModuleConfig& module_config) {
VLOG(4) << proto.ShortDebugString();
TF_ASSIGN_OR_RETURN(std::unique_ptr<HloModule> module,
HloModule::CreateFromProto(proto, module_config));
TF_RETURN_IF_ERROR(