Skip to content

Commit

Permalink
add unittest of elementwise mul, sub and div
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxinxin08 committed Mar 23, 2022
1 parent c163aae commit b655946
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ def generate_input(shape):
return np.random.random(shape).astype(np.float32)

for shape in [[4], [4, 32], [2, 64, 32], [1, 8, 16, 32]]:
for op_type in ["elementwise_add", "elementwise_mul"]:
for op_type in [
"elementwise_add", "elementwise_mul", "elementwise_sub",
"elementwise_div"
]:
for axis in [0, -1]:
self.dims = len(shape)
dics = [{"axis": axis}]
Expand Down Expand Up @@ -306,7 +309,10 @@ def generate_input(shape):
input1_shape = input1_shape_list[i]
for j in range(6):
input2_shape = input2_shape_list[j][i]
for op_type in ["elementwise_add", "elementwise_mul"]:
for op_type in [
"elementwise_add", "elementwise_mul", "elementwise_sub",
"elementwise_div"
]:
for axis in axis_list[j][i]:
self.shape1 = input1_shape
self.shape2 = input2_shape
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,23 @@ def test_check_output(self):
PassVersionChecker.IsCompatible('tensorrt_subgraph_pass'))


class TensorRTSubgraphPassElementwiseBroadcastTest1(
TensorRTSubgraphPassElementwiseBroadcastTest):
def append_eltwise(self, data1, data2):
return fluid.layers.elementwise_sub(x=data1, y=data2, axis=0)


class TensorRTSubgraphPassElementwiseBroadcastTest2(
TensorRTSubgraphPassElementwiseBroadcastTest):
def append_eltwise(self, data1, data2):
return fluid.layers.elementwise_mul(x=data1, y=data2, axis=0)


class TensorRTSubgraphPassElementwiseBroadcastTest3(
TensorRTSubgraphPassElementwiseBroadcastTest):
def append_eltwise(self, data1, data2):
return fluid.layers.elementwise_div(x=data1, y=data2, axis=0)


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

1 comment on commit b655946

@paddle-bot-old
Copy link

@paddle-bot-old paddle-bot-old bot commented on b655946 Mar 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵️ CI failures summary

🔍 PR: #40806 Commit ID: b655946 contains failed CI.

🔹 Failed: PR-CI-ScienceTest

Unknown Failed
Unknown Failed

🔹 Failed: PR-CI-Static-Check

Unknown Failed
Unknown Failed

Please sign in to comment.