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

Function TEST

tests/cpp/test_function.cc:36–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34using namespace tvm::ffi::testing;
35
36TEST(Func, FromPacked) {
37 Function fadd1 = Function::FromPacked([](const AnyView* args, int32_t num_args, Any* rv) {
38 EXPECT_EQ(num_args, 1);
39 int32_t a = args[0].cast<int32_t>();
40 *rv = a + 1;
41 });
42 int b = fadd1(1).cast<int>();
43 EXPECT_EQ(b, 2);
44
45 Function fadd2 = Function::FromPacked([](const AnyView* args, int32_t num_args, Any* rv) {
46 EXPECT_EQ(num_args, 1);
47 auto a = args[0].cast<TInt>();
48 EXPECT_EQ(a.use_count(), 2);
49 *rv = a->value + 1;
50 });
51 EXPECT_EQ(fadd2(TInt(12)).cast<int>(), 13);
52}
53
54TEST(Func, PackedArgs) {
55 Function fadd1 = Function::FromPacked([](PackedArgs args, Any* rv) {

Callers

nothing calls this directly

Calls 15

MoveFromSafeCallRaisedFunction · 0.85
invoke_testing_add1Function · 0.85
ParseFunction · 0.85
TVMFFITestingDummyTargetFunction · 0.85
TIntClass · 0.70
use_countMethod · 0.45
sizeMethod · 0.45
kindMethod · 0.45
messageMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected