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

Function WriteStridedTensorData

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

Source from the content-addressed store, hash-verified

895}
896
897Status WriteStridedTensorData(int dim_index, int64_t offset, int elem_size,
898 const Tensor& tensor, uint8_t* scratch_space,
899 io::OutputStream* dst) {
900 if (dim_index == tensor.ndim() - 1) {
901 const uint8_t* data_ptr = tensor.raw_data() + offset;
902 const int64_t stride = tensor.strides()[dim_index];
903 for (int64_t i = 0; i < tensor.shape()[dim_index]; ++i) {
904 memcpy(scratch_space + i * elem_size, data_ptr, elem_size);
905 data_ptr += stride;
906 }
907 return dst->Write(scratch_space, elem_size * tensor.shape()[dim_index]);
908 }
909 for (int64_t i = 0; i < tensor.shape()[dim_index]; ++i) {
910 RETURN_NOT_OK(WriteStridedTensorData(dim_index + 1, offset, elem_size, tensor,
911 scratch_space, dst));
912 offset += tensor.strides()[dim_index];
913 }
914 return Status::OK();
915}
916
917Status GetContiguousTensor(const Tensor& tensor, MemoryPool* pool,
918 std::unique_ptr<Tensor>* out) {

Callers 2

GetContiguousTensorFunction · 0.85
WriteTensorFunction · 0.85

Calls 6

ndimMethod · 0.80
raw_dataMethod · 0.80
OKFunction · 0.50
stridesMethod · 0.45
shapeMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected