| 228 | } |
| 229 | |
| 230 | StatusOr<std::vector<std::vector<const ShapedBuffer*>>> |
| 231 | Service::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 | |
| 265 | StatusOr<std::unique_ptr<HloModuleConfig>> Service::CreateModuleConfig( |
| 266 | const ProgramShape& program_shape, |
nothing calls this directly
no test coverage detected