(loc, m, size_hint)
| 15639 | return this._value; |
| 15640 | } |
| 15641 | asTuple(loc, m, size_hint) { |
| 15642 | const make_simple_value = (v) => new torch._C.SimpleValue(v); |
| 15643 | if (this._value.type() instanceof torch.TupleType) { |
| 15644 | const outputs = torch._C.createTupleUnpack(this._value); |
| 15645 | return outputs.map((v) => make_simple_value(v)); |
| 15646 | } else if (this._value.type() instanceof torch.ListType) { |
| 15647 | if (!size_hint) { |
| 15648 | throw new python.Error('Cannot statically infer the expected size of a list in this context.'); |
| 15649 | } |
| 15650 | const graph = this._value.owningGraph(); |
| 15651 | const unpack = graph.insertNode(graph.createListUnpack(this._value, size_hint)); |
| 15652 | return unpack.outputs().map((v) => make_simple_value(v)); |
| 15653 | } else if (this._value.type().kind() === 'AnyTupleType') { |
| 15654 | throw new python.Error('Provided tuple is not fully defined including its element types.'); |
| 15655 | } |
| 15656 | throw new python.Error(`Cannot use '${this._value.type().toString()}' as tuple.`); |
| 15657 | } |
| 15658 | attr(loc, m, field) { |
| 15659 | if (this._value.type().isSubtypeOf(torch.TensorType.get())) { |
| 15660 | if (torch._C.builtin_cast_method_to_scalar_type().has(field)) { |
no test coverage detected