(loc, tuple_val, tuple_args)
| 17886 | throw new python.Error(`Tuple slice indices must be integer constants at '${loc}'.`); |
| 17887 | } |
| 17888 | emitTupleSlice(loc, tuple_val, tuple_args) { |
| 17889 | const tuple_type = tuple_val.value(this.graph).type().expect(torch.TupleType); |
| 17890 | const tuple_len = tuple_type.elements().length; |
| 17891 | const [beg_val, end_val, step] = tuple_args; |
| 17892 | let step_size = 1; |
| 17893 | if (step) { |
| 17894 | const val = torch._C.toIValue(step.value(this.graph)); |
| 17895 | torch._C.TORCH_CHECK(val.isInt()); |
| 17896 | step_size = val.toInt(); |
| 17897 | } |
| 17898 | let beg = { _: Number.MAX_SAFE_INTEGER }; // std::numeric_limits<int64_t>::max(); |
| 17899 | if (beg_val) { |
| 17900 | beg = { _: this.getAdjTupleIndex(loc, tuple_type, this.getSliceInd(beg_val.value(this.graph), loc), true) }; |
| 17901 | } |
| 17902 | let end = { _: Number.MAX_SAFE_INTEGER }; // std::numeric_limits<int64_t>::max(); |
| 17903 | if (end_val) { |
| 17904 | end = { _: this.getAdjTupleIndex(loc, tuple_type, this.getSliceInd(end_val.value(this.graph), loc), true) }; |
| 17905 | } |
| 17906 | const num_values = torch._C.slice_indices_adjust(tuple_len, beg, end, step_size); |
| 17907 | return this.graph.insertNode(this.graph.createTupleSlice(tuple_val.value(this.graph), beg._, step_size, num_values)).output(); |
| 17908 | } |
| 17909 | emitSliceOp(loc, sliceable, dim, start, end, step) { |
| 17910 | const args = []; |
| 17911 | args.push(new torch._C.NamedValue(loc, 'self', sliceable)); |
no test coverage detected