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

Method serialize_operator

exir/serde/serialize.py:58–85  ·  view source on GitHub ↗
(
        self,
        target: Union[
            str,
            EdgeOpOverload,
            BackendOpOverload,
            torch._ops.OpOverload,
            torch._ops.HigherOrderOperator,
        ],
    )

Source from the content-addressed store, hash-verified

56 self.state_dict: Dict[str, torch.Tensor] = {} # TODO(T157676982)
57
58 def serialize_operator(
59 self,
60 target: Union[
61 str,
62 EdgeOpOverload,
63 BackendOpOverload,
64 torch._ops.OpOverload,
65 torch._ops.HigherOrderOperator,
66 ],
67 ) -> str:
68 if isinstance(target, str):
69 return target
70 elif target.__module__.startswith("executorch.exir.dialects.edge"):
71 # TODO(zhxchen17) Maybe provide a function name helper in FX.
72 # From torch.fx.node._get_qualified_name
73 module = target.__module__.replace(
74 "executorch.exir.dialects.edge._ops",
75 "executorch.exir.dialects.edge.ops",
76 )
77 return f"{module}.{target.__name__}"
78 elif target.__module__.startswith("executorch.exir.dialects.backend"):
79 module = target.__module__.replace(
80 "executorch.exir.dialects.backend._ops",
81 "executorch.exir.dialects.backend.ops",
82 )
83 return f"{module}.{target.__name__}"
84
85 return super().serialize_operator(target)
86
87 def handle_call_function(self, node: torch.fx.Node) -> None:
88 assert node.op == "call_function"

Callers 1

handle_call_functionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected