Skip to content
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
3 changes: 3 additions & 0 deletions paddle/fluid/pir/transforms/tensorrt/trt_op_marker_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,8 @@ class LogicalCommonOpPattern : public pir::OpRewritePattern<OpType> {
return true;
}
};
using LogicalXorOpPattern =
LogicalCommonOpPattern<paddle::dialect::LogicalXorOp>;
using LogicalOrOpPattern = LogicalCommonOpPattern<paddle::dialect::LogicalOrOp>;
using LogicalOr_OpPattern =
LogicalCommonOpPattern<paddle::dialect::LogicalOr_Op>;
Expand Down Expand Up @@ -2268,6 +2270,7 @@ class TrtOpMarkerPass : public pir::PatternRewritePass {
ps.Add(std::make_unique<SetValueWithTensor_OpPattern>(context));
ps.Add(std::make_unique<EqualOpPattern>(context));
ps.Add(std::make_unique<NotEqualOpPattern>(context));
ps.Add(std::make_unique<LogicalXorOpPattern>(context));
ps.Add(std::make_unique<TanhOpPattern>(context));
ps.Add(std::make_unique<CeluOpPattern>(context));
ps.Add(std::make_unique<OneHotOpPattern>(context));
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/tensorrt/impls/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"pd_op.greater_than": trt.ElementWiseOperation.GREATER,
"pd_op.less_than": trt.ElementWiseOperation.LESS,
"pd_op.equal": trt.ElementWiseOperation.EQUAL,
"pd_op.logical_xor": trt.ElementWiseOperation.XOR,
"pd_op.logical_or": trt.ElementWiseOperation.OR,
"pd_op.logical_or_": trt.ElementWiseOperation.OR,
"pd_op.logical_and": trt.ElementWiseOperation.AND,
Expand All @@ -32,6 +33,7 @@
@converter_registry.register("pd_op.greater_than", trt_version="8.x")
@converter_registry.register("pd_op.less_than", trt_version="8.x")
@converter_registry.register("pd_op.equal", trt_version="8.x")
@converter_registry.register("pd_op.logical_xor", trt_version="8.x")
@converter_registry.register("pd_op.logical_or", trt_version="8.x")
@converter_registry.register("pd_op.logical_or_", trt_version="8.x")
@converter_registry.register("pd_op.logical_and", trt_version="8.x")
Expand Down
39 changes: 39 additions & 0 deletions test/tensorrt/test_converter_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,44 @@ def test_trt_result(self):
self.check_marker(expected_result=False)


class TestLogicalXorTRTPattern(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.logical_xor

def test_trt_result(self):
self.api_args = {
"x": np.random.choice([True, False], size=(3,)).astype("bool"),
"y": np.random.choice([True, False], size=(3,)).astype("bool"),
}
self.program_config = {"feed_list": ["x", "y"]}
self.min_shape = {"x": [1], "y": [1]}
self.max_shape = {"x": [5], "y": [5]}
self.check_trt_result()

def test_trt_diff_shape_result(self):
self.api_args = {
"x": np.random.choice([True, False], size=(2, 3)).astype("bool"),
"y": np.random.choice([True, False], size=(3)).astype("bool"),
}
self.program_config = {"feed_list": ["x", "y"]}
self.min_shape = {"x": [1, 3], "y": [3]}
self.max_shape = {"x": [4, 3], "y": [3]}
self.check_trt_result()


class TestLogicalXorMarker(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.logical_xor
self.api_args = {
"x": np.random.randn(3).astype("int64"),
"y": np.random.randn(3).astype("int64"),
}
self.program_config = {"feed_list": ["x", "y"]}
self.target_marker_op = "pd_op.logical_xor"

def test_trt_result(self):
self.check_marker(expected_result=False)


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