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

Function TEST_F

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

Source from the content-addressed store, hash-verified

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