| 81 | EagerLocalTensorImpl::~EagerLocalTensorImpl() {} |
| 82 | |
| 83 | Maybe<void> EagerLocalTensorImpl::UpdateTensorStorage() { |
| 84 | const auto& eager_blob_object = eager_blob_object_; |
| 85 | tensor_storage_ = std::make_shared<TensorStorage>(eager_blob_object->tensor_storage()); |
| 86 | tensor_storage_->set_releaser_hook([eager_blob_object]( |
| 87 | const std::shared_ptr<vm::TensorStorage>&) { |
| 88 | auto ret = PhysicalRun([&](InstructionsBuilder* builder) -> Maybe<void> { |
| 89 | if (eager_blob_object->producer_stream().has_value()) { |
| 90 | JUST(builder->ReleaseTensor(eager_blob_object)); |
| 91 | } |
| 92 | return Maybe<void>::Ok(); |
| 93 | }); |
| 94 | // We should not use CHECK_JUST here because it will throw an exception |
| 95 | // in destructor. |
| 96 | if (!ret.IsOk()) { |
| 97 | LOG(WARNING) |
| 98 | << "Release hook gets an error. Release hooks are executed in destructor, so the error " |
| 99 | "is possibly only a secondary error caused by another unrelated exception."; |
| 100 | LOG(WARNING) << "======= Error message begin ======="; |
| 101 | LOG(WARNING) << ret.GetSerializedError(); |
| 102 | LOG(WARNING) << "======= Error message end ======="; |
| 103 | } |
| 104 | }); |
| 105 | return Maybe<void>::Ok(); |
| 106 | } |
| 107 | |
| 108 | const std::shared_ptr<const MutLocalTensorMeta>& EagerLocalTensorImpl::mut_tensor_meta() { |
| 109 | return eager_blob_object_->mut_tensor_meta(); |
nothing calls this directly
no test coverage detected