Skip to content

Commit 5be34f4

Browse files
3l1facebook-github-bot
authored andcommitted
Add dual-conv tests for add/sub dual-input ifm scaling (#18755)
Summary: Add AddDualConv and SubDualConv test models (conv1(x) +/- conv2(x)) where both inputs of the Add/Sub have Rescale producers. bypass-github-export-checks bypass-github-pytorch-ci-checks bypass-github-executorch-ci-checks Reviewed By: digantdesai Differential Revision: D99934624
1 parent 7e099b4 commit 5be34f4

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

backends/arm/test/ops/test_add.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,46 @@ def test_add_conv_residual_u85_INT(test_data: input_t1):
339339
pipeline.run()
340340

341341

342+
class AddDualConv(torch.nn.Module):
343+
"""Conv1(x) + conv2(x) — both inputs have Rescale producers."""
344+
345+
def __init__(self):
346+
super().__init__()
347+
self.conv1 = torch.nn.Conv2d(3, 3, 1, bias=False)
348+
self.conv2 = torch.nn.Conv2d(3, 3, 1, bias=False)
349+
350+
def forward(self, x):
351+
return self.conv1(x) + self.conv2(x)
352+
353+
test_data = {
354+
"4d_randn": lambda: (torch.randn(1, 3, 4, 4),),
355+
}
356+
357+
358+
@common.parametrize("test_data", AddDualConv.test_data)
359+
def test_add_dual_conv_tosa_INT(test_data: input_t1):
360+
pipeline = TosaPipelineINT[input_t1](AddDualConv(), test_data(), aten_op, exir_op)
361+
pipeline.run()
362+
363+
364+
@common.parametrize("test_data", AddDualConv.test_data)
365+
@common.XfailIfNoCorstone300
366+
def test_add_dual_conv_u55_INT(test_data: input_t1):
367+
pipeline = EthosU55PipelineINT[input_t1](
368+
AddDualConv(), test_data(), aten_op, exir_op
369+
)
370+
pipeline.run()
371+
372+
373+
@common.parametrize("test_data", AddDualConv.test_data)
374+
@common.XfailIfNoCorstone320
375+
def test_add_dual_conv_u85_INT(test_data: input_t1):
376+
pipeline = EthosU85PipelineINT[input_t1](
377+
AddDualConv(), test_data(), aten_op, exir_op
378+
)
379+
pipeline.run()
380+
381+
342382
@common.parametrize("test_data", Add.test_data)
343383
def test_add_tensor_tosa_INT_16a8w(test_data: input_t1):
344384
"""Test add operation with 16A8W quantization (16-bit activations, 8-bit

backends/arm/test/ops/test_sub.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,46 @@ def test_sub_conv_residual_u85_INT(test_data: input_t1):
354354
pipeline.run()
355355

356356

357+
class SubDualConv(torch.nn.Module):
358+
"""conv1(x) - conv2(x) — both inputs have Rescale producers."""
359+
360+
def __init__(self):
361+
super().__init__()
362+
self.conv1 = torch.nn.Conv2d(3, 3, 1, bias=False)
363+
self.conv2 = torch.nn.Conv2d(3, 3, 1, bias=False)
364+
365+
def forward(self, x):
366+
return self.conv1(x) - self.conv2(x)
367+
368+
test_data = {
369+
"4d_randn": lambda: (torch.randn(1, 3, 4, 4),),
370+
}
371+
372+
373+
@common.parametrize("test_data", SubDualConv.test_data)
374+
def test_sub_dual_conv_tosa_INT(test_data: input_t1):
375+
pipeline = TosaPipelineINT[input_t1](SubDualConv(), test_data(), aten_op, exir_op)
376+
pipeline.run()
377+
378+
379+
@common.parametrize("test_data", SubDualConv.test_data)
380+
@common.XfailIfNoCorstone300
381+
def test_sub_dual_conv_u55_INT(test_data: input_t1):
382+
pipeline = EthosU55PipelineINT[input_t1](
383+
SubDualConv(), test_data(), aten_op, exir_op
384+
)
385+
pipeline.run()
386+
387+
388+
@common.parametrize("test_data", SubDualConv.test_data)
389+
@common.XfailIfNoCorstone320
390+
def test_sub_dual_conv_u85_INT(test_data: input_t1):
391+
pipeline = EthosU85PipelineINT[input_t1](
392+
SubDualConv(), test_data(), aten_op, exir_op
393+
)
394+
pipeline.run()
395+
396+
357397
@common.parametrize("test_data", sub_test_data)
358398
def test_sub_tensor_16a8w_tosa_INT(test_data: input_t1):
359399
"""Test sub operation with 16A8W quantization (16-bit activations, 8-bit

0 commit comments

Comments
 (0)