Skip to content

jit_utils

torch_to_nnef.torch_graph.jit_utils

Shared utilities for JIT graph traversal and qualname parsing.

These small helpers are used by jit_inline, jit_passes, and the recursive parser in ir_helpers. Centralized here to avoid duplication.

parse_jit_qualname

parse_jit_qualname(qualname: str) -> T.Tuple[str, str]

Return (module_path, class_name) for a __torch__.* qualname.

Strips the __torch__. prefix and ___torch_mangle_* mangling segments; the trailing path component is the class name and the rest is the import path. Returns ("", "") when qualname is not a __torch__.* class reference.

Examples:

"__torch__.vad.model.SileroBlock" -> ("vad.model", "SileroBlock")

"__torch__.torch.nn.modules.rnn.___torch_mangle_8.LSTM" -> ("torch.nn.modules.rnn", "LSTM")

walk_nodes

walk_nodes(graph_or_block) -> T.Iterator['torch._C.Node']

Yield nodes recursively, descending into prim::If / prim::Loop blocks.