Skip to content

Commit

Permalink
Enhance several unit tests (#62477) (#62776)
Browse files Browse the repository at this point in the history
* Manually release predictor_tuned
* Add indices to no_cast_list to keep it as fp32
* Set both atol and rtol for the fp16 test_trt_convert_solve
* Merge branch 'rewang/fix_test_sparse_fused_attention_seed' into 'nv-2.6.0'

Fix test_sparse_fused_attention random seed

See merge request dl/paddle/paddle!312

---------

Signed-off-by: rewang <rewang@nvidia.com>
Co-authored-by: Ryan Jeng <rjeng@nvidia.com>
  • Loading branch information
zlsh80826 and jeng1220 authored Mar 19, 2024
1 parent 97ffa07 commit 0348f3f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/cpp/inference/api/trt_dynamic_shape_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ void TestTunedDynamic() {
output_t->copy_to_cpu(out_data.data());
};
check_func(predictor_tuned.get());
predictor_tuned.reset(nullptr);

// check tuned_dynamic_shape
AnalysisConfig config;
Expand Down
1 change: 1 addition & 0 deletions test/ir/inference/test_trt_convert_lookup_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def generate_input2(dims, attrs: List[Dict[str, Any]]):
)
},
outputs=["out_data"],
no_cast_list=["indices"],
)

yield program_config
Expand Down
2 changes: 1 addition & 1 deletion test/ir/inference/test_trt_convert_solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def clear_dynamic_shape():
yield self.create_inference_config(), (1, 3), 1e-5

self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), (1, 3), 1e-3
yield self.create_inference_config(), (1, 3), (1e-3, 1e-3)

def test(self):
self.run_test()
Expand Down
5 changes: 5 additions & 0 deletions test/legacy_test/test_sparse_fused_attention_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def get_cuda_version():
)
class TestSparseAttentionAPI1(unittest.TestCase):
def setUp(self):
paddle.seed(0)
self.batch_size = 16
self.num_heads = 16
self.seq_len = 128
Expand Down Expand Up @@ -134,6 +135,7 @@ def test_dygraph(self):

class TestSparseAttentionAPI2(TestSparseAttentionAPI1):
def setUp(self):
super().setUp()
self.batch_size = 16
self.num_heads = 16
self.seq_len = 128
Expand All @@ -144,6 +146,7 @@ def setUp(self):

class TestSparseAttentionAPI3(TestSparseAttentionAPI1):
def setUp(self):
super().setUp()
self.batch_size = 16
self.num_heads = 16
self.seq_len = 512
Expand All @@ -154,6 +157,7 @@ def setUp(self):

class TestSparseAttentionAPI4(TestSparseAttentionAPI1):
def setUp(self):
super().setUp()
self.batch_size = 16
self.num_heads = 16
self.seq_len = 512
Expand All @@ -164,6 +168,7 @@ def setUp(self):

class TestSparseAttentionAPI5(TestSparseAttentionAPI1):
def setUp(self):
super().setUp()
self.batch_size = 16
self.num_heads = 16
self.seq_len = 512
Expand Down

0 comments on commit 0348f3f

Please sign in to comment.