(obj, classinfo)
| 16869 | this.emitLoopCommon(stmt.range(), emit_body, null, [], cond); |
| 16870 | } |
| 16871 | emitIsInstance(obj, classinfo) { |
| 16872 | const lhs_val = this.emitExpr(obj); |
| 16873 | const lhs_types = []; |
| 16874 | const rhs_types = []; |
| 16875 | const gather_rhs = (expr) => { |
| 16876 | if (expr instanceof ast.Tuple) { |
| 16877 | for (const e of expr.elts) { |
| 16878 | gather_rhs(e); |
| 16879 | } |
| 16880 | return; |
| 16881 | } |
| 16882 | const type = this._typeParser.parseTypeFromExpr(expr); |
| 16883 | rhs_types.push(type); |
| 16884 | }; |
| 16885 | lhs_types.push(lhs_val.type()); |
| 16886 | gather_rhs(classinfo); |
| 16887 | torch._C.standardizeVectorForUnion(lhs_types); |
| 16888 | torch._C.standardizeVectorForUnion(rhs_types); |
| 16889 | let refinement = new torch._C.RefinementSet([], []); |
| 16890 | let unified_true = null; |
| 16891 | let unified_false = null; |
| 16892 | const isinstance_types = []; |
| 16893 | const not_isinstance_types = []; |
| 16894 | let true_refinements = []; |
| 16895 | let false_refinements = []; |
| 16896 | let all_lhs_subtype_some_rhs = true; |
| 16897 | for (const lhs_type of lhs_types) { |
| 16898 | if (lhs_type === torch.AnyType.get()) { |
| 16899 | isinstance_types.push(...rhs_types); |
| 16900 | not_isinstance_types.push(torch.AnyType.get()); |
| 16901 | if (isinstance_types.length !== 1 || isinstance_types[0] !== torch.AnyType.get()) { |
| 16902 | all_lhs_subtype_some_rhs = false; |
| 16903 | } |
| 16904 | break; |
| 16905 | } |
| 16906 | const get_smaller_type = (t1, t2) => { |
| 16907 | if (t1.isSubtypeOf(t2)) { |
| 16908 | return t1; |
| 16909 | } else if (t2.isSubtypeOf(t1)) { |
| 16910 | return t2; |
| 16911 | } |
| 16912 | return null; |
| 16913 | }; |
| 16914 | let found_refinement = null; |
| 16915 | for (const rhs_type of rhs_types) { |
| 16916 | const maybe_smaller_type = get_smaller_type(lhs_type, rhs_type); |
| 16917 | if (!maybe_smaller_type) { |
| 16918 | continue; |
| 16919 | } else if (maybe_smaller_type === lhs_type) { |
| 16920 | found_refinement = lhs_type; |
| 16921 | } else if (maybe_smaller_type === rhs_type) { |
| 16922 | found_refinement = found_refinement ? torch._C.unifyTypes(found_refinement, rhs_type) : rhs_type; |
| 16923 | } |
| 16924 | } |
| 16925 | if (found_refinement) { |
| 16926 | if (found_refinement === lhs_type) { |
| 16927 | all_lhs_subtype_some_rhs &= true; |
| 16928 | } |
no test coverage detected