Skip to content

Commit 0039b3e

Browse files
Arm backend: Convert asserts to raise errors in op_reciprocal (#10105)
Asserts are converted to proper raises to ensure graph integrity. Improve error messages and add additional check that there's only one input. Signed-off-by: Sebastian Larsson <[email protected]>
1 parent a147346 commit 0039b3e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

backends/arm/operators/op_reciprocal.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,16 @@ def define_node(
3434
inputs: List[TosaArg],
3535
output: TosaArg,
3636
) -> None:
37-
assert inputs[0].dtype == output.dtype == ts.DType.FP32
37+
if len(node.all_input_nodes) != 1:
38+
raise ValueError(
39+
f"Expected 1 input for {self.target}, got {len(node.all_input_nodes)}"
40+
)
41+
if inputs[0].dtype != ts.DType.FP32 or output.dtype != ts.DType.FP32:
42+
raise ValueError(
43+
f"Input and output for {self.target} need to be FP32, got "
44+
f"{inputs[0].dtype=} and {output.dtype=}"
45+
)
46+
3847
tosa_graph.addOperator(
3948
ts.TosaOp.Op().RECIPROCAL, [inputs[0].name], [output.name]
4049
)

0 commit comments

Comments
 (0)