Skip to content

Commit 06985cd

Browse files
Have plasma op deserialize as numpy array.
1 parent a2a9c36 commit 06985cd

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

cpp/src/arrow/python/serialize.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -752,23 +752,23 @@ Status SerializeObject(PyObject* context, PyObject* sequence, SerializedPyObject
752752
return Status::OK();
753753
}
754754

755-
Status SerializeTensor(std::shared_ptr<Tensor> tensor, SerializedPyObject* out) {
755+
Status SerializeNdarray(std::shared_ptr<Tensor> tensor, SerializedPyObject* out) {
756756
std::shared_ptr<Array> array;
757757
SequenceBuilder builder;
758-
RETURN_NOT_OK(builder.AppendTensor(static_cast<int32_t>(out->tensors.size())));
758+
RETURN_NOT_OK(builder.AppendNdarray(static_cast<int32_t>(out->tensors.size())));
759759
out->tensors.push_back(tensor);
760760
RETURN_NOT_OK(builder.Finish(nullptr, nullptr, nullptr, nullptr, &array));
761761
out->batch = MakeBatch(array);
762762
return Status::OK();
763763
}
764764

765-
Status WriteTensorHeader(std::shared_ptr<DataType> dtype,
766-
const std::vector<int64_t>& shape, int64_t tensor_num_bytes,
767-
io::OutputStream* dst) {
765+
Status WriteNdarrayHeader(std::shared_ptr<DataType> dtype,
766+
const std::vector<int64_t>& shape, int64_t tensor_num_bytes,
767+
io::OutputStream* dst) {
768768
auto empty_tensor = std::make_shared<Tensor>(
769769
dtype, std::make_shared<Buffer>(nullptr, tensor_num_bytes), shape);
770770
SerializedPyObject serialized_tensor;
771-
RETURN_NOT_OK(SerializeTensor(empty_tensor, &serialized_tensor));
771+
RETURN_NOT_OK(SerializeNdarray(empty_tensor, &serialized_tensor));
772772
return serialized_tensor.WriteTo(dst);
773773
}
774774

cpp/src/arrow/python/serialize.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ Status SerializeTensor(std::shared_ptr<Tensor> tensor, py::SerializedPyObject* o
103103
/// \param[in] dst The OutputStream to write the Tensor header to
104104
/// \return Status
105105
ARROW_EXPORT
106-
Status WriteTensorHeader(std::shared_ptr<DataType> dtype,
107-
const std::vector<int64_t>& shape, int64_t tensor_num_bytes,
108-
io::OutputStream* dst);
106+
Status WriteNdarrayHeader(std::shared_ptr<DataType> dtype,
107+
const std::vector<int64_t>& shape, int64_t tensor_num_bytes,
108+
io::OutputStream* dst);
109109

110110
} // namespace py
111111

python/pyarrow/tensorflow/plasma_op.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class TensorToPlasmaOp : public tf::AsyncOpKernel {
140140
std::vector<int64_t> shape = {total_bytes / byte_width};
141141

142142
arrow::io::MockOutputStream mock;
143-
ARROW_CHECK_OK(arrow::py::WriteTensorHeader(arrow_dtype, shape, 0, &mock));
143+
ARROW_CHECK_OK(arrow::py::WriteNdarrayHeader(arrow_dtype, shape, 0, &mock));
144144
int64_t header_size = mock.GetExtentBytesWritten();
145145

146146
std::shared_ptr<Buffer> data_buffer;
@@ -152,7 +152,7 @@ class TensorToPlasmaOp : public tf::AsyncOpKernel {
152152

153153
int64_t offset;
154154
arrow::io::FixedSizeBufferWriter buf(data_buffer);
155-
ARROW_CHECK_OK(arrow::py::WriteTensorHeader(arrow_dtype, shape, total_bytes, &buf));
155+
ARROW_CHECK_OK(arrow::py::WriteNdarrayHeader(arrow_dtype, shape, total_bytes, &buf));
156156
ARROW_CHECK_OK(buf.Tell(&offset));
157157

158158
uint8_t* data = reinterpret_cast<uint8_t*>(data_buffer->mutable_data() + offset);

0 commit comments

Comments
 (0)