MCPcopy Create free account
hub / github.com/apache/tvm-ffi / ExampleArray

Function ExampleArray

tests/cpp/test_example.cc:166–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164TEST(Example, String) { ExampleString(); }
165
166void ExampleArray() {
167 namespace ffi = tvm::ffi;
168 ffi::Array<int> numbers = {1, 2, 3};
169 EXPECT_EQ(numbers.size(), 3);
170 EXPECT_EQ(numbers[0], 1);
171
172 // NOLINTNEXTLINE(performance-unnecessary-value-param)
173 ffi::Function head = ffi::Function::FromTyped([](const ffi::Array<int> a) { return a[0]; });
174 EXPECT_EQ(head(numbers).cast<int>(), 1);
175
176 try {
177 // throw an error because 2.2 is not int
178 head(ffi::Array<ffi::Any>({1, 2.2}));
179 } catch (const ffi::Error& e) {
180 EXPECT_EQ(e.kind(), "TypeError");
181 }
182}
183
184void ExampleTuple() {
185 namespace ffi = tvm::ffi;

Callers 1

TESTFunction · 0.85

Calls 2

sizeMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected