Use the correct device ordinal to check whether the device the executable was

built for is equivalent to the device the it will run on.

Before this patch, if the device to run on was provided via a stream without
setting the device ordinal in the ExecutableRunOptions, we would check the
default device against the device the executable was built for.

PiperOrigin-RevId: 206892902
This commit is contained in:
A. Unique TensorFlower 2018-08-01 01:02:45 -07:00 committed by TensorFlower Gardener
parent 26ba623dcc
commit abd645085b

View File

@ -101,11 +101,14 @@ Status LocalExecutable::ValidateExecutionOptions(
}
}
// Verify that the device the executable was built for is equivalent to the
// device it will run on.
int run_device_ordinal = run_options.device_ordinal() == -1
? backend_->default_device_ordinal()
: run_options.device_ordinal();
// Verify that the device the executable was built for is equivalent
// to the device it will run on.
int run_device_ordinal = run_options.device_ordinal();
if (run_device_ordinal == -1) {
run_device_ordinal = run_options.stream() != nullptr
? run_options.stream()->parent()->device_ordinal()
: backend_->default_device_ordinal();
}
TF_ASSIGN_OR_RETURN(bool devices_equivalent,
backend_->devices_equivalent(
run_device_ordinal, build_options_.device_ordinal()));