33# This source code is licensed under the BSD-style license found in the
44# LICENSE file in the root directory of this source tree.
55
6- from typing import Any , List
7-
8- import torch
96import tosa_serializer as ts
107
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 ,
1912)
20- from executorch .backends .arm .tosa .mapping import TosaArg
2113
2214
2315@register_node_visitor
24- class IdentityVisitor (NodeVisitor ):
16+ class IdentityVisitor (SimpleNodeVisitor ):
2517 """Lower the TOSA IDENTITY op."""
2618
2719 target = "tosa.IDENTITY.default"
2820
29- def define_node (
30- self ,
31- node : torch .fx .Node ,
32- tosa_graph : Any ,
33- inputs : List [TosaArg ],
34- output : TosaArg ,
35- ) -> None :
36- validate_num_inputs (self .target , inputs , 1 )
37- validate_same_dtype (self .target , [inputs [0 ], output ], ts )
38- validate_valid_dtype (
39- self .target ,
40- [inputs [0 ], output ],
41- [
21+ @classmethod
22+ def get_config (cls ) -> SimpleNodeVisitorConfig :
23+ return SimpleNodeVisitorConfig (
24+ tosa_op = ts .Op .IDENTITY ,
25+ attr_method = "IdentityAttribute" ,
26+ num_inputs = 1 ,
27+ input_dtypes = [
4228 ts .DType .BOOL ,
4329 ts .DType .INT8 ,
4430 ts .DType .INT16 ,
@@ -49,16 +35,4 @@ def define_node(
4935 ts .DType .FP8E4M3 ,
5036 ts .DType .FP8E5M2 ,
5137 ],
52- self .tosa_spec ,
53- )
54-
55- attr = ts .TosaSerializerAttribute ()
56- attr .IdentityAttribute ()
57- self ._serialize_operator (
58- node ,
59- tosa_graph ,
60- ts .Op .IDENTITY ,
61- [inputs [0 ].name ],
62- [output .name ],
63- attr ,
6438 )
0 commit comments