MCPcopy
hub / github.com/lutzroeder/netron / emitTupleSlice

Method emitTupleSlice

source/python.js:17888–17908  ·  view source on GitHub ↗
(loc, tuple_val, tuple_args)

Source from the content-addressed store, hash-verified

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));

Callers 2

emitSliceOpMethod · 0.80
emitSubscriptMethod · 0.80

Calls 11

elementsMethod · 0.80
isIntMethod · 0.80
toIntMethod · 0.80
getAdjTupleIndexMethod · 0.80
getSliceIndMethod · 0.80
insertNodeMethod · 0.80
createTupleSliceMethod · 0.80
expectMethod · 0.45
typeMethod · 0.45
valueMethod · 0.45
outputMethod · 0.45

Tested by

no test coverage detected