未验证 提交 225a9c4e 编写于 作者: S Shang Zhizhou 提交者: GitHub

Fix unittest (#29412)

* fix tensorrt unittest precision error

* fix unittest precision error. test_trt_subgraph_pass && test_trt_dynamic_shape_transformer_prune
上级 f860de4a
...@@ -126,7 +126,7 @@ void trt_ernie(bool with_fp16, std::vector<float> result) { ...@@ -126,7 +126,7 @@ void trt_ernie(bool with_fp16, std::vector<float> result) {
run(config, &out_data); run(config, &out_data);
for (size_t i = 0; i < out_data.size(); i++) { for (size_t i = 0; i < out_data.size(); i++) {
EXPECT_NEAR(result[i], out_data[i], 1e-4); EXPECT_NEAR(result[i], out_data[i], 2e-3);
} }
} }
......
...@@ -308,7 +308,10 @@ class TensorRTSubgraphPassActivationTest(InferencePassTest): ...@@ -308,7 +308,10 @@ class TensorRTSubgraphPassActivationTest(InferencePassTest):
use_gpu = True use_gpu = True
if os.path.exists(self.path + "_opt_cache"): if os.path.exists(self.path + "_opt_cache"):
shutil.rmtree(self.path + "_opt_cache") shutil.rmtree(self.path + "_opt_cache")
if self.trt_parameters.precision == AnalysisConfig.Precision.Float32:
self.check_output_with_option(use_gpu) self.check_output_with_option(use_gpu)
else:
self.check_output_with_option(use_gpu, 1e-3)
self.assertTrue( self.assertTrue(
PassVersionChecker.IsCompatible('tensorrt_subgraph_pass')) PassVersionChecker.IsCompatible('tensorrt_subgraph_pass'))
...@@ -572,7 +575,7 @@ class TensorRTSubgraphPassDynamicSplitFp16SerializeTest(InferencePassTest): ...@@ -572,7 +575,7 @@ class TensorRTSubgraphPassDynamicSplitFp16SerializeTest(InferencePassTest):
use_gpu = True use_gpu = True
if os.path.exists(self.path + "_opt_cache"): if os.path.exists(self.path + "_opt_cache"):
shutil.rmtree(self.path + "_opt_cache") shutil.rmtree(self.path + "_opt_cache")
self.check_output_with_option(use_gpu) self.check_output_with_option(use_gpu, 1e-3)
self.assertTrue( self.assertTrue(
PassVersionChecker.IsCompatible('tensorrt_subgraph_pass')) PassVersionChecker.IsCompatible('tensorrt_subgraph_pass'))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册