You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/arch/runtime.rst
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,7 @@ The following code block provides an example in C++
54
54
55
55
#include <tvm/runtime/packed_func.h>
56
56
57
-
void MyAdd(TVMArgs args, TVMRetValue* rv) {
57
+
void MyAdd(ffi::PackedArgs args, ffi::Any* rv) {
58
58
// automatically convert arguments to desired type.
59
59
int a = args[0].cast<int>();
60
60
int b = args[1].cast<int>();
@@ -71,8 +71,8 @@ The following code block provides an example in C++
71
71
In the above codeblock, we defined a PackedFunc MyAdd. It takes two arguments
72
72
: ``args`` represents input arguments and ``rv`` represents return value.
73
73
The function is type-erased, which means that the function signature does not restrict which input type to pass in or type to return.
74
-
Under the hood, when we call a PackedFunc, it packs the input arguments to TVMArgs on stack,
75
-
and gets the result back via TVMRetValue.
74
+
Under the hood, when we call a PackedFunc, it packs the input arguments to ffi::PackedArgs on stack,
75
+
and gets the result back via ffi::Any.
76
76
77
77
Thanks to template tricks in C++, we can call a PackedFunc just like a normal function. Because of its type-erased nature, we can call a PackedFunc from dynamic languages like python, without additional glue code for each new type function created.
78
78
The following example registers PackedFunc in C++ and calls from python.
@@ -91,7 +91,7 @@ The following example registers PackedFunc in C++ and calls from python.
91
91
# prints 3
92
92
print(myadd(1, 2))
93
93
94
-
Most of the magic of PackedFunc lies in ``TVMArgs`` and ``TVMRetValue`` structure.
94
+
Most of the magic of PackedFunc lies in ``ffi::PackedArgs`` and ``ffi::Any`` structure.
95
95
We restrict a list of possible types which can be passed.
96
96
Here are the common ones:
97
97
@@ -111,7 +111,7 @@ we can pass functions from python (as PackedFunc) to C++.
0 commit comments