|
3 | 3 | # This source code is licensed under the BSD-style license found in the |
4 | 4 | # LICENSE file in the root directory of this source tree. |
5 | 5 |
|
6 | | - |
7 | | -from typing import Any, List |
8 | | - |
9 | 6 | import tosa_serializer as ts |
10 | 7 |
|
11 | | -from executorch.backends.arm.operators.node_visitor import ( |
12 | | - NodeVisitor, |
13 | | - register_node_visitor, |
14 | | -) |
15 | | -from executorch.backends.arm.operators.operator_validation_utils import ( |
16 | | - validate_num_inputs, |
17 | | - validate_same_dtype, |
18 | | - validate_valid_dtype, |
| 8 | +from executorch.backends.arm.operators.node_visitor import register_node_visitor |
| 9 | +from executorch.backends.arm.operators.simple_node_visitor import ( |
| 10 | + SimpleNodeVisitor, |
| 11 | + SimpleNodeVisitorConfig, |
19 | 12 | ) |
20 | | -from executorch.backends.arm.tosa.mapping import TosaArg |
21 | 13 |
|
22 | | -from torch.fx import Node |
| 14 | +COMPARE_INPUT_DTYPES = [ts.DType.INT32, ts.DType.FP32, ts.DType.BF16, ts.DType.FP16] |
23 | 15 |
|
24 | 16 |
|
25 | 17 | @register_node_visitor |
26 | | -class GreaterEqualVisitor(NodeVisitor): |
| 18 | +class GreaterEqualVisitor(SimpleNodeVisitor): |
27 | 19 | target = "aten.ge.Tensor" |
28 | 20 |
|
29 | | - def __init__(self, *args): |
30 | | - super().__init__(*args) |
31 | | - |
32 | | - def define_node( |
33 | | - self, |
34 | | - node: Node, |
35 | | - tosa_graph: Any, |
36 | | - inputs: List[TosaArg], |
37 | | - output: TosaArg, |
38 | | - ) -> None: |
39 | | - validate_num_inputs(self.target, inputs, 2) |
40 | | - validate_same_dtype(self.target, inputs, ts) |
41 | | - validate_valid_dtype( |
42 | | - self.target, |
43 | | - inputs, |
44 | | - [ts.DType.INT32, ts.DType.FP32, ts.DType.BF16, ts.DType.FP16], |
45 | | - self.tosa_spec, |
46 | | - ) |
47 | | - validate_valid_dtype(self.target, output, ts.DType.BOOL, self.tosa_spec) |
48 | | - |
49 | | - attr = ts.TosaSerializerAttribute() |
50 | | - attr.GreaterEqualAttribute() |
51 | | - self._serialize_operator( |
52 | | - node, |
53 | | - tosa_graph, |
54 | | - ts.Op.GREATER_EQUAL, |
55 | | - [inputs[0].name, inputs[1].name], |
56 | | - [output.name], |
57 | | - attr, |
| 21 | + @classmethod |
| 22 | + def get_config(cls) -> SimpleNodeVisitorConfig: |
| 23 | + return SimpleNodeVisitorConfig( |
| 24 | + tosa_op=ts.Op.GREATER_EQUAL, |
| 25 | + attr_method="GreaterEqualAttribute", |
| 26 | + num_inputs=2, |
| 27 | + input_dtypes=COMPARE_INPUT_DTYPES, |
| 28 | + output_dtypes=[ts.DType.BOOL], |
| 29 | + same_dtype_with_output=False, |
| 30 | + dtype_check_inputs_only=True, |
58 | 31 | ) |
0 commit comments