Skip to content

Commit

Permalink
[Paddle Tensorrt] change int32 to int64 in test file (#69191)
Browse files Browse the repository at this point in the history
* mod int64

* rm pass_test

* change np

* change file

* fix bug

* fix conflict

* add test mod

* Update

* fix conflict

* update third_party

* update flashattn

* change type
  • Loading branch information
Hanyonggong authored Dec 17, 2024
1 parent 1e4a234 commit 7635015
Show file tree
Hide file tree
Showing 49 changed files with 95 additions and 2,669 deletions.
134 changes: 0 additions & 134 deletions test/tensorrt/pass_test.py

This file was deleted.

4 changes: 2 additions & 2 deletions test/tensorrt/test_converter_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ def setUp(self):
"x": x_nchw,
"OutSize": None,
"SizeTensor": [
np.array([12], dtype="int32"),
np.array([12], dtype="int32"),
np.array([12], dtype="int64"),
np.array([12], dtype="int64"),
],
"Scale": None,
"attrs": {
Expand Down
8 changes: 4 additions & 4 deletions test/tensorrt/test_converter_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ class TestArangeTRTPattern(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.arange
self.api_args = {
"start": np.array([0]).astype("int32"),
"end": np.array([6]).astype("int32"),
"step": np.array([1]).astype("int32"),
"start": np.array([0]).astype("int64"),
"end": np.array([6]).astype("int64"),
"step": np.array([1]).astype("int64"),
}
self.program_config = {"feed_list": []}
self.min_shape = {}
Expand Down Expand Up @@ -195,7 +195,7 @@ class TestFullWithTensorTRTPattern(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.tensor.fill_constant
self.api_args = {
"shape": np.array([1]).astype("int32"),
"shape": np.array([1]).astype("int64"),
"dtype": "float32",
"value": np.array([0.0]).astype("float32"),
}
Expand Down
20 changes: 10 additions & 10 deletions test/tensorrt/test_converter_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class TestGreaterThanFloat32TRTPattern(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.greater_than
self.api_args = {
"x": np.random.randn(2, 3).astype(np.float32),
"y": np.random.randn(3).astype(np.float32),
"x": np.random.randn(2, 3).astype("float32"),
"y": np.random.randn(3).astype("float32"),
}
self.program_config = {"feed_list": ["x", "y"]}
self.min_shape = {"x": [1, 3], "y": [3]}
Expand All @@ -35,12 +35,12 @@ def test_trt_result(self):
self.check_trt_result()


class TestGreaterThanInt32TRTPattern(TensorRTBaseTest):
class TestGreaterThanInt64TRTPattern(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.greater_than
self.api_args = {
"x": np.random.randn(3).astype(np.int32),
"y": np.random.randn(3).astype(np.int32),
"x": np.random.randn(3).astype("int64"),
"y": np.random.randn(3).astype("int64"),
}
self.program_config = {"feed_list": ["x", "y"]}
self.min_shape = {"x": [1], "y": [1]}
Expand All @@ -54,8 +54,8 @@ class TestLessThanFloat32TRTPattern(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.less_than
self.api_args = {
"x": np.random.randn(2, 3).astype(np.float32),
"y": np.random.randn(3).astype(np.float32),
"x": np.random.randn(2, 3).astype("float32"),
"y": np.random.randn(3).astype("float32"),
}
self.program_config = {"feed_list": ["x", "y"]}
self.min_shape = {"x": [1, 3], "y": [3]}
Expand All @@ -65,12 +65,12 @@ def test_trt_result(self):
self.check_trt_result()


class TestLessThanInt32TRTPattern(TensorRTBaseTest):
class TestLessThanInt64TRTPattern(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.less_than
self.api_args = {
"x": np.random.randn(3).astype(np.int32),
"y": np.random.randn(3).astype(np.int32),
"x": np.random.randn(3).astype("int64"),
"y": np.random.randn(3).astype("int64"),
}
self.program_config = {"feed_list": ["x", "y"]}
self.min_shape = {"x": [1], "y": [1]}
Expand Down
59 changes: 34 additions & 25 deletions test/tensorrt/test_converter_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,46 @@ class TestCast0TRTPattern(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.cast
self.api_args = {
"x": np.random.randn(7, 3).astype(np.float32),
"out_dtype": np.bool_,
"x": np.random.randn(7, 3).astype("float32"),
"out_dtype": "bool",
}
self.program_config = {"feed_list": ["x"]}
self.min_shape = {"x": [3, 3]}
self.max_shape = {"x": [10, 3]}

def test_trt_result(self):
self.check_trt_result()


class TestCast1TRTPattern(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.cast
self.api_args = {
"x": np.random.randn(7, 3).astype(np.float16),
"out_dtype": np.int32,
"x": np.random.randn(7, 3).astype("float16"),
"out_dtype": "int32",
}
self.program_config = {"feed_list": ["x"]}
self.min_shape = {"x": [3, 3]}
self.max_shape = {"x": [10, 3]}

def test_trt_result(self):
self.check_trt_result()


class TestCast2TRTPattern(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.cast
self.api_args = {
"x": np.random.randn(7, 3).astype(np.float32),
"out_dtype": np.int64,
"x": np.random.randn(7, 3).astype("float32"),
"out_dtype": "int64",
}
self.program_config = {"feed_list": ["x"]}
self.min_shape = {"x": [3, 3]}
self.max_shape = {"x": [10, 3]}

def test_trt_result(self):
self.check_trt_result()


class TestConcatTRTPattern(TensorRTBaseTest):
def setUp(self):
Expand Down Expand Up @@ -112,7 +121,7 @@ def setUp(self):
self.python_api = paddle.expand
self.api_args = {
"x": np.random.randn(1, 3).astype("float32"),
"shape": np.array([6, 3]).astype("int32"),
"shape": np.array([6, 3]).astype("int64"),
}
self.program_config = {"feed_list": ["x", "shape"]}
self.min_shape = {"x": [1, 3]}
Expand Down Expand Up @@ -183,7 +192,7 @@ def setUp(self):
self.api_args = {
"x": np.array([[1, 2, 3]]).astype("float32"),
"y": np.array([[1, 2, 3], [4, 5, 6], [1, 2, 3], [4, 5, 6]]).astype(
"int32"
"int64"
),
}
self.program_config = {"feed_list": ["x", "y"]}
Expand All @@ -200,8 +209,8 @@ def setUp(self):
self.api_args = {
"x": np.random.random([5, 4, 5, 6]).astype("float32"),
"axes": [0, 1, 2],
"starts": np.array([1, 0, 2]).astype("int32"),
"ends": np.array([3, 3, 4]).astype("int32"),
"starts": np.array([1, 0, 2]).astype("int64"),
"ends": np.array([3, 3, 4]).astype("int64"),
}
self.program_config = {"feed_list": ["x", "starts", "ends"]}
self.min_shape = {"x": [3, 4, 5, 6]}
Expand All @@ -215,7 +224,7 @@ class TestSplitWithNumTRTPattern(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.split
self.api_args = {
"x": np.random.randn(3, 9, 5).astype(np.float32),
"x": np.random.randn(3, 9, 5).astype("float32"),
"num_or_sections": 3,
"axis": 1,
}
Expand All @@ -231,9 +240,9 @@ class TestSplitWithNumAxisTRTPattern(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.split
self.api_args = {
"x": np.random.randn(3, 9, 5).astype(np.float32),
"x": np.random.randn(3, 9, 5).astype("float32"),
"num_or_sections": 3,
"axis": np.array([1]).astype("int32"),
"axis": np.array([1]).astype("int64"),
}
self.program_config = {"feed_list": ["x", "axis"]}
self.min_shape = {"x": [1, 9, 5]}
Expand All @@ -247,9 +256,9 @@ class TestSplitWithNumAllTRTPattern(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.split
self.api_args = {
"x": np.random.randn(1, 2).astype(np.float32),
"x": np.random.randn(1, 2).astype("float32"),
"num_or_sections": 2,
"axis": np.array([1]).astype("int32"),
"axis": np.array([1]).astype("int64"),
}
self.program_config = {"feed_list": ["x", "axis"]}
self.min_shape = {"x": [1, 2]}
Expand All @@ -263,7 +272,7 @@ class TestSplitWithNumNegativeAxisTRTPattern(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.split
self.api_args = {
"x": np.random.randn(3, 9, 5).astype(np.float32),
"x": np.random.randn(3, 9, 5).astype("float32"),
"num_or_sections": 3,
"axis": -2,
}
Expand Down Expand Up @@ -297,7 +306,7 @@ def setUp(self):
self.api_args = {
"x": np.random.randn(3, 9, 5).astype("float32"),
"num_or_sections": [2, 4, 3],
"axis": np.array([1]).astype("int32"),
"axis": np.array([1]).astype("int64"),
}
self.program_config = {"feed_list": ["x", "axis"]}
self.min_shape = {"x": [1, 9, 5]}
Expand All @@ -316,7 +325,7 @@ def setUp(self):
self.python_api = split_api
self.api_args = {
"x": np.random.randn(3, 9, 5).astype("float32"),
"num_or_sections": np.array([2, 4, 3]).astype("int32"),
"num_or_sections": np.array([2, 4, 3]).astype("int64"),
"axis": 1,
}
self.program_config = {"feed_list": ["x", "num_or_sections"]}
Expand All @@ -332,8 +341,8 @@ def setUp(self):
self.python_api = split_api
self.api_args = {
"x": np.random.randn(3, 9, 5).astype("float32"),
"num_or_sections": np.array([2, 4, 3]).astype("int32"),
"axis": np.array([1]).astype("int32"),
"num_or_sections": np.array([2, 4, 3]).astype("int64"),
"axis": np.array([1]).astype("int64"),
}
self.program_config = {"feed_list": ["x", "num_or_sections", "axis"]}
self.min_shape = {"x": [1, 9, 5]}
Expand Down Expand Up @@ -367,9 +376,9 @@ def setUp(self):
self.python_api = paddle.stack
self.api_args = {
"x": [
np.array([[1, 2]]).astype("int32"),
np.array([[3, 4]]).astype("int32"),
np.array([[5, 6]]).astype("int32"),
np.array([[1, 2]]).astype("int64"),
np.array([[3, 4]]).astype("int64"),
np.array([[5, 6]]).astype("int64"),
],
"axis": -1,
}
Expand Down Expand Up @@ -400,8 +409,8 @@ class TestTileTRTPatternCase1(TensorRTBaseTest):
def setUp(self):
self.python_api = paddle.tile
self.api_args = {
"x": np.random.randn(1, 2, 3).astype("int32"),
"repeat_times": np.array([1, 2, 3, 4]).astype("int32"),
"x": np.random.randn(1, 2, 3).astype("int64"),
"repeat_times": np.array([1, 2, 3, 4]).astype("int64"),
}
self.program_config = {"feed_list": ["x", "repeat_times"]}
self.min_shape = {"x": [1, 2, 3]}
Expand Down
Loading

0 comments on commit 7635015

Please sign in to comment.