junrushao1994 commented on a change in pull request #10031:
URL: https://github.com/apache/tvm/pull/10031#discussion_r790195803



##########
File path: include/tvm/runtime/packed_func.h
##########
@@ -57,6 +57,73 @@ class TVMMovableArgValueWithContext_;
 class TVMRetValue;
 class TVMArgsSetter;
 
+/*!
+ * \brief Object container class that backs PackedFunc.
+ * \note Do not use this function directly, use PackedFunc.
+ */
+class PackedFuncObj : public Object {
+ public:
+  /*!
+   * \brief Call the function in packed format.
+   * \param args The arguments
+   * \param rv The return value.
+   */
+  inline void CallPacked(TVMArgs args, TVMRetValue* rv) const;
+  
+  /*! \return Whether the packed function is nullptr */
+  bool operator==(std::nullptr_t null) const { return f_call_ == nullptr; }
+  /*! \return Whether the packed function is not nullptr */
+  bool operator!=(std::nullptr_t null) const { return f_call_ != nullptr; }
+
+  static constexpr const char* _type_key = "PackedFuncObj";
+  TVM_DECLARE_FINAL_OBJECT_INFO(PackedFuncObj, Object);
+
+ protected:
+  /*!
+  * \brief Internal struct for extracting the callable method from callable 
type.
+  */
+  template <class TPackedFuncSubObj>
+  struct Extractor {
+    /*! 
+     * \brief extracting the callable method from callable type. 
+     * \param obj The base packed function object class.
+     * \param args The arguments
+     * \param rv The return value.
+     */
+    static void Call(const PackedFuncObj* obj, TVMArgs args, TVMRetValue* rv);
+  };
+
+  /*! \brief The internal callable function type. */
+  using FCall = void(const PackedFuncObj*, TVMArgs, TVMRetValue*);
+  
+  /*!
+   * \brief Constructing a packed function object from a function pointer.
+   * \param f_call The function pointer used to call the packed function.
+   */
+  explicit PackedFuncObj(FCall* f_call) : f_call_(f_call) {}
+
+  /*! \brief Internal callable function pointer used to call the packed 
function. */
+  FCall* f_call_;

Review comment:
       nit
   
   ```suggestion
     FCallPacked* f_call_packed_;
   ```




-- 
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]


Reply via email to