tensorflow/core/runtime_fallback/util/gpu/gpu_utils.cc
// Moves one ref on GpuBuffer to tensorflow::Tensor.
Moves one ref on GpuBuffer to tensorflow::Tensor.
Moves one ref on GpuBuffer to tensorflow :: Tensor .
tfrt::Expected<tensorflow::Tensor> MoveGpuBufferToTFTensor(
    tfrt::AsyncValueRef<tfrt::gpu::GpuBuffer> gpu_buffer, tfrt::DType dtype,
    tfrt::TensorShape shape) {
  auto deallocator = [](void* data, size_t len, void* arg) {
    auto* gpu_buffer = reinterpret_cast<tfrt::AsyncValue*>(arg);
    gpu_buffer->DropRef();
  };
  OwnedTFManagedBuffer tf_managed_buffer{
      new TF_ManagedBuffer(gpu_buffer->pointer().raw(), gpu_buffer->size(),
                           deallocator, gpu_buffer.release(),
                           false)};
  tensorflow::Tensor tensor(GetTfDataType(dtype), GetTfShape(shape),
                            tf_managed_buffer.get());
  return std::move(tensor);
}
tfrt :: Expected < tensorflow :: Tensor > MoveGpuBufferToTFTensor ( tfrt :: AsyncValueRef < tfrt :: gpu :: GpuBuffer > gpu_buffer , tfrt :: DType dtype , tfrt :: TensorShape shape ) { auto deallocator = [ ] ( void * data , size_t len , void * arg ) { auto * gpu_buffer = reinterpret_cast < tfrt :: AsyncValue * > ( arg ) ; gpu_buffer -> DropRef ( ) ; } ; OwnedTFManagedBuffer tf_managed_buffer { new TF_ManagedBuffer ( gpu_buffer -> pointer ( ) . raw ( ) , gpu_buffer -> size ( ) , deallocator , gpu_buffer . release ( ) , false ) } ; tensorflow :: Tensor tensor ( GetTfDataType ( dtype ) , GetTfShape ( shape ) , tf_managed_buffer . get ( ) ) ; return std :: move ( tensor ) ; }
Moves one ref on GpuBuffer to tensorflow::Tensor.
Moves one ref on GpuBuffer to tensorflow :: Tensor .
// `owns_memory` is used by tensorflow::Tensor::RefCountIsOne. // One ref on `gpu_buffer` is transfered here to TF_ManagedBuffer. /*owns_memory=*/