You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/08/30 14:49:08 UTC

[GitHub] [tvm] sunggg commented on a diff in pull request #12628: [MetaSchedule] Introduce `MergedDatabase`

sunggg commented on code in PR #12628:
URL: https://github.com/apache/tvm/pull/12628#discussion_r958581651


##########
python/tvm/meta_schedule/database/merged_database.py:
##########
@@ -0,0 +1,94 @@
+# 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.
+"""A database consists of multiple databases."""
+from typing import List, Union
+
+from tvm._ffi import register_object
+
+from .. import _ffi_api
+from .database import Database
+
+
+@register_object("meta_schedule.MergedDatabase")
+class MergedDatabase(Database):
+    """A database composed of multiple databases, allowing users to guide IR rewriting using
+    combined knowledge of those databases.
+
+    Besides querying from all databases and picking the best running time, this database also
+    comes with two extra sets of databases:
+    - preferred: If the preferred database responds to a query, all responses of other databases
+    will be overridden and ignored.
+    - fallback: If all databases don't respond to a query, the fallback databases will be used.
+
+    Examples
+    --------
+    An example of using the merged database:
+
+    .. code-block:: python
+    def schedule_conv2d(sch: tir.Schedule) -> bool:
+        if "nn_conv2d" in sch.mod.attrs["task_name"]:
+            handcrafted_scheduling(sch)
+            return True
+        return False
+
+    with ms.database.MergedDatabase(
+        preferred=ScheduleFnDatabase(schedule_conv2d),          # override schedule for conv2d
+        databases=[existing_db0, existing_db1, existing_db2],   # use existing databases
+        fallback=libtorch,                                      # fallback to libtorch

Review Comment:
   Would you elaborate a little more in the comment about database for `libtorch`?
   What kind of data entry does it have? Does it also contain MetaSchedule trace and its performance? 



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org