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

Method parseTypeFromExprImpl

source/python.js:11926–11948  ·  view source on GitHub ↗
(expr)

Source from the content-addressed store, hash-verified

11924 return this.parseTypeFromExprImpl(expr);
11925 }
11926 parseTypeFromExprImpl(expr) {
11927 if (expr instanceof ast.Subscript) {
11928 const value_name = this.parseBaseTypeName(expr.value);
11929 if (!value_name) {
11930 throw new python.Error('Subscripted type must be a type identifier.');
11931 }
11932 return this.subscriptToType(value_name, expr);
11933 }
11934 const name = this.parseBaseTypeName(expr);
11935 if (name) {
11936 const itr = torch._C.string_to_type_lut().get(name);
11937 if (itr) {
11938 return itr;
11939 }
11940 if (this._resolver) {
11941 const typePtr = this._resolver.resolveType(name, expr);
11942 if (typePtr) {
11943 return typePtr;
11944 }
11945 }
11946 }
11947 throw new python.Error(`Unknown type name '${name}'.`);
11948 }
11949 parseBaseTypeName(expr) {
11950 if (expr instanceof ast.Name) {
11951 return expr.id;

Callers 2

parseTypeFromExprMethod · 0.80
subscriptToTypeMethod · 0.80

Calls 4

parseBaseTypeNameMethod · 0.80
subscriptToTypeMethod · 0.80
getMethod · 0.45
resolveTypeMethod · 0.45

Tested by

no test coverage detected