Skip to content

Commit 49e6693

Browse files
Arm backend: Convert assert to throw ValueError in op_sigmoid
Asserts are converted to proper raises to ensure graph integrity. It should not be possible for sigmoid to have more than 1 input for a correctly formatted graph, but in the node visitor we cannot know for sure that the graph is formatted correctly. torch.sigmoid supports more data types than fp32, which is why it should be checked. Change-Id: If90fda18ccedde16ed2448188c3b99f766a5c8b0 Signed-off-by: Sebastian Larsson <[email protected]>
1 parent 9e7b469 commit 49e6693

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

backends/arm/operators/op_sigmoid.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ def define_node(
3636
output: TosaArg,
3737
) -> None:
3838

39-
assert len(node.all_input_nodes) == 1
40-
assert inputs[0].dtype == output.dtype == ts.DType.FP32
39+
if len(node.all_input_nodes) != 1:
40+
raise ValueError(
41+
f"Expected 1 input for {self.target}, got {len(node.all_input_nodes)}"
42+
)
43+
if inputs[0].dtype != ts.DType.FP32 or output.dtype != ts.DType.FP32:
44+
raise ValueError(
45+
f"Input and output for {self.target} need to be FP32, got input_dtype: "
46+
f"{inputs[0].dtype} and output_dtype: {output.dtype}"
47+
)
4148

4249
tosa_graph.addOperator(TosaOp.Op().SIGMOID, [inputs[0].name], [output.name])

0 commit comments

Comments
 (0)