Skip to content
Merged
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
21 changes: 15 additions & 6 deletions backends/arm/test/models/test_mobilenet_v2_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,28 @@
input_t = Tuple[torch.Tensor]


quant_test_data = {
"per_channel_quantization=true": True,
"per_channel_quantization=false": False,
}


def test_mv2_tosa_MI():
pipeline = TosaPipelineMI[input_t](
mv2, model_inputs, aten_op=[], exir_op=[], use_to_edge_transform_and_lower=True
)
pipeline.run()


def test_mv2_tosa_BI():
@common.parametrize("per_channel_quantization", quant_test_data)
def test_mv2_tosa_BI(per_channel_quantization):
pipeline = TosaPipelineBI[input_t](
mv2,
model_inputs,
aten_op=[],
exir_op=[],
use_to_edge_transform_and_lower=True,
per_channel_quantization=True,
per_channel_quantization=per_channel_quantization,
atol=0.25,
qtol=1,
)
Expand All @@ -55,15 +62,16 @@ def test_mv2_tosa_BI():

@pytest.mark.slow
@common.XfailIfNoCorstone300
def test_mv2_u55_BI():
@common.parametrize("per_channel_quantization", quant_test_data)
def test_mv2_u55_BI(per_channel_quantization):
pipeline = EthosU55PipelineBI[input_t](
mv2,
model_inputs,
aten_ops=[],
exir_ops=[],
run_on_fvp=True,
use_to_edge_transform_and_lower=True,
per_channel_quantization=True,
per_channel_quantization=per_channel_quantization,
atol=0.25,
qtol=1,
)
Expand All @@ -72,15 +80,16 @@ def test_mv2_u55_BI():

@pytest.mark.slow
@common.XfailIfNoCorstone320
def test_mv2_u85_BI():
@common.parametrize("per_channel_quantization", quant_test_data)
def test_mv2_u85_BI(per_channel_quantization):
pipeline = EthosU85PipelineBI[input_t](
mv2,
model_inputs,
aten_ops=[],
exir_ops=[],
run_on_fvp=True,
use_to_edge_transform_and_lower=True,
per_channel_quantization=True,
per_channel_quantization=per_channel_quantization,
atol=0.25,
qtol=1,
)
Expand Down
52 changes: 32 additions & 20 deletions backends/arm/test/ops/test_conv1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def forward(self, x):
batches=1,
)

