Skip to content

Commit d8b526e

Browse files
committed
Update on "[jit] register __getitem__ builtin"
[jit] register __getitem__ builtin Summary: Follow up of #21990, I am switching index select operations to a standard __getitem__ builtin, rather than bunch of different builtins according to the type, such as prim::DictIndex, prim::ListIndex, etc. This will also aligned with the some other magic methods that we already use gh-metadata: pytorch pytorch 22276 gh/wanchaol/28/head
1 parent 5b65f37 commit d8b526e

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

torch/csrc/jit/script/sugared_value.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -275,24 +275,6 @@ Value* SimpleValue::len(const SourceRange& loc, Function& m) {
275275
}
276276
}
277277

278-
int64_t getAdjTupleIndex(
279-
const SourceRange& loc,
280-
const TupleTypePtr& tuple_type,
281-
int64_t input_index,
282-
bool allow_out_of_bounds) {
283-
// set index to be positive to simplify logic in runtime
284-
int64_t adj_index = input_index;
285-
int64_t tuple_len = tuple_type->elements().size();
286-
if (input_index < 0) {
287-
adj_index = tuple_len + input_index;
288-
}
289-
if (!allow_out_of_bounds && (adj_index >= tuple_len || adj_index < 0)) {
290-
throw ErrorReport(loc) << "Tuple index out of range. Tuple is length "
291-
<< tuple_len << " and index is " << input_index;
292-
}
293-
return adj_index;
294-
}
295-
296278
Value* SimpleValue::getitem(const SourceRange& loc, Function& m, Value* idx) {
297279
Value* val = getValue();
298280
TypePtr val_type = val->type();

0 commit comments

Comments
 (0)