MCPcopy Create free account
hub / github.com/apache/arrow / GetContiguousTensor

Function GetContiguousTensor

cpp/src/arrow/ipc/writer.cc:898–916  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

896}
897
898Status GetContiguousTensor(const Tensor& tensor, MemoryPool* pool,
899 std::unique_ptr<Tensor>* out) {
900 const int elem_size = tensor.type()->byte_width();
901
902 ARROW_ASSIGN_OR_RAISE(
903 auto scratch_space,
904 AllocateBuffer(tensor.shape()[tensor.ndim() - 1] * elem_size, pool));
905
906 ARROW_ASSIGN_OR_RAISE(std::shared_ptr<ResizableBuffer> contiguous_data,
907 AllocateResizableBuffer(tensor.size() * elem_size, pool));
908
909 io::BufferOutputStream stream(contiguous_data);
910 RETURN_NOT_OK(WriteStridedTensorData(0, 0, elem_size, tensor,
911 scratch_space->mutable_data(), &stream));
912
913 *out = std::make_unique<Tensor>(tensor.type(), contiguous_data, tensor.shape());
914
915 return Status::OK();
916}
917
918} // namespace
919

Callers 1

GetTensorMessageFunction · 0.85

Calls 9

AllocateResizableBufferFunction · 0.85
WriteStridedTensorDataFunction · 0.85
ARROW_ASSIGN_OR_RAISEFunction · 0.70
OKFunction · 0.50
byte_widthMethod · 0.45
typeMethod · 0.45
sizeMethod · 0.45
mutable_dataMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected