Skip to content
Open
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
131 changes: 131 additions & 0 deletions backends/arm/test/ops/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,137 @@ def test_add_tensor_vgf_quant(test_data: input_t1):
pipeline.run()


class AddConvResidual(torch.nn.Module):
"""Conv(x) + x — residual block.

Creates non-unit IFM scales

"""

def __init__(self):
super().__init__()
self.conv = torch.nn.Conv2d(3, 3, 1, bias=False)

def forward(self, x):
return self.conv(x) + x

test_data = {
"4d_randn": lambda: (torch.randn(1, 3, 4, 4),),
}


@common.parametrize("test_data", AddConvResidual.test_data)
def test_add_conv_residual_tosa_INT(test_data: input_t1):
pipeline = TosaPipelineINT[input_t1](
AddConvResidual(), test_data(), aten_op, exir_op
)
pipeline.run()


@common.parametrize("test_data", AddConvResidual.test_data)
@common.XfailIfNoCorstone300
def test_add_conv_residual_u55_INT(test_data: input_t1):
pipeline = EthosU55PipelineINT[input_t1](
AddConvResidual(), test_data(), aten_op, exir_op
)
pipeline.run()


@common.parametrize("test_data", AddConvResidual.test_data)
@common.XfailIfNoCorstone320
def test_add_conv_residual_u85_INT(test_data: input_t1):
pipeline = EthosU85PipelineINT[input_t1](
AddConvResidual(), test_data(), aten_op, exir_op
)
pipeline.run()


class AddDualConv(torch.nn.Module):
"""Conv1(x) + conv2(x) — both inputs have Rescale producers."""

def __init__(self):
super().__init__()
self.conv1 = torch.nn.Conv2d(3, 3, 1, bias=False)
self.conv2 = torch.nn.Conv2d(3, 3, 1, bias=False)

def forward(self, x):
return self.conv1(x) + self.conv2(x)

test_data = {
"4d_randn": lambda: (torch.randn(1, 3, 4, 4),),
}


@common.parametrize("test_data", AddDualConv.test_data)
def test_add_dual_conv_tosa_INT(test_data: input_t1):
pipeline = TosaPipelineINT[input_t1](AddDualConv(), test_data(), aten_op, exir_op)
pipeline.run()


@common.parametrize("test_data", AddDualConv.test_data)
@common.XfailIfNoCorstone300
def test_add_dual_conv_u55_INT(test_data: input_t1):
pipeline = EthosU55PipelineINT[input_t1](
AddDualConv(), test_data(), aten_op, exir_op
)
pipeline.run()


@common.parametrize("test_data", AddDualConv.test_data)
@common.XfailIfNoCorstone320
def test_add_dual_conv_u85_INT(test_data: input_t1):
pipeline = EthosU85PipelineINT[input_t1](
AddDualConv(), test_data(), aten_op, exir_op
)
pipeline.run()


class AddMultiReader(torch.nn.Module):
"""Conv2(conv1(x)) + conv3(conv1(x)) — conv1's output Rescale has two
readers.
"""

def __init__(self):
super().__init__()
self.conv1 = torch.nn.Conv2d(3, 3, 1, bias=False)
self.conv2 = torch.nn.Conv2d(3, 3, 1, bias=False)
self.conv3 = torch.nn.Conv2d(3, 3, 1, bias=False)

def forward(self, x):
y = self.conv1(x)
return self.conv2(y) + self.conv3(y)

test_data = {
"4d_randn": lambda: (torch.randn(1, 3, 4, 4),),
}


@common.parametrize("test_data", AddMultiReader.test_data)
def test_add_multi_reader_tosa_INT(test_data: input_t1):
pipeline = TosaPipelineINT[input_t1](
AddMultiReader(), test_data(), aten_op, exir_op
)
pipeline.run()


@common.parametrize("test_data", AddMultiReader.test_data)
@common.XfailIfNoCorstone300
def test_add_multi_reader_u55_INT(test_data: input_t1):
pipeline = EthosU55PipelineINT[input_t1](
AddMultiReader(), test_data(), aten_op, exir_op
)
pipeline.run()


@common.parametrize("test_data", AddMultiReader.test_data)
@common.XfailIfNoCorstone320
def test_add_multi_reader_u85_INT(test_data: input_t1):
pipeline = EthosU85PipelineINT[input_t1](
AddMultiReader(), test_data(), aten_op, exir_op
)
pipeline.run()


