| 243 | } |
| 244 | |
| 245 | TF_Tensor* TF_AllocateOutput(TF_OpKernelContext* context, int index, |
| 246 | TF_DataType dtype, int64_t* dims, int num_dims, |
| 247 | size_t len) { |
| 248 | auto* cc_ctx = reinterpret_cast<::tensorflow::OpKernelContext*>(context); |
| 249 | tensorflow::AllocatorAttributes attr = cc_ctx->output_alloc_attr(index); |
| 250 | auto* allocator = cc_ctx->get_allocator(attr); |
| 251 | void* data = tensorflow::allocate_tensor("TF_AllocateOutput", len, allocator); |
| 252 | return TF_NewTensor(dtype, dims, num_dims, data, len, |
| 253 | tensorflow::deallocate_buffer, allocator); |
| 254 | } |