MCPcopy Create free account
hub / github.com/pytorch/executorch / EXIRATenDialectVerifier

Function EXIRATenDialectVerifier

exir/verification/verifier.py:84–176  ·  view source on GitHub ↗

Returns a verifier class that runs ATen dialect specific checks on the graph module.

(  # noqa: C901
    edge_compile_config: Optional[EdgeCompileConfig] = None,
    class_only: bool = False,
    core_aten_ops_exception_list: Optional[List[torch._ops.OpOverload]] = None,
    preserve_ops: Optional[List[torch._ops.OpOverload]] = None,
)

Source from the content-addressed store, hash-verified

82
83
84def EXIRATenDialectVerifier( # noqa: C901
85 edge_compile_config: Optional[EdgeCompileConfig] = None,
86 class_only: bool = False,
87 core_aten_ops_exception_list: Optional[List[torch._ops.OpOverload]] = None,
88 preserve_ops: Optional[List[torch._ops.OpOverload]] = None,
89):
90 """
91 Returns a verifier class that runs ATen dialect specific checks on the graph module.
92 """
93 _core_aten_ops_exception_list = core_aten_ops_exception_list or []
94 _preserve_ops = preserve_ops or []
95 # merge the exception list from edge_compile_config and exception_list
96 if edge_compile_config:
97 if edge_compile_config._core_aten_ops_exception_list:
98 _core_aten_ops_exception_list.extend(
99 edge_compile_config._core_aten_ops_exception_list
100 )
101 if edge_compile_config.preserve_ops:
102 _preserve_ops.extend(edge_compile_config.preserve_ops)
103
104 class _EXIRATenDialectVerifier(EXIRATenDialectVerifierBase):
105 dialect = "OLD_EXIR_ATEN"
106
107 def __init__(self) -> None:
108 super().__init__()
109 # Note: here we are using the exception list passed from EXIRATenDialectVerifier function!
110 self._core_aten_ops_exception_list = _core_aten_ops_exception_list
111 self._preserve_ops = _preserve_ops
112
113 def _get_core_aten_ops_exception_list(self) -> List[torch._ops.OpOverload]:
114 exception_list = (
115 [
116 torch.ops.aten.mkldnn_rnn_layer.default,
117 torch.ops.aten._upsample_bilinear2d_aa.default,
118 torch.ops.aten.quantize_per_tensor.default,
119 torch.ops.aten.dequantize.self,
120 torch.ops.aten.max.default, # TODO(T188268054)
121 torch.ops.aten.min.default, # TODO(T188268054)
122 torch.ops.aten.full_like.default, # TODO(T183507359)
123 ]
124 + list(_EXECUTORCH_SYM_OPS)
125 + DISALLOW_LIST
126 + self._core_aten_ops_exception_list
127 )
128
129 return exception_list
130
131 def check_valid_op(self, op):
132 if isinstance(op, OpOverload):
133 # TODO These special ops should be removable easily.
134 if (
135 op.namespace != "aten"
136 or op in self._get_core_aten_ops_exception_list()
137 ):
138 return
139 if op in self._preserve_ops:
140 if op.namespace != "aten":
141 raise RuntimeError(

Callers 4

_to_edgeFunction · 0.90
to_edgeFunction · 0.90
get_aten_verifierFunction · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected