Skip to content

Commit

Permalink
[PIR] No.43 Migrate paddle.unsqueeze into pir (#57617)
Browse files Browse the repository at this point in the history
* update unsqueeze in new ir

* fix bug

* Update test_unsqueeze2_op.py

* Update test_unsqueeze_op.py

* Update test_unsqueeze2_op.py
  • Loading branch information
longranger2 authored Sep 26, 2023
1 parent d55bb44 commit bd1584b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion python/paddle/tensor/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,7 @@ def unsqueeze(x, axis, name=None):
"""
input = x
axes = axis
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
if isinstance(axes, int):
axes = [axes]
elif isinstance(axes, Variable):
Expand Down
14 changes: 8 additions & 6 deletions test/legacy_test/test_unsqueeze2_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ def if_enable_cinn(self):
pass

def test_check_output(self):
self.check_output(no_check_set=["XShape"], check_prim=True)
self.check_output(
no_check_set=["XShape"], check_prim=True, check_new_ir=True
)

def test_check_grad(self):
self.check_grad(["X"], "Out", check_prim=True)
self.check_grad(["X"], "Out", check_prim=True, check_new_ir=True)

def init_test_case(self):
self.ori_shape = (3, 40)
Expand Down Expand Up @@ -135,10 +137,10 @@ def setUp(self):
}

def test_check_output(self):
self.check_output(no_check_set=["XShape"])
self.check_output(no_check_set=["XShape"], check_new_ir=True)

def test_check_grad(self):
self.check_grad(["X"], "Out")
self.check_grad(["X"], "Out", check_new_ir=True)

def init_test_case(self):
self.ori_shape = (20, 5)
Expand Down Expand Up @@ -196,10 +198,10 @@ def setUp(self):
}

def test_check_output(self):
self.check_output(no_check_set=["XShape"])
self.check_output(no_check_set=["XShape"], check_new_ir=True)

def test_check_grad(self):
self.check_grad(["X"], "Out")
self.check_grad(["X"], "Out", check_new_ir=True)

def init_test_case(self):
self.ori_shape = (20, 5)
Expand Down

0 comments on commit bd1584b

Please sign in to comment.