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

Method CheckTensorRoundTrip

cpp/src/arrow/ipc/tensor_test.cc:68–91  ·  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 ARROW_SUPPRESS_DEPRECATION_WARNING
76 ASSERT_OK(WriteTensor(tensor, mmap_.get(), &metadata_length, &body_length));
77 ARROW_UNSUPPRESS_DEPRECATION_WARNING
78
79 const int64_t expected_body_length = elem_size * tensor.size();
80 ASSERT_EQ(expected_body_length, body_length);
81
82 ASSERT_OK(mmap_->Seek(0));
83
84 std::shared_ptr<Tensor> result;
85 ARROW_SUPPRESS_DEPRECATION_WARNING
86 ASSERT_OK_AND_ASSIGN(result, ReadTensor(mmap_.get()));
87 ARROW_UNSUPPRESS_DEPRECATION_WARNING
88
89 ASSERT_EQ(result->data()->size(), expected_body_length);
90 ASSERT_TRUE(tensor.Equals(*result));
91 }
92
93 protected:
94 std::shared_ptr<io::MemoryMappedFile> mmap_;

Callers

nothing calls this directly

Calls 9

WriteTensorFunction · 0.85
ReadTensorFunction · 0.85
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