tensorflow/core/runtime_fallback/util/tensor_util.cc
// Moves one ref on HostBuffer to tensorflow::Tensor.
Moves one ref on HostBuffer to tensorflow::Tensor.
Moves one ref on HostBuffer to tensorflow :: Tensor .
tensorflow::Tensor MoveHostBufferToTfTensor(RCReference<HostBuffer> host_buffer,
                                            DType dtype,
                                            const tfrt::TensorShape& shape) {
  llvm::SmallVector<tfrt::Index, 4> dims;
  shape.GetDimensions(&dims);
  auto deallocator = [](void* data, size_t len, void* arg) {
    auto* host_buffer = reinterpret_cast<HostBuffer*>(arg);
    host_buffer->DropRef();
  };
  CheckBoolCompatibility();
  auto* data = host_buffer->data();
  auto size = host_buffer->size();
  OwnedTFTensor tf_tensor{TF_NewTensor(
      static_cast<TF_DataType>(GetTfDataType(dtype)), dims.data(), dims.size(),
      data, size, deallocator, host_buffer.release())};
  return down_cast<TensorInterface*>(tf_tensor->tensor)->Tensor();
}
tensorflow :: Tensor MoveHostBufferToTfTensor ( RCReference < HostBuffer > host_buffer , DType dtype , const tfrt :: TensorShape & shape ) { llvm :: SmallVector < tfrt :: Index , 4 > dims ; shape . GetDimensions ( & dims ) ; auto deallocator = [ ] ( void * data , size_t len , void * arg ) { auto * host_buffer = reinterpret_cast < HostBuffer * > ( arg ) ; host_buffer -> DropRef ( ) ; } ; CheckBoolCompatibility ( ) ; auto * data = host_buffer -> data ( ) ; auto size = host_buffer -> size ( ) ; OwnedTFTensor tf_tensor { TF_NewTensor ( static_cast < TF_DataType > ( GetTfDataType ( dtype ) ) , dims . data ( ) , dims . size ( ) , data , size , deallocator , host_buffer . release ( ) ) } ; return down_cast < TensorInterface * > ( tf_tensor -> tensor ) -> Tensor ( ) ; }
Moves one ref on HostBuffer to tensorflow::Tensor.
Moves one ref on HostBuffer to tensorflow :: Tensor .
// Transfer one HostBuffer ref to TFTensor.