MCPcopy Index your code
hub / github.com/lutzroeder/netron / emitTupleIndex

Method emitTupleIndex

source/python.js:17862–17880  ·  view source on GitHub ↗
(loc, tuple_val, idx_val)

Source from the content-addressed store, hash-verified

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()) {

Callers 1

emitSubscriptMethod · 0.80

Calls 9

elementsMethod · 0.80
getAdjTupleIndexMethod · 0.80
toIntMethod · 0.80
insertNodeMethod · 0.80
createTupleIndexMethod · 0.80
typeMethod · 0.45
getMethod · 0.45
createMethod · 0.45
outputMethod · 0.45

Tested by

no test coverage detected