Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ArmTester logging #5629

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backends/arm/test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

import logging
import os
import shutil
import subprocess
import sys
import tempfile

import pytest
Expand Down Expand Up @@ -37,6 +39,7 @@ def pytest_configure(config):
"Tests are run with --arm_run_corstone300 but corstone300 FVP is not installed."
)
_enabled_options.append("corstone300")
logging.basicConfig(level=logging.INFO, stream=sys.stdout)


def pytest_collection_modifyitems(config, items):
Expand Down
105 changes: 83 additions & 22 deletions backends/arm/test/misc/test_debug_feats.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,29 +127,52 @@ def test_numerical_diff_prints(self):
self.fail()


class TestDumpOperatorsAndDtypes(unittest.TestCase):
def test_dump_ops_and_dtypes(self):
model = Linear(20, 30)
(
ArmTester(
model,
example_inputs=model.get_inputs(),
compile_spec=common.get_tosa_compile_spec(),
)
.quantize()
.dump_dtype_distribution()
.dump_operator_distribution()
.export()
.dump_dtype_distribution()
.dump_operator_distribution()
.to_edge()
.dump_dtype_distribution()
.dump_operator_distribution()
.partition()
.dump_dtype_distribution()
.dump_operator_distribution()
def test_dump_ops_and_dtypes():
model = Linear(20, 30)
(
ArmTester(
model,
example_inputs=model.get_inputs(),
compile_spec=common.get_tosa_compile_spec(),
)
.quantize()
.dump_dtype_distribution()
.dump_operator_distribution()
.export()
.dump_dtype_distribution()
.dump_operator_distribution()
.to_edge()
.dump_dtype_distribution()
.dump_operator_distribution()
.partition()
.dump_dtype_distribution()
.dump_operator_distribution()
)
# Just test that there are no execptions.


def test_dump_ops_and_dtypes_parseable():
model = Linear(20, 30)
(
ArmTester(
model,
example_inputs=model.get_inputs(),
compile_spec=common.get_tosa_compile_spec(),
)
# Just test that there are no execeptions.
.quantize()
.dump_dtype_distribution(print_table=False)
.dump_operator_distribution(print_table=False)
.export()
.dump_dtype_distribution(print_table=False)
.dump_operator_distribution(print_table=False)
.to_edge()
.dump_dtype_distribution(print_table=False)
.dump_operator_distribution(print_table=False)
.partition()
.dump_dtype_distribution(print_table=False)
.dump_operator_distribution(print_table=False)
)
# Just test that there are no execptions.


class TestCollateTosaTests(unittest.TestCase):
Expand Down Expand Up @@ -186,3 +209,41 @@ def test_collate_tosa_BI_tests(self):

os.environ.pop("TOSA_TESTCASES_BASE_PATH")
shutil.rmtree("test_collate_tosa_tests", ignore_errors=True)


def test_dump_tosa_ops(caplog):
caplog.set_level(logging.INFO)
model = Linear(20, 30)
(
ArmTester(
model,
example_inputs=model.get_inputs(),
compile_spec=common.get_tosa_compile_spec(),
)
.quantize()
.export()
.to_edge()
.partition()
.dump_operator_distribution()
)
assert "TOSA operators:" in caplog.text


def test_fail_dump_tosa_ops(caplog):
caplog.set_level(logging.INFO)

class Add(torch.nn.Module):
def forward(self, x):
return x + x

model = Add()
compile_spec = common.get_u55_compile_spec()
(
ArmTester(model, example_inputs=(torch.ones(5),), compile_spec=compile_spec)
.quantize()
.export()
.to_edge()
.partition()
.dump_operator_distribution()
)
assert "Can not get operator distribution for Vela command stream." in caplog.text
Loading
Loading