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/09/26 17:24:12 UTC

[GitHub] [tvm] cconvey commented on a diff in pull request #12794: [TIR] add unit-tests for upcoming primfunc-slicing

cconvey commented on code in PR #12794:
URL: https://github.com/apache/tvm/pull/12794#discussion_r980317496


##########
tests/python/unittest/test_slice_tir.py:
##########
@@ -0,0 +1,178 @@
+# 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.
+
+import tvm
+import tvm.testing
+from tvm.script import tir as T
+import pytest
+
+
+# ABOUT THIS FILE:
+# We (cconvey / OctoML) are working on a sequence of PRs to allow a single TIR primfunc's
+# AST to be sliced into multiple partitiones, where each partition will be converted into
+# a new TIR primfunc. (See https://en.wikipedia.org/wiki/Program_slicing).
+#
+# The unit tests below provide a roadmap for that sequence of PRs; each PR should allow
+# one more of these tests to pass.
+#
+# NOTE: These unit tests may change as work progresses.  They aren't meant to
+# indicate hard requirements.
+
+# NOTE! The `tvm.testing.CompareBeforeAfter` class provides TWO useful mechanisms for
+# these tests:
+#
+# (a) It lets us specify code snippets which are valid Python, but which aren't YET
+#     recognized as valid TVMScript.  This allows unit tests for new constructs,
+#     e.g. 'call_tir(...)' to simply be disabled rather than fully commented out.
+#
+# (b) It lets us structurally compare the TIR bodies of two primfuncs.
+#
+#     Note that some of the tests below will require the structural comparison of
+#     two entire IRModules, not just primfuncs.  This will require adding functionality
+#     to the `CompareBeforeAfter` class, or implementing that level of comparison within
+#     the individual unit tests.
+#
+# Some of the unit tests below which require whole-IRModule comparison.  For expedience
+# we simply comment out the (early draft) bodies of those unit tests, rather than
+# hacking their structure to get the benefits of (a).
+
+
+# step 1: that vvvv simple passes Python / TVMScript parsing.
+#
+#   The only requirement for this test is that the TVMScript parser
+#   doesn't raise an error when encountering `T.call_tir(foo)`,
+#   where "foo" is a syntactically valid TVMScript function name.
+#
+#   NOTE! The role of this unit test should evolve as follows:
+#   1) Initially the test should fail, because we haven't yet changed the TVMScript
+#      parser to support 'call_tir'.

Review Comment:
   100% agree that the name `call_tir` should be revisited, but IMHO we should answer a few more questions before picking the name.  (E.g., are we _sure_ this is any different from `call_external` once the callee has been extracted?)
   
   Would it be okay for now to just add a clarifying comment?



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