Mousius commented on code in PR #12550:
URL: https://github.com/apache/tvm/pull/12550#discussion_r952669661


##########
tests/python/relay/aot/test_pass_aot_lower_main.py:
##########
@@ -0,0 +1,435 @@
+# 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
+from tvm.relay.backend.aot import AOTLowerMain, CallType
+
+import numpy as np
+import pytest
+
+
+def make_const(dtype, shape):
+    return tvm.relay.const(np.zeros(shape).astype(dtype))
+
+
+def make_consts(dtype, shapes):
+    return [make_const(dtype, shape) for shape in shapes]
+
+
+def transform(mod):
+    host_target = tvm.target.Target("llvm")
+    prim_target = tvm.target.Target("llvm", host=host_target)
+    ctxt = tvm.transform.PassContext()
+    config = tvm.target.make_compilation_config(ctxt, prim_target)
+    mod = tvm.relay.transform.PlanDevices(config)(mod)
+    mod = tvm.relay.transform.InferType()(mod)
+    if mod.get_attr("device_contexts") is None:

Review Comment:
   What's the usefulness of adding the attribute in a test and then immediately 
overwriting it in this function? 
   
   Also, it'd be clearer to have another function which can be used by the 
relevant test rather than a branch here.



##########
tests/python/relay/aot/test_pass_aot_lower_main.py:
##########
@@ -0,0 +1,435 @@
+# 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
+from tvm.relay.backend.aot import AOTLowerMain, CallType
+
+import numpy as np
+import pytest
+
+
+def make_const(dtype, shape):
+    return tvm.relay.const(np.zeros(shape).astype(dtype))
+
+
+def make_consts(dtype, shapes):
+    return [make_const(dtype, shape) for shape in shapes]
+
+
+def transform(mod):
+    host_target = tvm.target.Target("llvm")
+    prim_target = tvm.target.Target("llvm", host=host_target)
+    ctxt = tvm.transform.PassContext()
+    config = tvm.target.make_compilation_config(ctxt, prim_target)
+    mod = tvm.relay.transform.PlanDevices(config)(mod)
+    mod = tvm.relay.transform.InferType()(mod)
+    if mod.get_attr("device_contexts") is None:
+        device_contexts = {}
+        for gv in mod.get_global_vars():
+            device_contexts[gv] = "llvm"
+
+        mod = mod.with_attr("device_contexts", device_contexts)
+
+    return mod, config
+
+
+def compare(mod, main_func, call_type, print_script=False):

Review Comment:
   ```suggestion
   def _assert_lowered_main(mod, main_func, call_type, print_script=False):
   ```
   
   or something similar to make it obvious what this assertion does



##########
tests/python/relay/aot/test_pass_aot_lower_main.py:
##########
@@ -0,0 +1,435 @@
+# 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
+from tvm.relay.backend.aot import AOTLowerMain, CallType
+
+import numpy as np
+import pytest
+
+
+def make_const(dtype, shape):
+    return tvm.relay.const(np.zeros(shape).astype(dtype))
+
+
+def make_consts(dtype, shapes):
+    return [make_const(dtype, shape) for shape in shapes]
+
+
+def transform(mod):

Review Comment:
   ```suggestion
   def _lower_main(mod):
   ```



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