Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Prim][PIR] support floor_divide op forward in prim pir #64023

Merged
merged 2 commits into from
May 7, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"elu",
"embedding",
"flatten",
"floor_divide",
"full_like",
"gelu",
"hardswish",
Expand Down Expand Up @@ -67,6 +68,7 @@
"elu",
"embedding",
"flatten",
"floor_divide",
"full_like",
"gelu",
"hardswish",
Expand Down
8 changes: 8 additions & 0 deletions paddle/fluid/primitive/composite/composite.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,14 @@ Tensor full_like_decomp(const Tensor& x,
}
}

template <typename T>
Tensor floor_divide_decomp(const Tensor& x, const Tensor& y) {
auto x_cast = cast<T>(x, DataType::INT64);
auto y_cast = cast<T>(y, DataType::INT64);
auto res = x_cast / y_cast;
return cast<T>(res, x.dtype());
}

template <typename T>
std::tuple<Tensor, Tensor> dropout_decomp(
const Tensor& x,
Expand Down
4 changes: 3 additions & 1 deletion test/deprecated/legacy_test/test_elementwise_floordiv_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def init_kernel_type(self):

def setUp(self):
self.op_type = "elementwise_floordiv"
self.prim_op_type = "comp"
self.python_api = paddle.floor_divide
self.public_python_api = paddle.floor_divide
self.dtype = np.int32
self.axis = -1
self.init_dtype()
Expand All @@ -45,7 +47,7 @@ def setUp(self):
self.outputs = {'Out': self.out}

def test_check_output(self):
self.check_output(check_pir=True)
self.check_output(check_pir=True, check_prim_pir=True)

def init_input_output(self):
self.x = np.random.uniform(0, 10000, [10, 10]).astype(self.dtype)
Expand Down