Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions torch/csrc/jit/runtime/register_prim_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,34 @@ RegisterOperators reg(
return 0;
},
aliasAnalysisFromSchema()),
// only used internally in range() translation
Operator(
"aten::__range_length(int lo, int hi, int step) -> int",
[](Stack& stack) {
int64_t lo, hi, step;
pop(stack, lo, hi, step);
// error handling when step_val = 0 during runtime
if (step == 0) {
throw std::runtime_error("range() arg 3 must not be zero");
}
if (step > 0 && lo < hi)
push(stack, 1 + (hi - 1 - lo) / step);
else if (step < 0 && lo > hi)
push(stack, 1 + (lo - 1 - hi) / (0 - step));
else
push(stack, 0);
return 0;
},
aliasAnalysisFromSchema()),
Operator(
"aten::__derive_index(int index, int start, int step) -> int",
[](Stack& stack) {
int64_t index, start, step;
pop(stack, index, start, step);
push(stack, start + index * step);
return 0;
},
aliasAnalysisFromSchema()),
// these ops are generic over the list element type.
// CREATING GENERIC_LIST_OPS
Operator(
Expand Down
28 changes: 0 additions & 28 deletions torch/csrc/jit/runtime/register_prim_ops_fulljit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,34 +1003,6 @@ RegisterOperators reg2({
// only used in loop unrolling, not exposed to end users
DEFINE_INT_OP(aten::__round_to_zero_floordiv, a / b),

// only used internally in range() translation
Operator(
"aten::__range_length(int lo, int hi, int step) -> int",
[](Stack& stack) {
int64_t lo, hi, step;
pop(stack, lo, hi, step);
// error handling when step_val = 0 during runtime
if (step == 0) {
throw std::runtime_error("range() arg 3 must not be zero");
}
if (step > 0 && lo < hi)
push(stack, 1 + (hi - 1 - lo) / step);
else if (step < 0 && lo > hi)
push(stack, 1 + (lo - 1 - hi) / (0 - step));
else
push(stack, 0);
return 0;
},
aliasAnalysisFromSchema()),
Operator(
"aten::__derive_index(int index, int start, int step) -> int",
[](Stack& stack) {
int64_t index, start, step;
pop(stack, index, start, step);
push(stack, start + index * step);
return 0;
},
aliasAnalysisFromSchema()),
Operator(
"aten::modf(float a) -> (float, float)",
[](Stack& stack) {
Expand Down