Skip to content

Commit

Permalink
Loose TRT half test tolerance to 1e-3 (PaddlePaddle#47101)
Browse files Browse the repository at this point in the history
  • Loading branch information
zlsh80826 committed Nov 21, 2022
1 parent a5ff838 commit 1580a9a
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, False), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False), 1e-5
attrs, False), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
Expand All @@ -143,7 +143,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, True), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, True), 1e-5
attrs, True), 1e-3

def test(self):
self.run_test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, False), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False), 1e-5
attrs, False), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
Expand All @@ -129,7 +129,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, True), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, True), 1e-5
attrs, True), 1e-3

def test(self):
self.run_test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons
from trt_layer_auto_scan_test import TrtLayerAutoScanTest
from program_config import TensorConfig, ProgramConfig
import numpy as np
import paddle.inference as paddle_infer
from functools import partial
from typing import Optional, List, Callable, Dict, Any, Set
from typing import List
import unittest
import os

Expand Down Expand Up @@ -98,7 +98,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, False), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False), 1e-5
attrs, False), 1e-3

# The output has little diff between gpu and trt in CI-Windows-Inference
tol_fp32 = 1e-4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, False), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False), 1e-5
attrs, False), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
Expand All @@ -147,7 +147,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, True), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, True), 1e-5
attrs, True), 1e-3

def test(self):
self.run_test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, False), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False), 1e-5
attrs, False), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
Expand All @@ -308,7 +308,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, True), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, True), 1e-5
attrs, True), 1e-3

def add_skip_trt_case(self):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, False), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False), (1e-5, 1e-3)
attrs, False), (1e-3, 1e-3)
# self.trt_param.precision = paddle_infer.PrecisionType.Int8
# yield self.create_inference_config(), generate_trt_nodes_num(
# attrs, False), (1e-5, 1e-5)
Expand All @@ -193,7 +193,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, True), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, True), (1e-5, 1e-3)
attrs, True), (1e-3, 1e-3)
# self.trt_param.precision = paddle_infer.PrecisionType.Int8
# yield self.create_inference_config(), generate_trt_nodes_num(
# attrs, True), (1e-5, 1e-5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, False), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False), 1e-5
attrs, False), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
Expand All @@ -140,7 +140,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, True), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, True), 1e-5
attrs, True), 1e-3

def add_skip_trt_case(self):
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, False), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False), 1e-5
attrs, False), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
Expand All @@ -156,7 +156,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, True), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, True), 1e-5
attrs, True), 1e-3

def test(self):
self.run_test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def generate_trt_nodes_num(dynamic_shape):
False), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
False), 1e-5
False), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ def clear_dynamic_shape():
self.trt_param.precision = paddle_infer.PrecisionType.Float32
yield self.create_inference_config(), (0, 4), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), (0, 4), 1e-5
yield self.create_inference_config(), (0, 4), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
self.trt_param.precision = paddle_infer.PrecisionType.Float32
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-5
yield self.create_inference_config(), (1, 3), 1e-3

def add_skip_trt_case(self):

Expand Down Expand Up @@ -188,14 +188,14 @@ def clear_dynamic_shape():
self.trt_param.precision = paddle_infer.PrecisionType.Float32
yield self.create_inference_config(), (0, 4), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), (0, 4), 1e-5
yield self.create_inference_config(), (0, 4), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
self.trt_param.precision = paddle_infer.PrecisionType.Float32
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-5
yield self.create_inference_config(), (1, 3), 1e-3

def add_skip_trt_case(self):

Expand Down Expand Up @@ -281,14 +281,14 @@ def clear_dynamic_shape():
self.trt_param.precision = paddle_infer.PrecisionType.Float32
yield self.create_inference_config(), (0, 4), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), (0, 4), 1e-5
yield self.create_inference_config(), (0, 4), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
self.trt_param.precision = paddle_infer.PrecisionType.Float32
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-5
yield self.create_inference_config(), (1, 3), 1e-3

def add_skip_trt_case(self):

Expand Down Expand Up @@ -374,14 +374,14 @@ def clear_dynamic_shape():
self.trt_param.precision = paddle_infer.PrecisionType.Float32
yield self.create_inference_config(), (0, 4), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), (0, 4), 1e-5
yield self.create_inference_config(), (0, 4), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
self.trt_param.precision = paddle_infer.PrecisionType.Float32
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-5
yield self.create_inference_config(), (1, 3), 1e-3

