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

Method tryCreate

source/python.js:15929–15950  ·  view source on GitHub ↗
(symbol, self)

Source from the content-addressed store, hash-verified

15927 return new torch._C.SimpleValue(torch._C.emitBuiltinCall(loc, m.graph(), this.symbol, args, kwargs, this.self));
15928 }
15929 static tryCreate(symbol, self) {
15930 for (const op of torch._C.getAllOperatorsFor(symbol)) {
15931 if (!self) {
15932 return new torch._C.BuiltinFunction(symbol, null);
15933 }
15934 const index = op.schema().argumentIndexWithName('self');
15935 if (index) {
15936 const type_env = new Map();
15937 const formal_type = op.schema().arguments()[index].type();
15938 const matched = torch._C.matchTypeVariables(formal_type, self.type(), type_env);
15939 if (!matched.success()) {
15940 continue;
15941 }
15942 const concrete_type = torch._C.tryEvalTypeVariables(formal_type, type_env);
15943 if (!concrete_type || !self.type().isSubtypeOf(concrete_type)) {
15944 continue;
15945 }
15946 return new torch._C.BuiltinFunction(symbol, self);
15947 }
15948 }
15949 return null;
15950 }
15951 });
15952 this.registerType('torch._C.BuiltinModule', class extends torch._C.SugaredValue {
15953 constructor(name, version) {

Callers 1

attrMethod · 0.80

Calls 6

argumentIndexWithNameMethod · 0.80
schemaMethod · 0.80
argumentsMethod · 0.80
successMethod · 0.80
isSubtypeOfMethod · 0.80
typeMethod · 0.45

Tested by

no test coverage detected