| 896 | } |
| 897 | |
| 898 | Status 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 |
no test coverage detected