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

Method __update_args_kwargs

source/python.js:8888–8927  ·  view source on GitHub ↗
(new_args, new_kwargs)

Source from the content-addressed store, hash-verified

8886 [p._next, n._prev] = [n, p];
8887 }
8888 __update_args_kwargs(new_args, new_kwargs) {
8889 const update_users_and_input_nodes = (n) => {
8890 if (n instanceof torch.fx.node.Node) {
8891 this._input_nodes.setdefault(n);
8892 n.users.setdefault(this);
8893 }
8894 return n;
8895 };
8896 const map_aggregate = (a, fn) => {
8897 if (a instanceof builtins.tuple) {
8898 const t = new builtins.tuple(a.map((elem) => map_aggregate(elem, fn)));
8899 if (!builtins.hasattr(a, '_fields')) {
8900 return t;
8901 }
8902 throw new python.Error('Not implemented.');
8903 // return type(a)(*t);
8904 } else if (Array.isArray(a)) {
8905 return a.map((elem) => map_aggregate(elem, fn));
8906 } else if (a instanceof builtins.dict) {
8907 const rv = new builtins.dict();
8908 for (const [k, v] of a) {
8909 rv.__setitem__(k, map_aggregate(v, fn));
8910 }
8911 return rv;
8912 } else if (a instanceof builtins.slice) {
8913 throw new python.Error('Not implemented.');
8914 // return slice(map_aggregate(a.start, fn), map_aggregate(a.stop, fn), map_aggregate(a.step, fn))
8915 }
8916 return fn(a);
8917 };
8918 for (const old_use of this._input_nodes.keys()) {
8919 old_use.users.pop(this);
8920 }
8921 // object.__setattr__(self, "_input_nodes", {})
8922 this._input_nodes = new builtins.dict();
8923 // object.__setattr__(self, "_args", map_aggregate(new_args, update_users_and_input_nodes))
8924 this._args = map_aggregate(new_args, update_users_and_input_nodes);
8925 // object.__setattr__(self, "_kwargs", map_aggregate(new_kwargs, update_users_and_input_nodes))
8926 this._kwargs = map_aggregate(new_kwargs, update_users_and_input_nodes);
8927 }
8928 });
8929 torch.fx.Node = torch.fx.node.Node;
8930 torch.fx.graph.Node = torch.fx.node.Node;

Callers 1

constructorMethod · 0.80

Calls 2

keysMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected