| 424 | } |
| 425 | |
| 426 | cg::ComputingGraph::OutputSpecItem mgb::make_callback_copy( |
| 427 | SymbolVar dev, HostTensorND& host, bool sync) { |
| 428 | auto cb = [sync, &host](DeviceTensorND& d) { |
| 429 | host.copy_from(d); |
| 430 | if (sync) { |
| 431 | host.sync(); |
| 432 | } |
| 433 | }; |
| 434 | return {dev, cb}; |
| 435 | } |
| 436 | |
| 437 | /* ========================== PersistentCacheHook ========================== */ |
| 438 | class PersistentCacheHook::HookedImpl final : public PersistentCache { |