| 903 | } |
| 904 | |
| 905 | Status GetContiguousTensor(const Tensor& tensor, MemoryPool* pool, |
| 906 | std::unique_ptr<Tensor>* out) { |
| 907 | const int elem_size = tensor.type()->byte_width(); |
| 908 | |
| 909 | ARROW_ASSIGN_OR_RAISE( |
| 910 | auto scratch_space, |
| 911 | AllocateBuffer(tensor.shape()[tensor.ndim() - 1] * elem_size, pool)); |
| 912 | |
| 913 | ARROW_ASSIGN_OR_RAISE(std::shared_ptr<ResizableBuffer> contiguous_data, |
| 914 | AllocateResizableBuffer(tensor.size() * elem_size, pool)); |
| 915 | |
| 916 | io::BufferOutputStream stream(contiguous_data); |
| 917 | RETURN_NOT_OK(WriteStridedTensorData(0, 0, elem_size, tensor, |
| 918 | scratch_space->mutable_data(), &stream)); |
| 919 | |
| 920 | *out = std::make_unique<Tensor>(tensor.type(), contiguous_data, tensor.shape()); |
| 921 | |
| 922 | return Status::OK(); |
| 923 | } |
| 924 | |
| 925 | } // namespace |
| 926 |
no test coverage detected