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

Method parseFakeAndRealType

source/python.js:11591–11721  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11589 }
11590 }
11591 parseFakeAndRealType() {
11592 const L = this.L;
11593 let fake_value = null;
11594 let real_value = null;
11595 let alias_info = null;
11596 if (L.nextIf('(')) {
11597 const types = [];
11598 while (!L.nextIf(')')) {
11599 const r = this.parseType();
11600 types.push(r.first);
11601 if (alias_info && r.second) {
11602 alias_info.addContainedType(r.second);
11603 }
11604 L.nextIf(',');
11605 }
11606 real_value = torch.TupleType.create(types);
11607 fake_value = real_value;
11608 } else if (L.cur().text() === 'Future') {
11609 L.next();
11610 L.expect('(');
11611 const p = this.parseType();
11612 const subtype = p.first;
11613 // const subalias = p.second;
11614 L.expect(')');
11615 real_value = torch.FutureType.create(subtype);
11616 fake_value = real_value;
11617 } else if (L.cur().text() === 'Await') {
11618 L.next();
11619 L.expect('(');
11620 const p = this.parseType();
11621 const subtype = p.first;
11622 // const subalias = p.second;
11623 L.expect(')');
11624 real_value = torch.AwaitType.get(subtype);
11625 fake_value = real_value;
11626 } else if (L.cur().text() === 'RRef') {
11627 L.next();
11628 L.expect('(');
11629 const p = this.parseType();
11630 const subtype = p.first;
11631 // const subalias = p.second;
11632 L.expect(')');
11633 real_value = torch.RRefType.create(subtype);
11634 fake_value = real_value;
11635 } else if (L.cur().text() === 'Tensor') {
11636 L.next();
11637 real_value = torch.TensorType.get();
11638 fake_value = real_value;
11639 alias_info = this.parseAliasAnnotation();
11640 } else if (L.cur().text() === 'Dict') {
11641 L.next();
11642 L.expect('(');
11643 const key_type = this.parseType().first;
11644 L.expect(',');
11645 const value_type = this.parseType().first;
11646 L.expect(')');
11647 alias_info = this.parseAliasAnnotation();
11648 real_value = torch.DictType.create(key_type, value_type);

Callers 2

parseArgumentMethod · 0.80
parseTypeMethod · 0.80

Calls 14

nextIfMethod · 0.80
addContainedTypeMethod · 0.80
textMethod · 0.80
curMethod · 0.80
parseAliasAnnotationMethod · 0.80
parseBaseTypeMethod · 0.80
lookaheadMethod · 0.80
parseTypeMethod · 0.45
pushMethod · 0.45
createMethod · 0.45
nextMethod · 0.45
expectMethod · 0.45

Tested by

no test coverage detected