(qualified_classname, class_def, is_module)
| 13735 | } |
| 13736 | } |
| 13737 | importClass(qualified_classname, class_def, is_module) { |
| 13738 | if (qualified_classname.prefix().startsWith('__torch__.torch.classes')) { |
| 13739 | return; |
| 13740 | } |
| 13741 | const parameter_names = new Set(); |
| 13742 | const buffer_names = new Set(); |
| 13743 | const methods = []; |
| 13744 | const method_resolvers = []; |
| 13745 | const attributes = []; |
| 13746 | const constants = []; |
| 13747 | const pre_hook_names = new Set(); |
| 13748 | const pre_hook_def_map = new Map(); |
| 13749 | const hook_names = new Set(); |
| 13750 | const hook_def_map = new Map(); |
| 13751 | const class_type = torch.ClassType.create(qualified_classname.qualifiedName(), this._cu, is_module); |
| 13752 | for (const stmt of class_def.body) { |
| 13753 | if (stmt instanceof ast.Assign || stmt instanceof ast.AnnAssign) { |
| 13754 | let target = null; |
| 13755 | let annotation = null; |
| 13756 | let value = null; |
| 13757 | if (stmt instanceof ast.Assign) { |
| 13758 | [target] = stmt.targets; |
| 13759 | value = stmt.value; |
| 13760 | } else { |
| 13761 | target = stmt.target; |
| 13762 | annotation = stmt.annotation; |
| 13763 | value = stmt.value; |
| 13764 | } |
| 13765 | if (target instanceof ast.Name) { |
| 13766 | const name = this._cu.execution.identifier(target); |
| 13767 | switch (name) { |
| 13768 | case '__annotations__': { |
| 13769 | continue; |
| 13770 | } |
| 13771 | case '__parameters__': { |
| 13772 | for (const elt of value.elts) { |
| 13773 | parameter_names.add(elt.value); |
| 13774 | } |
| 13775 | break; |
| 13776 | } |
| 13777 | case '__buffers__': { |
| 13778 | for (const elt of value.elts) { |
| 13779 | buffer_names.add(elt.value); |
| 13780 | } |
| 13781 | break; |
| 13782 | } |
| 13783 | case '__forward_pre_hooks__': { |
| 13784 | for (const elt of value.elts) { |
| 13785 | pre_hook_names.add(elt.value); |
| 13786 | } |
| 13787 | break; |
| 13788 | } |
| 13789 | case '__forward_hooks__': { |
| 13790 | for (const elt of value.elts) { |
| 13791 | hook_names.add(elt.value); |
| 13792 | } |
| 13793 | break; |
| 13794 | } |
no test coverage detected