tqchen commented on code in PR #266:
URL: https://github.com/apache/tvm-ffi/pull/266#discussion_r2531919433
##########
include/tvm/ffi/function.h:
##########
@@ -145,14 +146,22 @@ namespace details {
template <typename TCallable>
Review Comment:
document: Invariance: TCallable cannot be reference
##########
include/tvm/ffi/function.h:
##########
@@ -611,11 +621,10 @@ class Function : public ObjectRef {
* \param packed_call The packed function signature
*/
template <typename TCallable>
- static Function FromPackedInternal(TCallable packed_call) {
- using ObjType = typename details::FunctionObjImpl<TCallable>;
+ static Function FromPackedInternal(TCallable&& packed_call) {
+ using ObjType = typename details::FunctionObjImpl<std::decay_t<TCallable>>;
Review Comment:
document: need to make sure we create ObjectType that do not come with
references
##########
include/tvm/ffi/function.h:
##########
@@ -487,10 +497,10 @@ class Function : public ObjectRef {
* \param callable the internal container of packed function.
*/
template <typename TCallable>
- static Function FromTyped(TCallable callable) {
- using FuncInfo = details::FunctionInfo<TCallable>;
- auto call_packed = [callable = std::move(callable)](const AnyView* args,
int32_t num_args,
- Any* rv) mutable ->
void {
+ static Function FromTyped(TCallable&& callable) {
+ using FuncInfo = details::FunctionInfo<std::decay_t<TCallable>>;
+ auto call_packed = [callable = std::forward<TCallable>(callable)](
Review Comment:
what happens if TCallable here is a const reference? will the captured
callable being a constant ref? Where is FuncInfo being used here
##########
include/tvm/ffi/function.h:
##########
@@ -145,14 +146,22 @@ namespace details {
template <typename TCallable>
class FunctionObjImpl : public FunctionObj {
public:
- using TStorage = std::remove_cv_t<std::remove_reference_t<TCallable>>;
Review Comment:
I see, in this case, would be useful to add a static assert here to indicate
it is not cv ref (for maintainability). As well as a document
##########
include/tvm/ffi/function.h:
##########
@@ -503,9 +513,9 @@ class Function : public ObjectRef {
* \param name optional name attacked to the function.
*/
template <typename TCallable>
- static Function FromTyped(TCallable callable, std::string name) {
- using FuncInfo = details::FunctionInfo<TCallable>;
- auto call_packed = [callable = std::move(callable), name =
std::move(name)](
+ static Function FromTyped(TCallable&& callable, std::string name) {
+ using FuncInfo = details::FunctionInfo<std::decay_t<TCallable>>;
+ auto call_packed = [callable = std::forward<TCallable>(callable), name =
std::move(name)](
Review Comment:
what happens if TCallable here is a const reference? will the captured
callable being a constant ref? Where is FuncInfo being used here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]