Skip to content

Commit cc29c19

Browse files
linbinyufacebook-github-bot
authored andcommitted
add "aten::add.str" op and remove two duplicated ops
Summary: add "aten::add.str" op and remove two duplicated ops Test Plan: ``` buck run //xplat/caffe2/fb/pytorch_predictor:converter /mnt/vol/gfsfblearner-altoona/flow/data/2020-06-29/1ca8a85f-dbd5-4181-b5fc-63d24465c1fc/201084299/2068673333/model.pt1 ~/model_f201084299.bc buck run xplat/assistant/model_benchmark_tool/mobile/binary/:lite_predictor -- --model ~/model_f201084299.bc --input_file /tmp/gc_model_input.txt --model_input_args src_tokens,dict_feat,contextual_token_embedding --warmup 1 --iter 2 ``` Reviewed By: pengtxiafb Differential Revision: D22395604 fbshipit-source-id: 0ce21e8b8ae989d125f2f3739523e3c486590b9f
1 parent a4fd490 commit cc29c19

File tree

4 files changed

+11
-41
lines changed

4 files changed

+11
-41
lines changed

test/backward_compatibility/check_backward_compatibility.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
('aten::__or__', datetime.date(2020, 6, 30)),
116116
('aten::__xor__', datetime.date(2020, 6, 30)),
117117
('aten::split', datetime.date(2020, 6, 30)),
118+
('aten::add', datetime.date(2020, 7, 30)),
118119
]
119120

120121

torch/csrc/jit/runtime/register_ops_utils.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,14 @@ void listSetItem(Stack* stack);
589589
push(stack, op); \
590590
}, \
591591
aliasAnalysisFromSchema())
592-
592+
#define DEFINE_STRING_OP(op_name, string_op, result) \
593+
Operator( \
594+
#op_name ".str(str a, str b) ->" #result, \
595+
[](Stack* stack) { \
596+
auto b = pop(stack).toStringRef(); \
597+
auto a = pop(stack).toStringRef(); \
598+
push(stack, string_op); \
599+
}, \
600+
aliasAnalysisFromSchema())
593601
} // namespace jit
594602
} // namespace torch

torch/csrc/jit/runtime/register_prim_ops.cpp

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -322,32 +322,6 @@ RegisterOperators reg(
322322
pack(stack, result);
323323
},
324324
aliasAnalysisFromSchema()),
325-
// only used internally in range() translation
326-
Operator(
327-
"aten::__range_length(int lo, int hi, int step) -> int",
328-
[](Stack* stack) {
329-
int64_t lo, hi, step;
330-
pop(stack, lo, hi, step);
331-
// error handling when step_val = 0 during runtime
332-
if (step == 0) {
333-
throw std::runtime_error("range() arg 3 must not be zero");
334-
}
335-
if (step > 0 && lo < hi)
336-
push(stack, 1 + (hi - 1 - lo) / step);
337-
else if (step < 0 && lo > hi)
338-
push(stack, 1 + (lo - 1 - hi) / (0 - step));
339-
else
340-
push(stack, 0);
341-
},
342-
aliasAnalysisFromSchema()),
343-
Operator(
344-
"aten::__derive_index(int index, int start, int step) -> int",
345-
[](Stack* stack) {
346-
int64_t index, start, step;
347-
pop(stack, index, start, step);
348-
push(stack, start + index * step);
349-
},
350-
aliasAnalysisFromSchema()),
351325
// these ops are generic over the list element type.
352326
// CREATING GENERIC_LIST_OPS
353327
Operator(
@@ -450,6 +424,7 @@ RegisterOperators reg(
450424
handler(ss.str());
451425
},
452426
aliasAnalysisSpecialCase()),
427+
DEFINE_STRING_OP(aten::add, a + b, str),
453428
DEFINE_COMPARISON_OP(aten::eq, a == b),
454429
DEFINE_COMPARISON_OP(aten::ne, a != b),
455430
DEFINE_COMPARISON_OP(aten::lt, a < b),

torch/csrc/jit/runtime/register_prim_ops_fulljit.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -687,20 +687,6 @@ void hashValue(Stack* stack) {
687687

688688
RegisterOperators reg2({
689689

690-
#define DEFINE_STRING_OP(op_name, string_op, result) \
691-
Operator( \
692-
#op_name "(str a, str b) ->" #result, \
693-
[](Stack* stack) { \
694-
auto b = pop(stack).toStringRef(); \
695-
auto a = pop(stack).toStringRef(); \
696-
push(stack, string_op); \
697-
}, \
698-
aliasAnalysisFromSchema())
699-
700-
DEFINE_STRING_OP(aten::eq, a == b, bool),
701-
DEFINE_STRING_OP(aten::ne, a != b, bool),
702-
DEFINE_STRING_OP(aten::add, a + b, str),
703-
#undef DEFINE_STRING_OP
704690
Operator(
705691
"aten::__getitem__.str(str s, int index) -> str",
706692
[](Stack* stack) {

0 commit comments

Comments
 (0)