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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


# INT profile: ops supported via native TOSA ops, decompositions/transformations, precompute, TableOps, etc.
# Note that ops supported via pre-quantization decompositions are not included here.
TOSA_PRO_INT_SupportList: Final[Set] = {
exir_ops.edge.aten.abs.default,
exir_ops.edge.aten.add.Tensor,
Expand Down Expand Up @@ -46,8 +47,6 @@
exir_ops.edge.aten.hardsigmoid.default,
exir_ops.edge.aten.hardtanh.default,
exir_ops.edge.aten.hardswish.default,
exir_ops.edge.aten.div.Tensor,
exir_ops.edge.aten.div.Tensor_mode,
exir_ops.edge.aten.eq.Tensor,
exir_ops.edge.aten.eq.Scalar,
exir_ops.edge.aten.erf.default,
Expand All @@ -68,16 +67,7 @@
exir_ops.edge.aten.lt.Tensor,
exir_ops.edge.aten.lt.Scalar,
exir_ops.edge.aten.mul.Tensor,
exir_ops.edge.aten.ne.Tensor,
exir_ops.edge.aten.ne.Scalar,
exir_ops.edge.aten.neg.default,
exir_ops.edge.aten.add.Scalar,
exir_ops.edge.aten.sub.Scalar,
exir_ops.edge.aten.mul.Scalar,
exir_ops.edge.aten.div.Scalar,
exir_ops.edge.aten._native_batch_norm_legit_no_training.default,
exir_ops.edge.aten.native_layer_norm.default,
exir_ops.edge.aten.native_group_norm.default,
exir_ops.edge.aten.sigmoid.default,
exir_ops.edge.aten.mean.dim,
exir_ops.edge.aten.mm.default,
Expand All @@ -86,19 +76,12 @@
exir_ops.edge.aten.repeat.default,
exir_ops.edge.aten.reciprocal.default,
exir_ops.edge.aten.relu.default,
exir_ops.edge.aten.leaky_relu.default,
exir_ops.edge.aten.sqrt.default,
exir_ops.edge.aten.rsqrt.default,
exir_ops.edge.aten.round.default,
exir_ops.edge.aten._softmax.default,
exir_ops.edge.aten.select_copy.int,
exir_ops.edge.aten._log_softmax.default,
exir_ops.edge.aten.sub.Tensor,
exir_ops.edge.aten.tanh.default,
exir_ops.edge.aten.upsample_bilinear2d.vec,
exir_ops.edge.aten.upsample_nearest2d.vec,
exir_ops.edge.aten.var.correction,
exir_ops.edge.aten.var.dim,
exir_ops.edge.aten.view_copy.default,
exir_ops.edge.aten.unsqueeze_copy.default,
exir_ops.edge.aten.squeeze_copy.dims,
Expand Down Expand Up @@ -127,12 +110,9 @@
exir_ops.edge.aten.sign.default,
exir_ops.edge.aten.asin.default,
exir_ops.edge.aten.atanh.default,
exir_ops.edge.aten.addmm.default,
exir_ops.edge.aten.masked_fill.Scalar,
exir_ops.edge.aten.asinh.default,
exir_ops.edge.aten.cosh.default,
exir_ops.edge.aten.glu.default,
exir_ops.edge.aten.logit.default,
exir_ops.edge.aten.acos.default,
exir_ops.edge.aten.elu.default,
exir_ops.edge.aten.bitwise_not.default,
Expand Down
55 changes: 2 additions & 53 deletions backends/arm/operator_support/tosa_supported_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def tosa_support_factory(
]

if not tosa_spec.support_float():
negative_checks.append(NeedsDecompositionCheck(reporter))
negative_checks.append(CheckProperQuantization(reporter))
if tosa_spec.is_U55_subset:
negative_checks.append(EthosU55NotSupported(reporter))
Expand All @@ -156,7 +155,8 @@ def tosa_support_factory(
class TOSAProINTSupportList(OperatorSupportBase):
"""
TOSA_PRO_INT_SupportList:
Ops supported in INT profile via native TOSA ops, decomposition/transformation, pre-compute, or TableOps
Ops supported in INT profile via native TOSA ops, decomposition/transformation, pre-compute, or TableOps.
Note that ops supported via pre-quantization decompositions are not included here.
"""

def is_node_supported(
Expand All @@ -179,57 +179,6 @@ def is_node_supported(
return node.op == "call_function" and node.target in TOSA_PRO_FP_SupportList


class NeedsDecompositionCheck(OperatorSupportBase):
"""
Targeted operators need to be decomposed prior to quantization in order to get a pair of q-dq-nodes surrounding
the operator, and to get optimal quantization parameters for each operator. This check will reject operators
that need to be decomposed.
"""

def __init__(self, reporter: WhyNoPartitionReporter):
self.reporter = reporter

def is_node_supported(
self, submodules: typing.Mapping[str, torch.nn.Module], node: fx.Node
) -> bool:

if node.op != "call_function":
return True

needs_decomp_dict = {
exir_ops.edge.aten.div.Tensor: None,
exir_ops.edge.aten._native_batch_norm_legit_no_training.default: "BatchNorm2D with track_running_stats==True not immediately following a convolution is not supported for quantized TOSA backends.",
exir_ops.edge.aten.native_layer_norm.default: None,
exir_ops.edge.aten.native_group_norm.default: None,
exir_ops.edge.aten._softmax.default: None,
exir_ops.edge.aten._log_softmax.default: None,
exir_ops.edge.aten.var.correction: None,
exir_ops.edge.aten.var.dim: None,
exir_ops.edge.aten.add.Scalar: None,
exir_ops.edge.aten.sqrt.default: None,
exir_ops.edge.aten.sub.Scalar: None,
exir_ops.edge.aten.mul.Scalar: None,
exir_ops.edge.aten.ne.Tensor: None,
exir_ops.edge.aten.ne.Scalar: None,
exir_ops.edge.aten.div.Scalar: None,
exir_ops.edge.aten.leaky_relu.default: None,
exir_ops.edge.aten.round.default: None,
exir_ops.edge.aten.addmm.default: None,
exir_ops.edge.aten.glu.default: None,
exir_ops.edge.aten.logit.default: None,
}

if node.target in needs_decomp_dict:
reject_message = needs_decomp_dict[node.target]
if reject_message is None:
reject_message = "Op needs to be decomposed into other ops before quantization to get quantized properly."

self.reporter.report_reject(node, reject_message)
return False
else:
return True


class CheckProperQuantization(OperatorSupportBase):
"""
For targeted nodes, check that it has been quantized as expected. In most cases this means that a pair of quantize
Expand Down
Loading