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

Function GetContiguousTensor

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

Source from the content-addressed store, hash-verified

915}
916
917Status GetContiguousTensor(const Tensor& tensor, MemoryPool* pool,
918 std::unique_ptr<Tensor>* out) {
919 const int elem_size = tensor.type()->byte_width();
920
921 ARROW_ASSIGN_OR_RAISE(
922 auto scratch_space,
923 AllocateBuffer(tensor.shape()[tensor.ndim() - 1] * elem_size, pool));
924
925 ARROW_ASSIGN_OR_RAISE(std::shared_ptr<ResizableBuffer> contiguous_data,
926 AllocateResizableBuffer(tensor.size() * elem_size, pool));
927
928 io::BufferOutputStream stream(contiguous_data);
929 RETURN_NOT_OK(WriteStridedTensorData(0, 0, elem_size, tensor,
930 scratch_space->mutable_data(), &stream));
931
932 *out = std::make_unique<Tensor>(tensor.type(), contiguous_data, tensor.shape());
933
934 return Status::OK();
935}
936
937} // namespace
938

Callers 1

GetTensorMessageFunction · 0.85

Calls 10

AllocateResizableBufferFunction · 0.85
WriteStridedTensorDataFunction · 0.85
ndimMethod · 0.80
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