MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ResolveAndValidateArguments

Method ResolveAndValidateArguments

tensorflow/compiler/xla/service/service.cc:230–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230StatusOr<std::vector<std::vector<const ShapedBuffer*>>>
231Service::ResolveAndValidateArguments(
232 absl::Span<const GlobalDataHandle* const> arguments,
233 absl::Span<se::StreamExecutor* const> stream_executors) const {
234 CHECK_EQ(options_.number_of_replicas(), stream_executors.size());
235 std::vector<std::vector<const ShapedBuffer*>> replicated_arguments;
236 replicated_arguments.resize(options_.number_of_replicas());
237 for (size_t i = 0; i < arguments.size(); ++i) {
238 auto buffer_status = allocation_tracker_.Resolve(*arguments[i]);
239 if (!buffer_status.ok()) {
240 return Status(buffer_status.status().code(),
241 StrCat(buffer_status.status().error_message(), ", ",
242 "failed to resolve allocation for parameter ", i));
243 }
244 auto replicated_buffers = buffer_status.ValueOrDie();
245 CHECK_EQ(options_.number_of_replicas(), replicated_buffers.size());
246 for (int replica = 0; replica < options_.number_of_replicas(); ++replica) {
247 const ShapedBuffer* shaped_buffer = replicated_buffers[replica];
248 int replica_device_ordinal = stream_executors[replica]->device_ordinal();
249 // Verify allocation is same platform and device as the execution.
250 if (shaped_buffer->platform() != execute_backend_->platform() ||
251 shaped_buffer->device_ordinal() != replica_device_ordinal) {
252 return InvalidArgument(
253 "argument %lu is on device %s:%d but computation will be executed "
254 "on device %s",
255 i, shaped_buffer->platform()->Name(),
256 shaped_buffer->device_ordinal(),
257 execute_backend_->device_name(replica_device_ordinal));
258 }
259 replicated_arguments[replica].push_back(shaped_buffer);
260 }
261 }
262 return replicated_arguments;
263}
264
265StatusOr<std::unique_ptr<HloModuleConfig>> Service::CreateModuleConfig(
266 const ProgramShape& program_shape,

Callers

nothing calls this directly

Calls 15

InvalidArgumentFunction · 0.85
StatusClass · 0.50
StrCatFunction · 0.50
number_of_replicasMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
ResolveMethod · 0.45
okMethod · 0.45
codeMethod · 0.45
statusMethod · 0.45
device_ordinalMethod · 0.45
platformMethod · 0.45

Tested by

no test coverage detected