(type)
| 7500 | return this.mapTypeToAliasTypeSetImpl(type); |
| 7501 | } |
| 7502 | mapTypeToAliasTypeSetImpl(type) { |
| 7503 | if (type instanceof torch.ListType || |
| 7504 | type instanceof torch.DictType || |
| 7505 | type instanceof torch.ClassType || |
| 7506 | type instanceof torch.TensorType) { |
| 7507 | return [torch._C.unshapedType(type)]; |
| 7508 | } |
| 7509 | if (type instanceof torch.UnionType) { |
| 7510 | const mutable_types = []; |
| 7511 | for (const inner of type.expect(torch.UnionType).containedTypes()) { |
| 7512 | const maybe_inner_types = this.mapTypeToAliasTypeSet(inner); |
| 7513 | if (maybe_inner_types) { |
| 7514 | mutable_types.push(...maybe_inner_types); |
| 7515 | } |
| 7516 | } |
| 7517 | if (mutable_types.length === 0) { |
| 7518 | return null; |
| 7519 | } |
| 7520 | return mutable_types; |
| 7521 | } |
| 7522 | if (type instanceof torch.OptionalType) { |
| 7523 | const inner = type.getElementType(); |
| 7524 | return this.mapTypeToAliasTypeSet(inner); |
| 7525 | } |
| 7526 | if (type instanceof torch.AnyType) { |
| 7527 | return [torch._C.AliasTypeSet([type])]; |
| 7528 | } |
| 7529 | if (type instanceof torch.FutureType) { |
| 7530 | const maybe_mut_types = this.mapTypeToAliasTypeSet(type.getElementType()); |
| 7531 | if (maybe_mut_types) { |
| 7532 | return [torch._C.AliasTypeSet([torch.FutureType.create(torch._C.toSingleType(maybe_mut_types))])]; |
| 7533 | } |
| 7534 | return null; |
| 7535 | } |
| 7536 | if (type instanceof torch.AwaitType) { |
| 7537 | const maybe_mut_types = this.mapTypeToAliasTypeSet(type.getElementType()); |
| 7538 | if (maybe_mut_types) { |
| 7539 | return [torch._C.AliasTypeSet([torch.AwaitType.create(torch._C.toSingleType(maybe_mut_types))])]; |
| 7540 | } |
| 7541 | return null; |
| 7542 | } |
| 7543 | if (type instanceof torch.TupleType) { |
| 7544 | const mutable_types = []; |
| 7545 | for (const inner of type.elements()) { |
| 7546 | const maybe_inner_types = this.mapTypeToAliasTypeSet(inner); |
| 7547 | if (maybe_inner_types) { |
| 7548 | mutable_types.push(...maybe_inner_types); |
| 7549 | } |
| 7550 | } |
| 7551 | if (mutable_types.length === 0) { |
| 7552 | return null; |
| 7553 | } |
| 7554 | return [[torch.TupleType.create(mutable_types)]]; |
| 7555 | } |
| 7556 | return null; |
| 7557 | } |
| 7558 | }); |
| 7559 | this.registerFunction('torch._C.isMutableTypeImpl', (type, mutable_type_cache) => { |
no test coverage detected