| 90 | } |
| 91 | |
| 92 | void Compute(OpKernelContext* context) override { |
| 93 | Status s; |
| 94 | ResourceMgr* rm = context->resource_manager(); |
| 95 | OP_REQUIRES(context, rm, errors::Internal("No per-step resource manager.")); |
| 96 | auto* tmp_var = new TmpVar; |
| 97 | OP_REQUIRES(context, tmp_var, |
| 98 | errors::ResourceExhausted("Could not allocate TmpVar.")); |
| 99 | tmp_var->name = var_name_; |
| 100 | s = context->allocate_temp(dtype_, shape_, &tmp_var->val); |
| 101 | if (!s.ok()) tmp_var->Unref(); |
| 102 | OP_REQUIRES_OK(context, s); |
| 103 | OP_REQUIRES_OK(context, |
| 104 | context->step_container()->Create(rm, var_name_, tmp_var)); |
| 105 | context->set_output_ref(0, &tmp_var->mu, &tmp_var->val); |
| 106 | if (context->track_allocations()) { |
| 107 | context->record_persistent_memory_allocation( |
| 108 | tmp_var->val.AllocatedBytes()); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | private: |
| 113 | // Refcounted temporary variable resource. |
nothing calls this directly
no test coverage detected