masahi commented on code in PR #14537: URL: https://github.com/apache/tvm/pull/14537#discussion_r1163429227
########## tests/python/relax/test_meta_schedule_relax_integration.py: ########## @@ -0,0 +1,285 @@ +# 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. +"""Integration test for MetaSchedule""" + +import numpy as np +import pytest +import tempfile +import tvm +import tvm.testing +from tvm import IRModule +from tvm import meta_schedule as ms +from tvm import relay, relax, tir +from tvm.ir import transform +from tvm.relax.testing import relay_translator + + +def get_relay_model(): + np.random.seed(0) + dtype = "int32" + deep = 4 + dshape = (1, 8, 8, deep) + data = np.random.randint( + low=np.iinfo(dtype).min, high=np.iinfo(dtype).max, size=dshape, dtype=dtype + ) + + wshape = (3, 3, deep, 1) + weight1 = np.random.randint( + low=np.iinfo(dtype).min, high=np.iinfo(dtype).max, size=wshape, dtype=dtype + ) + weight2 = np.random.randint( + low=np.iinfo(dtype).min, high=np.iinfo(dtype).max, size=wshape, dtype=dtype + ) + weight3 = np.random.randint( + low=np.iinfo(dtype).min, high=np.iinfo(dtype).max, size=wshape, dtype=dtype + ) + + a = tvm.relay.var("data", tvm.relay.TensorType(dshape, dtype)) + b1 = tvm.relay.const(weight1, dtype=dtype) + b2 = tvm.relay.const(weight2, dtype=dtype) + b3 = tvm.relay.const(weight3, dtype=dtype) + + kernel_layout = "HWOI" + + bias_w = tvm.relay.const(np.array([1] * deep), dtype="int32") + # fmt: off + expr = tvm.relay.nn.conv2d(data=a, weight=b1, kernel_size=(3,3), channels=deep, groups=deep, padding=1, data_layout="NHWC", kernel_layout="HWOI", out_layout="", out_dtype="int32") + expr = tvm.relay.nn.bias_add(expr, bias_w, axis=3) + expr = tvm.relay.nn.conv2d(data=expr, weight=b2, kernel_size=(3,3), channels=deep, groups=deep, padding=1, data_layout="NHWC", kernel_layout="HWOI", out_layout="", out_dtype="int32") + expr = tvm.relay.nn.conv2d(data=expr, weight=b3, kernel_size=(3,3), channels=deep, groups=deep, padding=1, data_layout="NHWC", kernel_layout="HWOI", out_layout="", out_dtype="int32") + # fmt: on + mod = tvm.IRModule.from_expr(expr) + executor = tvm.relay.backend.Executor("graph", {"link-params": True}) Review Comment: In general we shouldn't depend on Relay in Relax tests. And in Relax we don't have the notion of `link-params`. So can you remove relay entirely from this tests? You don't have to test `ignore-ndarray`, I think `anchor-block` is to exercise the new code path. -- 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]
