(loc, tuple_val, idx_val)
| 17860 | return adj_index; |
| 17861 | } |
| 17862 | emitTupleIndex(loc, tuple_val, idx_val) { |
| 17863 | const tuple_typ = tuple_val.type(); |
| 17864 | const elems = tuple_typ.elements(); |
| 17865 | let output_type = null; |
| 17866 | if (idx_val.type() !== torch.IntType.get()) { |
| 17867 | throw new python.Error('Tuple index must be an integer.'); |
| 17868 | } |
| 17869 | const idx = torch._C.toIValue(idx_val); |
| 17870 | if (idx) { |
| 17871 | const adj_index = this.getAdjTupleIndex(loc, tuple_typ, idx.toInt(), /*allow_out_of_bounds*/ false); |
| 17872 | output_type = elems[adj_index]; |
| 17873 | } else { |
| 17874 | if (elems.length === 0 || !torch._C.convertibleToList(tuple_typ, torch.ListType.create(elems[0]))) { |
| 17875 | throw new python.Error('Cannot index into a tuple with a non-integer literal.'); |
| 17876 | } |
| 17877 | [output_type] = elems; |
| 17878 | } |
| 17879 | return this.graph.insertNode(this.graph.createTupleIndex(tuple_val, idx_val, output_type)).output(); |
| 17880 | } |
| 17881 | getSliceInd(idx_val, loc) { |
| 17882 | const ivalue = torch._C.toIValue(idx_val); |
| 17883 | if (ivalue && ivalue.isInt()) { |
no test coverage detected