MCPcopy
hub / github.com/lutzroeder/netron / trace

Method trace

source/python.js:8709–8732  ·  view source on GitHub ↗
(root /*, concrete_args */)

Source from the content-addressed store, hash-verified

8707 });
8708 this.registerType('torch.fx._symbolic_trace.Tracer', class extends torch.fx.proxy.TracerBase {
8709 trace(root /*, concrete_args */) {
8710 let fn = null;
8711 if (root instanceof torch.nn.Module) {
8712 // torch.fx._lazy_graph_module._LazyGraphModule.force_recompile(root)
8713 this.root = root;
8714 fn = builtins.getattr(new builtins.type(root), this.traced_func_name);
8715 this.root_module_name = root._get_name();
8716 this.submodule_paths = new builtins.dict(root.named_modules());
8717 } else {
8718 this.root = new torch.nn.Module();
8719 fn = root;
8720 }
8721 const tracer_cls = builtins.getattr(this, '__class__', null);
8722 this.graph = new torch.fx.graph.Graph(null, tracer_cls);
8723 if (builtins.hasattr(this, '__code__')) {
8724 const code = fn.__code__;
8725 this.graph._co_fields = {
8726 co_name: code.co_name,
8727 co_filename: code.co_filename,
8728 co_firstlineno: code.co_firstlineno,
8729 };
8730 }
8731 return this.graph;
8732 }
8733 is_leaf_module(m /*, module_qualified_name */) {
8734 return (m.__module__.startsWith('torch.nn') || m.__module__.startsWith('torch.ao.nn')) && m instanceof torch.nn.Sequential === false;
8735 }

Callers 3

constructorMethod · 0.80

Calls 4

_get_nameMethod · 0.80
named_modulesMethod · 0.80
hasattrMethod · 0.80
getattrMethod · 0.45

Tested by

no test coverage detected