tkonolige commented on a change in pull request #8110:
URL: https://github.com/apache/tvm/pull/8110#discussion_r647013617



##########
File path: src/driver/driver_api.cc
##########
@@ -109,6 +109,52 @@ void GetBinds(const Array<te::Tensor>& args, bool compact,
   }
 }
 
+void GetBinds(const Array<ObjectRef>& args, bool compact,
+              const std::unordered_map<te::Tensor, tir::Buffer>& binds,
+              Map<te::Tensor, tir::Buffer>* out_binds, Array<ObjectRef>* 
out_arg_list) {
+  *out_binds = binds;
+
+  for (const ObjectRef& x : args) {
+    if (const auto* tensor_node = x.as<te::TensorNode>()) {
+      auto x_ref = GetRef<te::Tensor>(tensor_node);
+      if (out_binds->find(x_ref) == out_binds->end()) {
+        auto buf =
+            BufferWithOffsetAlignment(x_ref->shape, x_ref->dtype, 
x_ref->op->name, -1, 0, compact);
+        out_binds->Set(x_ref, buf);
+        out_arg_list->push_back(buf);
+      } else {
+        out_arg_list->push_back((*out_binds)[x_ref]);
+      }
+    } else if (x.as<te::BufferNode>() || x.as<tir::VarNode>()) {
+      out_arg_list->push_back(x);
+    } else {
+      LOG(FATAL)
+          << "Expected type of the elements of args to be te::Tensor, 
te::Buffer or tir::Var, "
+          << "but got a " << typeid(x).name();

Review comment:
       ```suggestion
             << "but got a " << x->GetTypeKey();
   ```
   `GetTypeKey` has a confusing name but it is what you want.

##########
File path: python/tvm/driver/build_module.py
##########
@@ -136,7 +98,7 @@ def lower(
 
     Parameters
     ----------
-    input : Union[schedule.Schedule, PrimFunc, IRModule]
+    inputs : Union[schedule.Schedule, PrimFunc, IRModule]

Review comment:
       Maybe use `inp` instead? I can't really think of a good name either.

##########
File path: include/tvm/driver/driver_api.h
##########
@@ -42,17 +43,64 @@
 #include <vector>
 
 namespace tvm {
+
+/*!
+ * \brief Build an IRModule given a module, args and binds
+ * \param mod The IRmodule to lower
+ * \param simple_mode Disables the loop partition pass. Defaults to false.
+ * \return The result module.
+ */
+TVM_DLL IRModule LowerModule(IRModule mod, bool simple_mode = false);
+
+/*!
+ * \brief Build an IRModule given a module, args and binds
+ * \param func The PrimFunc to lower
+ * \param name The name of the lowered function.
+ * \param simple_mode Disables the loop partition pass. Defaults to false.
+ * \return The result module.
+ */
+TVM_DLL IRModule LowerPrimFunc(tvm::tir::PrimFunc func, const std::string& 
name,
+                               bool simple_mode = false);
+
 /*!
  * \brief Build an IRModule given a schedule, args and binds
  * \param sch The schedule to lower.
  * \param args The arguments to the function.
  * \param name The name of the lowered function.
  * \param binds Buffer assignments.
+ * \param simple_mode Disables the loop partition pass. Defaults to false.
  * \return The result module.
  */
-TVM_DLL IRModule lower(te::Schedule sch, const Array<te::Tensor>& args, const 
std::string& name,
-                       const std::unordered_map<te::Tensor, tir::Buffer>& 
binds);
 
+TVM_DLL IRModule LowerSchedule(te::Schedule sch, const Array<te::Tensor>& args,
+                               const std::string& name,
+                               const std::unordered_map<te::Tensor, 
tir::Buffer>& binds,
+                               bool simple_mode = false);
+
+/*!
+ * \brief Build an IRModule given a schedule, args and binds
+ * \param sch The schedule to lower.
+ * \param args The arguments to the function (Array of Union of Tensor, Buffer 
and Vars)
+ * \param name The name of the lowered function.
+ * \param binds Buffer assignments.
+ * \param simple_mode Disables the loop partition pass. Defaults to false.
+ * \return The result module.
+ */
+TVM_DLL IRModule LowerSchedule(te::Schedule sch, const Array<ObjectRef>& args,
+                               const std::string& name,
+                               const std::unordered_map<te::Tensor, 
tir::Buffer>& binds,
+                               bool simple_mode = false);
+
+/*!
+ * \brief Create an IRModule out of a Schedule
+ * \param sch The schedule
+ * \param args The arguments to the function.
+ * \param name The name of the lowered function.
+ * \param binds Buffer assignments.
+ * \return The result module.
+ */
+IRModule ScheduleToModule(te::Schedule sch, const Array<ObjectRef>& args, 
const std::string& name,

Review comment:
       Can you be a little more explicit about this in the documentation?

##########
File path: include/tvm/driver/driver_api.h
##########
@@ -42,17 +43,64 @@
 #include <vector>
 
 namespace tvm {
+
+/*!
+ * \brief Build an IRModule given a module, args and binds
+ * \param mod The IRmodule to lower
+ * \param simple_mode Disables the loop partition pass. Defaults to false.
+ * \return The result module.
+ */
+TVM_DLL IRModule LowerModule(IRModule mod, bool simple_mode = false);
+
+/*!
+ * \brief Build an IRModule given a module, args and binds
+ * \param func The PrimFunc to lower
+ * \param name The name of the lowered function.
+ * \param simple_mode Disables the loop partition pass. Defaults to false.
+ * \return The result module.
+ */
+TVM_DLL IRModule LowerPrimFunc(tvm::tir::PrimFunc func, const std::string& 
name,
+                               bool simple_mode = false);
+
 /*!
  * \brief Build an IRModule given a schedule, args and binds
  * \param sch The schedule to lower.
  * \param args The arguments to the function.
  * \param name The name of the lowered function.
  * \param binds Buffer assignments.
+ * \param simple_mode Disables the loop partition pass. Defaults to false.

Review comment:
       It is probably fine for now.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to