Skip to content

Commit cdbc41a

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. Differential Revision: D99934624
1 parent 34529aa commit cdbc41a

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
@@ -323,6 +323,46 @@ def test_add_conv_residual_u85_INT(test_data: input_t1):
323323
pipeline.run()
324324

325325

326+
class AddDualConv(torch.nn.Module):
327+
"""Conv1(x) + conv2(x) — both inputs have Rescale producers."""
328+
329+
def __init__(self):
330+
super().__init__()
331+
self.conv1 = torch.nn.Conv2d(3, 3, 1, bias=False)
332+
self.conv2 = torch.nn.Conv2d(3, 3, 1, bias=False)
333+
334+
def forward(self, x):
335+
return self.conv1(x) + self.conv2(x)
336+
337+
test_data = {
338+
"4d_randn": lambda: (torch.randn(1, 3, 4, 4),),
339+
}
340+
341+
342+
@common.parametrize("test_data", AddDualConv.test_data)
343+
def test_add_dual_conv_tosa_INT(test_data: input_t1):
344+
pipeline = TosaPipelineINT[input_t1](AddDualConv(), test_data(), aten_op, exir_op)
345+
pipeline.run()
346+
347+
348+
@common.parametrize("test_data", AddDualConv.test_data)
349+
@common.XfailIfNoCorstone300
350+
def test_add_dual_conv_u55_INT(test_data: input_t1):
351+
pipeline = EthosU55PipelineINT[input_t1](
352+
AddDualConv(), test_data(), aten_op, exir_op
353+
)
354+
pipeline.run()
355+
356+
357+
@common.parametrize("test_data", AddDualConv.test_data)
358+
@common.XfailIfNoCorstone320
359+
def test_add_dual_conv_u85_INT(test_data: input_t1):
360+
pipeline = EthosU85PipelineINT[input_t1](
361+
AddDualConv(), test_data(), aten_op, exir_op
362+
)
363+
pipeline.run()
364+
365+
326366
@common.parametrize("test_data", Add.test_data)
327367
def test_add_tensor_tosa_INT_16a8w(test_data: input_t1):
328368
"""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)