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

Method CheckTensorRoundTrip

cpp/src/arrow/ipc/tensor_test.cc:68–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66class TestTensorRoundTrip : public BaseTensorTest {
67 public:
68 void CheckTensorRoundTrip(const Tensor& tensor) {
69 int32_t metadata_length;
70 int64_t body_length;
71 const int elem_size = tensor.type()->byte_width();
72
73 ASSERT_OK(mmap_->Seek(0));
74
75 ASSERT_OK(WriteTensor(tensor, mmap_.get(), &metadata_length, &body_length));
76
77 const int64_t expected_body_length = elem_size * tensor.size();
78 ASSERT_EQ(expected_body_length, body_length);
79
80 ASSERT_OK(mmap_->Seek(0));
81
82 std::shared_ptr<Tensor> result;
83 ASSERT_OK_AND_ASSIGN(result, ReadTensor(mmap_.get()));
84
85 ASSERT_EQ(result->data()->size(), expected_body_length);
86 ASSERT_TRUE(tensor.Equals(*result));
87 }
88
89 protected:
90 std::shared_ptr<io::MemoryMappedFile> mmap_;

Callers

nothing calls this directly

Calls 10

WriteTensorFunction · 0.85
ReadTensorFunction · 0.85
ASSERT_OK_AND_ASSIGNFunction · 0.50
byte_widthMethod · 0.45
typeMethod · 0.45
SeekMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
EqualsMethod · 0.45

Tested by

no test coverage detected