Creates a tensor from a buffer of memory
It creates a tensor without taking ownership of the memory it points to. You must call clone
if you want to copy the memory over a new tensor.
torch_tensor_from_buffer(buffer, shape, dtype = "float") buffer_from_torch_tensor(tensor)
buffer
: An R atomic object containing the data in a contiguous array.shape
: The shape of the resulting tensor.dtype
: A torch data type for the tresulting tensor.tensor
: Tensor object that will be converted into a buffer.buffer_from_torch_tensor()
: Creates a raw vector containing the tensor data. Causes a data copy.Useful links