comaniac commented on a change in pull request #9382:
URL: https://github.com/apache/tvm/pull/9382#discussion_r743044703



##########
File path: include/tvm/meta_schedule/integration.h
##########
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#ifndef TVM_META_SCHEDULE_INTEGRATION_H_
+#define TVM_META_SCHEDULE_INTEGRATION_H_
+
+#include <tvm/meta_schedule/database.h>
+#include <tvm/support/with.h>
+
+#include <unordered_set>
+
+namespace tvm {
+namespace meta_schedule {
+
+/**************** ExtractedTask ****************/
+
+/*!
+ * \brief A tuning task extracted from the high-level IR
+ */
+class ExtractedTaskNode : public runtime::Object {
+ public:
+  /*! \brief The name of the task extracted */
+  String task_name;
+  /*! \brief The high-level IR */
+  IRModule mod;
+  /*! \brief A list of low-level IRs that the high-level IR could potentially 
dispatch to */
+  Array<IRModule> dispatched;
+
+  void VisitAttrs(AttrVisitor* v) {
+    v->Visit("task_name", &task_name);
+    v->Visit("mod", &mod);
+    v->Visit("dispatched", &dispatched);
+  }
+
+  static constexpr const char* _type_key = "meta_schedule.ExtractedTask";
+  TVM_DECLARE_FINAL_OBJECT_INFO(ExtractedTaskNode, runtime::Object);
+};
+
+/*!
+ * \brief Managed reference to ExtractedTaskNode
+ * \sa ExtractedTaskNode
+ */
+class ExtractedTask : public runtime::ObjectRef {
+ public:
+  /*!
+   * \brief Constructor. The name of the task extracted
+   * \brief The high-level IR
+   * \brief A list of low-level IRs that the high-level IR could potentially 
dispatch to
+   */
+  explicit ExtractedTask(String task_name, IRModule mod, Array<IRModule> 
dispatched);
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(ExtractedTask, runtime::ObjectRef, 
ExtractedTaskNode);
+};
+
+/**************** MetaScheduleContext ****************/
+
+/*!
+ * \brief A context manager interface for the integration
+ */
+class MetaScheduleContextNode : public runtime::Object {
+ public:
+  /*! \brief Default destructor */
+  virtual ~MetaScheduleContextNode() = default;
+  /*!
+   * \brief The entry point of the integration
+   * \param task_name The name of the task
+   * \param mod The high-level IR
+   * \param dispatched A list of low-level IRs that the high-level IR could 
potentially dispatch to.
+   * NullOpt means the dispatch needs to be done in the context.
+   * \return There are different types of the output
+   * 1) NullOpt if there is no feedback hint
+   * 2) tir::PrimFunc if `mod` should be lowered to a PrimFunc
+   * 3) relay::Function if `mod` should be dispatched to BYOC workflow
+   * 4) IRModule for unified dispatch
+   */
+  virtual Optional<ObjectRef> Query(runtime::String task_name, IRModule mod,
+                                    Optional<Array<IRModule>> dispatched) = 0;
+
+  static constexpr const char* _type_key = "meta_schedule.MetaScheduleContext";
+  TVM_DECLARE_BASE_OBJECT_INFO(MetaScheduleContextNode, runtime::Object);
+};
+
+/*!
+ * \brief Managed reference to MetaScheduleContextNode
+ * \sa MetaScheduleContextNode
+ */
+class MetaScheduleContext : public runtime::ObjectRef {
+  friend class MetaScheduleContextInternal;
+  friend class With<MetaScheduleContext>;
+
+ public:
+  /*! \brief Default destructor */
+  virtual ~MetaScheduleContext() = default;
+  /*!
+   * \brief The context manager in the current scope
+   * \return The MetaScheduleContext in the current scope. NullOpt if it's 
currently not under any
+   * MetaScheduleContext.
+   */
+  static Optional<MetaScheduleContext> Current();
+  /*!
+   * \brief The entry point of the integration workflow. The compilation 
process of the high-level
+   * IR should call this method for task extraction and for feedback hints
+   * \param task_name The name of the task
+   * \param mod The high-level IR
+   * \param dispatched A list of low-level IRs that the high-level IR could 
potentially dispatch to
+   * \return There are different types of the output
+   * 1) NullOpt if there is no feedback hint
+   * 2) tir::PrimFunc if `mod` should be lowered to a PrimFunc
+   * 3) relay::Function if `mod` should be dispatched to BYOC workflow
+   * 4) IRModule for unified dispatch
+   */
+  static Optional<ObjectRef> QueryInWithScope(runtime::String task_name, 
IRModule mod,
+                                              Optional<Array<IRModule>> 
dispatched);

Review comment:
       This name sounds a bit redundant. `QueryInScope` or `QueryWithScope` may 
be better, but this is just a nit.




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