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

Function TEST_F

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

Source from the content-addressed store, hash-verified

92};
93
94TEST_F(TestTensorRoundTrip, BasicRoundtrip) {
95 std::string path = "test-write-tensor";
96 constexpr int64_t kBufferSize = 1 << 20;
97 ASSERT_OK_AND_ASSIGN(mmap_, io::MemoryMapFixture::InitMemoryMap(kBufferSize, path));
98
99 std::vector<int64_t> shape = {4, 6};
100 std::vector<int64_t> strides = {48, 8};
101 std::vector<std::string> dim_names = {"foo", "bar"};
102 int64_t size = 24;
103
104 std::vector<int64_t> values;
105 randint(size, 0, 100, &values);
106
107 auto data = Buffer::Wrap(values);
108
109 Tensor t0(int64(), data, shape, strides, dim_names);
110 Tensor t_no_dims(int64(), data, {}, {}, {});
111 Tensor t_zero_length_dim(int64(), data, {0}, {8}, {"foo"});
112
113 CheckTensorRoundTrip(t0);
114 CheckTensorRoundTrip(t_no_dims);
115 CheckTensorRoundTrip(t_zero_length_dim);
116
117 int64_t serialized_size;
118 ASSERT_OK(GetTensorSize(t0, &serialized_size));
119 ASSERT_TRUE(serialized_size > static_cast<int64_t>(size * sizeof(int64_t)));
120
121 // ARROW-2840: Check that padding/alignment minded
122 std::vector<int64_t> shape_2 = {1, 1};
123 std::vector<int64_t> strides_2 = {8, 8};
124 Tensor t0_not_multiple_64(int64(), data, shape_2, strides_2, dim_names);
125 CheckTensorRoundTrip(t0_not_multiple_64);
126}
127
128TEST_F(TestTensorRoundTrip, NonContiguous) {
129 std::string path = "test-write-tensor-strided";

Callers

nothing calls this directly

Calls 4

randintFunction · 0.85
WrapFunction · 0.85
GetTensorSizeFunction · 0.85
ASSERT_OK_AND_ASSIGNFunction · 0.50

Tested by

no test coverage detected