Skip to content

Commit 00e5030

Browse files
zingoper
andauthored
Arm backend: Fix transpose convolution accumulator type (pytorch#23150)
Use FP32 accumulation for BF16 and FP16 transpose convolutions, matching the existing CONV2D lowering. Keep FP8 accumulation in FP16. Signed-off-by: Zingo Andersen <Zingo.Andersen@arm.com> Co-authored-by: Per Åstrand <per.astrand@arm.com>
1 parent d23381a commit 00e5030

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎backends/arm/operators/op_tosa_transpose_conv2d.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def _get_tosa_op(self):
3636
def _get_attr_func(self, attr):
3737
return attr.TransposeConv2dAttribute
3838

39-
def define_node(
39+
def define_node( # noqa: C901
4040
self,
4141
node,
4242
tosa_graph,
@@ -104,6 +104,14 @@ def define_node(
104104

105105
output_name = output.name
106106
acc_type = output.dtype
107+
if input.dtype in [ts.DType.FP8E4M3, ts.DType.FP8E5M2]:
108+
acc_type = ts.DType.FP16
109+
elif output.dtype in [
110+
ts.DType.BF16,
111+
ts.DType.FP16,
112+
]:
113+
# Accumulate BF16 and FP16 inputs in FP32 for better precision.
114+
acc_type = ts.DType.FP32
107115
input_zp_name, weight_zp_name = add_input_weight_zp_consts(
108116
tosa_graph, node, inputs, output_name
109117
)

0 commit comments

Comments
 (0)