| 229 | } |
| 230 | |
| 231 | StatusOr<ScopedShapedBuffer> LocalExecutable::RunAsync( |
| 232 | const absl::Span<const ShapedBuffer* const> arguments, |
| 233 | ExecutableRunOptions run_options) { |
| 234 | std::vector<const Shape*> argument_shapes; |
| 235 | argument_shapes.reserve(arguments.size()); |
| 236 | for (const ShapedBuffer* const arg : arguments) { |
| 237 | argument_shapes.push_back(&arg->on_host_shape()); |
| 238 | } |
| 239 | TF_ASSIGN_OR_RETURN(auto options_and_stream, |
| 240 | RunHelper(argument_shapes, run_options)); |
| 241 | se::Stream* stream = run_options.stream(); |
| 242 | |
| 243 | std::shared_ptr<HloSnapshot> snapshot; |
| 244 | if (executable_->dumping_snapshot()) { |
| 245 | snapshot = DumpArguments(backend_, executable_.get(), arguments, stream); |
| 246 | } |
| 247 | |
| 248 | TF_ASSIGN_OR_RETURN(ScopedShapedBuffer outputs, |
| 249 | executable_->ExecuteAsyncOnStreamWrapper( |
| 250 | &options_and_stream.first, arguments)); |
| 251 | |
| 252 | // Transfer the outputs and save the snapshot to disk. |
| 253 | if (snapshot) { |
| 254 | DumpOutputsAndSaveSnapshot(backend_, outputs, std::move(snapshot), stream); |
| 255 | } |
| 256 | |
| 257 | return std::move(outputs); |
| 258 | } |
| 259 | |
| 260 | static ShapedBuffer MaybeOwningShapeTreeToShapedBuffer( |
| 261 | Shape const& on_host_shape, const ShapeTree<MaybeOwningDeviceMemory>& tree, |
no test coverage detected