Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into side-effects-list
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo committed Jul 4, 2023
2 parents ded1080 + 019b846 commit cf9c355
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
10 changes: 8 additions & 2 deletions sot/opcode_translator/executor/opcode_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,6 @@ def ROT_FOUR(self, instr: Instruction):
BINARY_OR = tos_op_wrapper(operator.or_)
BINARY_XOR = tos_op_wrapper(operator.xor)

@call_break_graph_decorator(push_n=1)
def BINARY_SUBSCR(self, instr: Instruction):
key = self.pop()
container = self.pop()
Expand Down Expand Up @@ -736,7 +735,6 @@ def BINARY_SUBSCR(self, instr: Instruction):
def NOP(self, instr: Instruction):
pass

@call_break_graph_decorator(push_n=1)
def LOAD_ATTR(self, instr: Instruction):
attr_name = instr.argval
obj = self.pop()
Expand Down Expand Up @@ -1775,6 +1773,14 @@ def CALL_FUNCTION_KW(self, instr: Instruction):
def CALL_FUNCTION_EX(self, instr: Instruction):
super().CALL_FUNCTION_EX(instr)

@call_break_graph_decorator(push_n=1)
def LOAD_ATTR(self, instr: Instruction):
super().LOAD_ATTR(instr)

@call_break_graph_decorator(push_n=1)
def BINARY_SUBSCR(self, instr: Instruction):
super().BINARY_SUBSCR(instr)

def RETURN_VALUE(self, instr: Instruction):
assert (
len(self._stack) == 1
Expand Down
2 changes: 1 addition & 1 deletion sot/opcode_translator/executor/variable_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
getattr,
("VariableBase", "ConstantVariable"),
{},
lambda var, name, default: var.getattr(name.get_value(), default),
lambda var, name: var.getattr(name.get_value()),
)
Dispatcher.register(
getattr,
Expand Down
2 changes: 0 additions & 2 deletions tests/run_all_paddle_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ disabled_tests=(
${PADDLE_TEST_BASE}/test_lac.py # disabled by paddle
${PADDLE_TEST_BASE}/test_sentiment.py # disabled unitcase by paddle
${PADDLE_TEST_BASE}/test_reinforcement_learning.py # 'CartPoleEnv' object has no attribute 'seed'
${PADDLE_TEST_BASE}/test_resnet_v2.py # segment error: oneDNN
${PADDLE_TEST_BASE}/test_resnet.py # segment error: oneDNN
# tmp = x
# for i in range(x)
# tmp += Linear(x)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_builtin_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,17 @@ def test_dispatch_bool(self):
self.assert_results(dispatch_bool, paddle.to_tensor([1, 2, 3]))


def run_getattr(x: paddle.Tensor):
attr = 'dtype'
out = getattr(x, attr)
return out


class TestGetattr(TestCaseBase):
def test_getattr(self):
x = paddle.to_tensor(4)
self.assert_results(run_getattr, x)


if __name__ == "__main__":
unittest.main()

0 comments on commit cf9c355

Please sign in to comment.