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


##########
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:
   I found your TODO for this haha 
https://github.com/apache/tvm/blob/a0fe74b3c3608929b21faeaea422ac09aa2f75eb/src/relay/backend/te_compiler.cc#L1230-L1231
   
   It looks like some destructive lowering takes place in `LowerTE` removing 
`kCompiler` attrs that are otherwise saved into this data structure. One option 
would be to have a 'device_context' attr defined for each PrimFunc (which I 
consider a lesser sin that IRModule level attrs).



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