def add_skip_trt_case(self):

Expand Down Expand Up @@ -467,14 +467,14 @@ def clear_dynamic_shape():
self.trt_param.precision = paddle_infer.PrecisionType.Float32
yield self.create_inference_config(), (0, 4), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), (0, 4), 1e-5
yield self.create_inference_config(), (0, 4), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
self.trt_param.precision = paddle_infer.PrecisionType.Float32
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-5
yield self.create_inference_config(), (1, 3), 1e-3

def add_skip_trt_case(self):

Expand Down Expand Up @@ -561,14 +561,14 @@ def clear_dynamic_shape():
self.trt_param.precision = paddle_infer.PrecisionType.Float32
yield self.create_inference_config(), (0, 4), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), (0, 4), 1e-5
yield self.create_inference_config(), (0, 4), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
self.trt_param.precision = paddle_infer.PrecisionType.Float32
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-5
yield self.create_inference_config(), (1, 3), 1e-3

def test(self):
self.run_test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, False), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False), 1e-5
attrs, False), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
Expand All @@ -135,7 +135,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, True), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, True), 1e-5
attrs, True), 1e-3

def test(self):
self.run_test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, False), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False), 1e-5
attrs, False), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
Expand All @@ -129,7 +129,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, True), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, True), 1e-5
attrs, True), 1e-3

def add_skip_trt_case(self):
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ def clear_dynamic_shape():
self.trt_param.precision = paddle_infer.PrecisionType.Float32
yield self.create_inference_config(), (1, 2), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), (1, 2), 1e-5
yield self.create_inference_config(), (1, 2), 1e-3

# for dynamic_shape
generate_dynamic_shape(attrs)
self.trt_param.precision = paddle_infer.PrecisionType.Float32
yield self.create_inference_config(), (1, 2), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), (1, 2), 1e-5
yield self.create_inference_config(), (1, 2), 1e-3

def test(self):
self.run_test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, False), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False), (1e-5, 1e-5)
attrs, False), (1e-3, 1e-3)

# for dynamic_shape
generate_dynamic_shape(attrs)
Expand All @@ -109,7 +109,7 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, True), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, True), (1e-5, 1e-5)
attrs, True), (1e-3, 1e-3)

def test(self):
self.run_test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, False), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False), (1e-5, 1e-5)
attrs, False), (1e-3, 1e-3)
self.trt_param.precision = paddle_infer.PrecisionType.Int8
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False), (1e-5, 1e-5)
attrs, False), (1e-3, 1e-3)

# for dynamic_shape
generate_dynamic_shape(attrs)
Expand All @@ -116,10 +116,10 @@ def generate_trt_nodes_num(attrs, dynamic_shape):
attrs, True), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, True), (1e-5, 1e-5)
attrs, True), (1e-3, 1e-3)
self.trt_param.precision = paddle_infer.PrecisionType.Int8
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, True), (1e-5, 1e-5)
attrs, True), (1e-3, 1e-3)

def test(self):
self.run_test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def clear_dynamic_shape():
self.trt_param.precision = paddle_infer.PrecisionType.Float32
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-5
yield self.create_inference_config(), (1, 3), 1e-3

def test(self):
self.run_test()
Expand Down Expand Up @@ -198,7 +198,7 @@ def generate_dynamic_shape(attrs):
self.trt_param.precision = paddle_infer.PrecisionType.Float32
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-5
yield self.create_inference_config(), (1, 3), 1e-3

def add_skip_trt_case(self):
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,15 @@ def clear_dynamic_shape():
self.trt_param.workspace_size = 2013265920
yield self.create_inference_config(), (1, 4), (1e-5, 1e-5)
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), (1, 4), (1e-5, 1e-5)
yield self.create_inference_config(), (1, 4), (1e-3, 1e-3)

# for dynamic_shape
generate_dynamic_shape(attrs)
self.trt_param.precision = paddle_infer.PrecisionType.Float32
self.trt_param.workspace_size = 2013265920
yield self.create_inference_config(), (1, 3), (1e-5, 1e-4)
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), (1, 3), (1e-5, 1e-5)
yield self.create_inference_config(), (1, 3), (1e-3, 1e-3)

def add_skip_trt_case(self):

Expand Down

0 comments on commit 1580a9a

Please sign in to comment.