@common.parametrize("test_data", Add.test_data)
def test_add_tensor_tosa_INT_16a8w(test_data: input_t1):
"""Test add operation with 16A8W quantization (16-bit activations, 8-bit
Expand Down
125 changes: 125 additions & 0 deletions backends/arm/test/ops/test_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,131 @@ def test_sub_tensor_vgf_quant_2(test_data: Tuple[torch.Tensor, torch.Tensor]):
pipeline.run()


class SubConvResidual(torch.nn.Module):
"""conv(x) - x — residual block. Creates non-unit IFM scales"""

def __init__(self):
super().__init__()
self.conv = torch.nn.Conv2d(3, 3, 1, bias=False)

def forward(self, x):
return self.conv(x) - x

test_data = {
"4d_randn": lambda: (torch.randn(1, 3, 4, 4),),
}


@common.parametrize("test_data", SubConvResidual.test_data)
def test_sub_conv_residual_tosa_INT(test_data: input_t1):
pipeline = TosaPipelineINT[input_t1](
SubConvResidual(), test_data(), aten_op, exir_op
)
pipeline.run()


@common.parametrize("test_data", SubConvResidual.test_data)
@common.XfailIfNoCorstone300
def test_sub_conv_residual_u55_INT(test_data: input_t1):
pipeline = EthosU55PipelineINT[input_t1](
SubConvResidual(), test_data(), aten_op, exir_op
)
pipeline.run()


@common.parametrize("test_data", SubConvResidual.test_data)
@common.XfailIfNoCorstone320
def test_sub_conv_residual_u85_INT(test_data: input_t1):
pipeline = EthosU85PipelineINT[input_t1](
SubConvResidual(), test_data(), aten_op, exir_op
)
pipeline.run()


class SubDualConv(torch.nn.Module):
"""conv1(x) - conv2(x) — both inputs have Rescale producers."""

def __init__(self):
super().__init__()
self.conv1 = torch.nn.Conv2d(3, 3, 1, bias=False)
self.conv2 = torch.nn.Conv2d(3, 3, 1, bias=False)

def forward(self, x):
return self.conv1(x) - self.conv2(x)

test_data = {
"4d_randn": lambda: (torch.randn(1, 3, 4, 4),),
}


@common.parametrize("test_data", SubDualConv.test_data)
def test_sub_dual_conv_tosa_INT(test_data: input_t1):
pipeline = TosaPipelineINT[input_t1](SubDualConv(), test_data(), aten_op, exir_op)
pipeline.run()


@common.parametrize("test_data", SubDualConv.test_data)
@common.XfailIfNoCorstone300
def test_sub_dual_conv_u55_INT(test_data: input_t1):
pipeline = EthosU55PipelineINT[input_t1](
SubDualConv(), test_data(), aten_op, exir_op
)
pipeline.run()


@common.parametrize("test_data", SubDualConv.test_data)
@common.XfailIfNoCorstone320
def test_sub_dual_conv_u85_INT(test_data: input_t1):
pipeline = EthosU85PipelineINT[input_t1](
SubDualConv(), test_data(), aten_op, exir_op
)
pipeline.run()


class SubMultiReader(torch.nn.Module):
"""conv2(conv1(x)) - conv3(conv1(x)) — conv1's output Rescale has two readers."""

def __init__(self):
super().__init__()
self.conv1 = torch.nn.Conv2d(3, 3, 1, bias=False)
self.conv2 = torch.nn.Conv2d(3, 3, 1, bias=False)
self.conv3 = torch.nn.Conv2d(3, 3, 1, bias=False)

def forward(self, x):
y = self.conv1(x)
return self.conv2(y) - self.conv3(y)

test_data = {
"4d_randn": lambda: (torch.randn(1, 3, 4, 4),),
}


@common.parametrize("test_data", SubMultiReader.test_data)
def test_sub_multi_reader_tosa_INT(test_data: input_t1):
pipeline = TosaPipelineINT[input_t1](
SubMultiReader(), test_data(), aten_op, exir_op
)
pipeline.run()


@common.parametrize("test_data", SubMultiReader.test_data)
@common.XfailIfNoCorstone300
def test_sub_multi_reader_u55_INT(test_data: input_t1):
pipeline = EthosU55PipelineINT[input_t1](
SubMultiReader(), test_data(), aten_op, exir_op
)
pipeline.run()


@common.parametrize("test_data", SubMultiReader.test_data)
@common.XfailIfNoCorstone320
def test_sub_multi_reader_u85_INT(test_data: input_t1):
pipeline = EthosU85PipelineINT[input_t1](
SubMultiReader(), test_data(), aten_op, exir_op
)
pipeline.run()


@common.parametrize("test_data", sub_test_data)
def test_sub_tensor_16a8w_tosa_INT(test_data: input_t1):
"""Test sub operation with 16A8W quantization (16-bit activations, 8-bit
Expand Down
Loading