test_modules = {
test_data_MI = {
"2_3x2x40_nobias": lambda: conv1d_2_3x2x40_nobias,
"3_1x3x256_st1": lambda: conv1d_3_1x3x256_st1,
"3_1x3x12_st2_pd1": lambda: conv1d_3_1x3x12_st2_pd1,
Expand All @@ -265,53 +265,65 @@ def forward(self, x):
"two_conv1d": lambda: two_conv1d,
}

test_data_BI = {
f"{k},per_channel_quant={q}": (lambda v=v, q=q: (v(), q))
for (k, v) in test_data_MI.items()
for q in [True, False]
}


@common.parametrize("test_module", test_modules)
def test_convolution_1d_tosa_MI(test_module):
@common.parametrize("test_data", test_data_MI)
def test_convolution_1d_tosa_MI(test_data):
pipeline = TosaPipelineMI[input_t](
test_module(),
test_module().get_inputs(),
test_data(),
test_data().get_inputs(),
aten_op,
exir_op,
)
pipeline.run()


@common.parametrize("test_module", test_modules)
def test_convolution_1d_tosa_BI(test_module):
@common.parametrize("test_data", test_data_BI)
def test_convolution_1d_tosa_BI(test_data):
model, per_channel_quantization = test_data()
pipeline = TosaPipelineBI[input_t](
test_module(),
test_module().get_inputs(),
model,
model.get_inputs(),
aten_op,
exir_op,
per_channel_quantization=per_channel_quantization,
qtol=1,
)
pipeline.change_args("run_method_and_compare_outputs", qtol=1)
pipeline.run()


@common.parametrize("test_module", test_modules)
@common.parametrize("test_data", test_data_BI)
@common.XfailIfNoCorstone300
def test_convolution_1d_u55_BI(test_module):
def test_convolution_1d_u55_BI(test_data):
model, per_channel_quantization = test_data()
pipeline = EthosU55PipelineBI[input_t](
test_module(),
test_module().get_inputs(),
model,
model.get_inputs(),
aten_op,
exir_op,
run_on_fvp=True,
per_channel_quantization=per_channel_quantization,
qtol=1,
)
pipeline.change_args("run_method_and_compare_outputs", qtol=1)
pipeline.run()


@common.parametrize("test_module", test_modules)
@common.parametrize("test_data", test_data_BI)
@common.XfailIfNoCorstone320
def test_convolution_1d_u85_BI(test_module):
def test_convolution_1d_u85_BI(test_data):
model, per_channel_quantization = test_data()
pipeline = EthosU85PipelineBI[input_t](
test_module(),
test_module().get_inputs(),
model,
model.get_inputs(),
aten_op,
exir_op,
run_on_fvp=True,
per_channel_quantization=per_channel_quantization,
qtol=1,
)
pipeline.change_args("run_method_and_compare_outputs", qtol=1)
pipeline.run()
61 changes: 41 additions & 20 deletions backends/arm/test/ops/test_conv2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def forward(self, x):

# Shenanigan to get a nicer output when test fails. With unittest it looks like:
# FAIL: test_convolution_2d_tosa_BI_2_3x3_1x3x12x12_st2_pd1
test_modules = {
test_data_MI = {
"2x2_3x2x40x40_nobias": lambda: conv2d_2x2_3x2x40x40_nobias,
"3x3_1x3x256x256_st1": lambda: conv2d_3x3_1x3x256x256_st1,
"3x3_1x3x12x12_st2_pd1": lambda: conv2d_3x3_1x3x12x12_st2_pd1,
Expand All @@ -380,58 +380,79 @@ def forward(self, x):
"groups_bias": lambda: conv2d_groups_bias,
}

# Generate a new test set paired with per_channel_quant=True/False.
test_data_BI = {
f"{k},per_channel_quant={q}": (lambda v=v, q=q: (v(), q))
for (k, v) in test_data_MI.items()
for q in [True, False]
# TODO: Invalid TOSA graph (MLETORCH-1144)
if (k not in ["groups", "groups_bias"]) and (q is True)
}

fvp_xfails = {
"2x2_3x2x40x40_nobias": "MLETORCH-520: Numerical issues on FVP.",
"5x5_3x2x128x128_st1": "MLETORCH-520: Numerical issues on FVP.",
f"{k},per_channel_quant={q}": reason
for k, reason in {
"2x2_3x2x40x40_nobias": "MLETORCH-520: Numerical issues on FVP.",
"5x5_3x2x128x128_st1": "MLETORCH-520: Numerical issues on FVP.",
}.items()
for q in [True, False]
}

input_t = Tuple[torch.Tensor]


@common.parametrize("test_module", test_modules)
def test_convolution_2d_tosa_MI(test_module):
@common.parametrize("test_data", test_data_MI)
def test_convolution_2d_tosa_MI(test_data):
model = test_data()
pipeline = TosaPipelineMI[input_t](
test_module(),
test_module().get_inputs(),
model,
model.get_inputs(),
aten_op,
exir_op,
)
pipeline.run()


@common.parametrize("test_module", test_modules)
def test_convolution_2d_tosa_BI(test_module):
@common.parametrize("test_data", test_data_BI)
def test_convolution_2d_tosa_BI(test_data):
model, per_channel_quantization = test_data()
pipeline = TosaPipelineBI[input_t](
test_module(),
test_module().get_inputs(),
model,
model.get_inputs(),
aten_op,
exir_op,
per_channel_quantization=per_channel_quantization,
qtol=1,
)
pipeline.change_args("run_method_and_compare_outputs", qtol=1)
pipeline.run()


@common.parametrize("test_module", test_modules, fvp_xfails)
@common.parametrize("test_data", test_data_BI, fvp_xfails)
@common.XfailIfNoCorstone300
def test_convolution_2d_u55_BI(test_module):
def test_convolution_2d_u55_BI(test_data):
model, per_channel_quantization = test_data()
pipeline = EthosU55PipelineBI[input_t](
test_module(),
test_module().get_inputs(),
model,
model.get_inputs(),
aten_op,
exir_op,
run_on_fvp=True,
per_channel_quantization=per_channel_quantization,
)
pipeline.run()


@common.parametrize("test_module", test_modules, fvp_xfails)
@common.parametrize("test_data", test_data_BI, fvp_xfails)
@common.XfailIfNoCorstone320
def test_convolution_2d_u85_BI(test_module):
def test_convolution_u85_BI(test_data):
model, per_channel_quantization = test_data()
pipeline = EthosU85PipelineBI[input_t](
test_module(),
test_module().get_inputs(),
model,
model.get_inputs(),
aten_op,
exir_op,
run_on_fvp=True,
per_channel_quantization=per_channel_quantization,
)
pipeline.run()

Expand Down
48 changes: 32 additions & 16 deletions backends/arm/test/ops/test_conv3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def forward(self, x):
batches=1,
)

test_modules = {
test_data_MI = {
"2x2_3x2x40x40_nobias": lambda: conv3d_2x2_3x2x40x40_nobias,
"3x3_1x3x256x256_st1": lambda: conv3d_3x3_1x3x256x256_st1,
"3x3_1x3x12x12_st2_pd1": lambda: conv3d_3x3_1x3x12x12_st2_pd1,
Expand All @@ -323,50 +323,66 @@ def forward(self, x):
"3x3_1x3x224x224_st2_pd1": lambda: conv3d_3x3_1x3x224x224_st2_pd1,
}

# Generate a new test set paired with per_channel_quant=True/False.
test_data_BI = {
f"{k},per_channel_quant={q}": (lambda v=v, q=q: (v(), q))
for (k, v) in test_data_MI.items()
for q in [True, False]
}

input_t = Tuple[torch.Tensor]


@common.parametrize("test_module", test_modules)
@common.parametrize("test_data", test_data_MI)
@pytest.mark.skip # Not implemented, skip until it is.
def test_convolution_tosa_MI_3d(test_module):
def test_convolution_3d_tosa_MI(test_data):
pipeline = TosaPipelineMI[input_t](
test_module(), test_module().get_inputs(), aten_op, exir_op
test_data(), test_data().get_inputs(), aten_op, exir_op
)
pipeline.run()


@common.parametrize("test_module", test_modules)
@common.parametrize("test_data", test_data_BI)
@pytest.mark.skip # Not implemented, skip until it is.
def test_convolution_tosa_BI_3d(test_module):
def test_convolution_3d_tosa_BI(test_data):
model, per_channel_quantization = test_data()
pipeline = TosaPipelineBI[input_t](
test_module(), test_module().get_inputs(), aten_op, exir_op
model,
model.get_inputs(),
aten_op,
exir_op,
per_channel_quantization=per_channel_quantization,
qtol=1,
)
pipeline.change_args("run_method_and_compare_outputs", qtol=1)
pipeline.run()


@common.parametrize("test_module", test_modules)
@common.parametrize("test_data", test_data_BI)
@pytest.mark.skip # Not implemented, skip until it is.
def test_convolution_u55_BI_3d(test_module):
def test_convolution_3d_u55_BI(test_data):
model, per_channel_quantization = test_data()
pipeline = EthosU55PipelineBI[input_t](
test_module(),
test_module().get_inputs(),
model,
model.get_inputs(),
aten_op,
exir_op,
run_on_fvp=True,
per_channel_quantization=per_channel_quantization,
)
pipeline.run()


@common.parametrize("test_module", test_modules)
@common.parametrize("test_data", test_data_BI)
@pytest.mark.skip # Not implemented, skip until it is.
def test_convolution_u85_BI_3d(test_module):
def test_convolution_3d_u85_BI(test_data):
model, per_channel_quantization = test_data()
pipeline = EthosU85PipelineBI[input_t](
test_module(),
test_module().get_inputs(),
model,
model.get_inputs(),
aten_op,
exir_op,
run_on_fvp=True,
per_channel_quantization=per_channel_quantization,
)
pipeline.run()

Expand Down
Loading
Loading