Skip to content

Commit 0480fc0

Browse files
Arm backend: Convert assert to throw ValueError in op_log (#10392)
Asserts are converted to proper raises to ensure graph integrity. It should not be possible for log 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.log supports more data types than fp32, which is why it should be checked. Signed-off-by: Sebastian Larsson <[email protected]>
1 parent 318e26b commit 0480fc0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

backends/arm/operators/op_log.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ def define_node(
3333
inputs: List[TosaArg],
3434
output: TosaArg,
3535
) -> None:
36-
assert len(node.all_input_nodes) == 1
37-
assert inputs[0].dtype == output.dtype == ts.DType.FP32
36+
if len(node.all_input_nodes) != 1:
37+
raise ValueError(
38+
f"Expected 1 input for {self.target}, got {len(node.all_input_nodes)}"
39+
)
40+
if inputs[0].dtype != ts.DType.FP32 or output.dtype != ts.DType.FP32:
41+
raise ValueError(
42+
f"Input and output for {self.target} need to be FP32, got input_dtype: "
43+
f"{inputs[0].dtype} and output_dtype: {output.dtype}"
44+
)
3845

3946
tosa_graph.addOperator(ts.TosaOp.Op().LOG, [inputs[0].name], [output.name])

0 commit comments

Comments
 (0)