Skip to content

Commit

Permalink
[Pylint] Pylint integration_tests folder (apache#11672)
Browse files Browse the repository at this point in the history
* add folder to pylint

* add init py

* lint test_arm_mrpofile_dsp.py

* one more change to tests/python/integratoin/test_arm_mprofile_dsp.py

* add test_dot

* test_ewise_fpga.py

* test_ewise.py

* test gemm

* test_lower.py

* test_meta_schedule_auto_tensorize.py

* test_reduce.py pt1

* test_reduce.py pt2

* test_scan.py

* test_tuning.py

* test_winograd_nnpack.py

* final test pass

* comments

* clean up test_lower more
  • Loading branch information
AndrewZhaoLuo authored and masahi committed Jul 15, 2022
1 parent 2a6919f commit da59431
Show file tree
Hide file tree
Showing 13 changed files with 1,089 additions and 770 deletions.
1 change: 1 addition & 0 deletions tests/lint/pylint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ python3 -m pylint tests/python/unittest/test_tvmscript_type.py --rcfile="$(dirna
python3 -m pylint tests/python/contrib/test_cmsisnn --rcfile="$(dirname "$0")"/pylintrc
python3 -m pylint tests/python/relay/aot/*.py --rcfile="$(dirname "$0")"/pylintrc
python3 -m pylint tests/python/ci --rcfile="$(dirname "$0")"/pylintrc
python3 -m pylint tests/python/integration/ --rcfile="$(dirname "$0")"/pylintrc
17 changes: 17 additions & 0 deletions tests/python/integration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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.
"""Infrastructure and tests for e2e integration tests."""
10 changes: 5 additions & 5 deletions tests/python/integration/test_arm_mprofile_dsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import sys
"""Test arm mprofile dsp."""
import numpy as np
import pytest
import tvm
Expand Down Expand Up @@ -173,16 +173,16 @@ def test_conv1d(data_shape_nwc, kernel_size, num_filter, strides, padding, dtype

@tvm.testing.requires_corstone300
@pytest.mark.parametrize(
"M, K, N",
"dim_m, dim_k, dim_n",
[
(1, 32, 64),
(3, 12, 10),
],
)
def test_dense(M, K, N):
def test_dense(dim_m, dim_k, dim_n):
"""Test a subgraph with a single dense operator."""
ishape = (M, K)
wshape = (N, K)
ishape = (dim_m, dim_k)
wshape = (dim_n, dim_k)

input0 = relay.var("input", relay.TensorType(ishape, "int8"))
dense_f = relay.op.nn.batch_flatten(input0)
Expand Down
43 changes: 29 additions & 14 deletions tests/python/integration/test_dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,46 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""Test scheduling and running a dot product."""
import numpy as np

import tvm
import tvm.testing
from tvm import te
import numpy as np


@tvm.testing.requires_llvm
def test_dot():
nn = 12
n = tvm.runtime.convert(nn)
A = te.placeholder((n,), name="A")
B = te.placeholder((n,), name="B")
k = te.reduce_axis((0, n), "k")
C = te.compute((), lambda: te.sum(A[k] * B[k], axis=k), name="C")
s = te.create_schedule(C.op)
"""Test dot product."""
arr_length = 12
arr_length_tvm = tvm.runtime.convert(arr_length)
placeholder_a = te.placeholder((arr_length_tvm,), name="A")
placeholder_b = te.placeholder((arr_length_tvm,), name="B")
reduce_axis_k = te.reduce_axis((0, arr_length_tvm), "k")
result_c = te.compute(
(),
lambda: te.sum(
placeholder_a[reduce_axis_k] * placeholder_b[reduce_axis_k], axis=reduce_axis_k
),
name="C",
)
schedule = te.create_schedule(result_c.op)

def verify(target):
f = tvm.driver.build(s, [A, B, C], target)
f = tvm.driver.build(schedule, [placeholder_a, placeholder_b, result_c], target)
# verify
dev = tvm.cpu(0)
a = tvm.nd.array(np.random.uniform(size=(nn,)).astype(A.dtype), dev)
b = tvm.nd.array(np.random.uniform(size=(nn,)).astype(B.dtype), dev)
c = tvm.nd.array(np.zeros((), dtype=C.dtype), dev)
f(a, b, c)
tvm.testing.assert_allclose(c.numpy(), np.dot(a.numpy(), b.numpy()), rtol=1e-4)
buff_a = tvm.nd.array(
np.random.uniform(size=(arr_length,)).astype(placeholder_a.dtype), dev
)
buff_b = tvm.nd.array(
np.random.uniform(size=(arr_length,)).astype(placeholder_b.dtype), dev
)
buff_c = tvm.nd.array(np.zeros((), dtype=result_c.dtype), dev)
f(buff_a, buff_b, buff_c)
tvm.testing.assert_allclose(
buff_c.numpy(), np.dot(buff_a.numpy(), buff_b.numpy()), rtol=1e-4
)

verify("llvm")

Expand Down
Loading

0 comments on commit da59431

Please sign in to comment.