Mousius commented on code in PR #12550: URL: https://github.com/apache/tvm/pull/12550#discussion_r953767352
########## 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: The second option is clearer but the information will still need to be threaded from `LowerTE` to `LowerMain` due to the first pass producing a new `IRModule` without any way of providing the device information (which makes sense given the `IRModule` is meant to contain all this information). Maybe you could also re-scan the `main` function within AOT to re-create the device contexts rather than using attributes? -- 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]
