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
5 changes: 3 additions & 2 deletions test/ir/inference/test_trt_convert_cumsum.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

import unittest
from functools import partial
from typing import List

import numpy as np
from program_config import ProgramConfig, TensorConfig
Expand Down Expand Up @@ -109,7 +110,7 @@ def generate_input1():

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape():
if self.dims == 0:
self.dynamic_shape.min_input_shape = {
Expand Down
36 changes: 19 additions & 17 deletions test/ir/inference/test_trt_convert_deformable_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

import unittest
from functools import partial
from typing import Any, Dict, List
from typing import Any

import numpy as np
from program_config import ProgramConfig, TensorConfig
Expand All @@ -41,9 +43,9 @@ def is_program_valid(self, program_config: ProgramConfig) -> bool:

def sample_program_configs(self):
def compute_output_size(
input_size: List[int],
kernel_sizes: List[int],
attrs: List[Dict[str, Any]],
input_size: list[int],
kernel_sizes: list[int],
attrs: list[dict[str, Any]],
):
strides = attrs[0]['strides']
paddings = attrs[0]['paddings']
Expand All @@ -58,17 +60,17 @@ def compute_output_size(

def generate_input1(
batch: int,
input_size: List[int],
kernel_sizes: List[int],
attrs: List[Dict[str, Any]],
input_size: list[int],
kernel_sizes: list[int],
attrs: list[dict[str, Any]],
):
return np.random.random([batch, 3] + input_size).astype(np.float32)

def generate_offset1(
batch: int,
input_size: List[int],
kernel_sizes: List[int],
attrs: List[Dict[str, Any]],
input_size: list[int],
kernel_sizes: list[int],
attrs: list[dict[str, Any]],
):
output_size = compute_output_size(input_size, kernel_sizes, attrs)
return np.random.random(
Expand All @@ -77,9 +79,9 @@ def generate_offset1(

def generate_mask1(
batch: int,
input_size: List[int],
kernel_sizes: List[int],
attrs: List[Dict[str, Any]],
input_size: list[int],
kernel_sizes: list[int],
attrs: list[dict[str, Any]],
):
output_size = compute_output_size(input_size, kernel_sizes, attrs)
return np.random.random(
Expand All @@ -88,9 +90,9 @@ def generate_mask1(

def generate_filter1(
batch: int,
input_size: List[int],
kernel_sizes: List[int],
attrs: List[Dict[str, Any]],
input_size: list[int],
kernel_sizes: list[int],
attrs: list[dict[str, Any]],
):
filter = np.random.random([6, 3] + kernel_sizes)
filter[0][0][0][0] = 8.8978638e-08
Expand Down Expand Up @@ -184,7 +186,7 @@ def generate_filter1(

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
self.dynamic_shape.min_input_shape = {
"input_data": [1, 3, 32, 32],
Expand Down
10 changes: 6 additions & 4 deletions test/ir/inference/test_trt_convert_depthwise_conv2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

import itertools
import unittest
from functools import partial
from typing import Any, Dict, List
from typing import Any

import numpy as np
from program_config import ProgramConfig, TensorConfig
Expand Down Expand Up @@ -43,11 +45,11 @@ def is_program_valid(self, program_config: ProgramConfig) -> bool:
def sample_program_configs(self):
self.trt_param.workspace_size = 1073741824

def generate_input1(batch, attrs: List[Dict[str, Any]]):
def generate_input1(batch, attrs: list[dict[str, Any]]):
groups = attrs[0]['groups']
return np.ones([batch, groups, 64, 64]).astype(np.float32)

def generate_weight1(attrs: List[Dict[str, Any]]):
def generate_weight1(attrs: list[dict[str, Any]]):
return np.random.random([24, 1, 3, 3]).astype(np.float32)

batch_options = [1]
Expand Down Expand Up @@ -120,7 +122,7 @@ def generate_weight1(attrs: List[Dict[str, Any]]):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
groups = attrs[0]['groups']
self.dynamic_shape.min_input_shape = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
import unittest
from functools import partial
from itertools import product
from typing import Any, Generator
from typing import TYPE_CHECKING, Any

import numpy as np
from program_config import ProgramConfig, TensorConfig
from trt_layer_auto_scan_test import SkipReasons, TrtLayerAutoScanTest

import paddle.inference as paddle_infer

if TYPE_CHECKING:
from collections.abc import Generator


class TrtConvertDepthwiseConv2dTransposeTest(TrtLayerAutoScanTest):
def is_program_valid(self, program_config: ProgramConfig) -> bool:
Expand Down
8 changes: 5 additions & 3 deletions test/ir/inference/test_trt_convert_dropout.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

import unittest
from functools import partial
from typing import Any, Dict, List
from typing import Any

import numpy as np
from program_config import ProgramConfig, TensorConfig
Expand All @@ -28,7 +30,7 @@ def is_program_valid(self, program_config: ProgramConfig) -> bool:
return True

def sample_program_configs(self):
def generate_input(attrs: List[Dict[str, Any]]):
def generate_input(attrs: list[dict[str, Any]]):
return np.ones([1, 3, 64, 64]).astype(np.float32)

for dropout_implementation in [
Expand Down Expand Up @@ -76,7 +78,7 @@ def generate_input(attrs: List[Dict[str, Any]]):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
self.dynamic_shape.min_input_shape = {"input_data": [1, 3, 32, 32]}
self.dynamic_shape.max_input_shape = {"input_data": [4, 3, 64, 64]}
Expand Down
9 changes: 5 additions & 4 deletions test/ir/inference/test_trt_convert_einsum.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

import unittest
from functools import partial
from typing import List

import numpy as np
from program_config import ProgramConfig, TensorConfig
Expand Down Expand Up @@ -91,7 +92,7 @@ def generate_equation1(dims):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
if self.dims == 1:
self.dynamic_shape.min_input_shape = {
Expand Down Expand Up @@ -251,7 +252,7 @@ def generate_equation_matrix_vector(dims, vec_shape):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
if self.dims == 1:
self.dynamic_shape.min_input_shape = {
Expand Down Expand Up @@ -383,7 +384,7 @@ def generate_input_matrix(input_shape):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
min_xshape = self.x_shape[:]
max_xshape = self.x_shape[:]
Expand Down
21 changes: 11 additions & 10 deletions test/ir/inference/test_trt_convert_elementwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

import unittest
from functools import partial
from typing import List

import numpy as np
from program_config import ProgramConfig, TensorConfig
Expand Down Expand Up @@ -110,7 +111,7 @@ def generate_weight(op_type):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
# The input.dims[1] must be equal to the weight's length.
if self.dims == 4:
Expand Down Expand Up @@ -251,7 +252,7 @@ def generate_weight(op_type):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
self.dynamic_shape.min_input_shape = {"input_data": [32]}
self.dynamic_shape.max_input_shape = {"input_data": [64]}
Expand Down Expand Up @@ -396,7 +397,7 @@ def generate_weight(op_type):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
# The input.dims[1] must be equal to the weight's length.
if self.dims == 1:
Expand Down Expand Up @@ -539,7 +540,7 @@ def generate_input(shape, op_type):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
if self.dims == 1:
self.dynamic_shape.min_input_shape = {
Expand Down Expand Up @@ -749,7 +750,7 @@ def generate_input(shape, op_type):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
max_shape = [
[128],
Expand Down Expand Up @@ -901,7 +902,7 @@ def generate_weight(op_type):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
# The input.dims[1] must be equal to the weight's length.
if self.dims == 1:
Expand Down Expand Up @@ -1023,7 +1024,7 @@ def generate_input(shape, op_type):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
if self.dims == 1:
self.dynamic_shape.min_input_shape = {
Expand Down Expand Up @@ -1169,7 +1170,7 @@ def generate_input(shape):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
if self.dims == 0:
self.dynamic_shape.min_input_shape = {"input_data": []}
Expand Down Expand Up @@ -1332,7 +1333,7 @@ def generate_input(dims, op_type):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
# The input.dims[1] must be equal to the weight's length.
if self.dims == 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

import unittest
from functools import partial
from typing import List

import numpy as np
from program_config import ProgramConfig, TensorConfig
Expand Down Expand Up @@ -130,7 +132,7 @@ def ele2_input_datagen(dics):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs, inputs):
channel = inputs['ele_input_1'].shape[2]

Expand Down
5 changes: 3 additions & 2 deletions test/ir/inference/test_trt_convert_emb_eltwise_layernorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

import unittest
from functools import partial
from typing import List

import numpy as np
from program_config import ProgramConfig, TensorConfig
Expand Down Expand Up @@ -263,7 +264,7 @@ def generate_weight4(size2):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
self.dynamic_shape.min_input_shape = {
"input_data1": [1, 4, 1],
Expand Down
5 changes: 3 additions & 2 deletions test/ir/inference/test_trt_convert_equal.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

import unittest
from functools import partial
from typing import List

import numpy as np
from program_config import ProgramConfig, TensorConfig
Expand Down Expand Up @@ -82,7 +83,7 @@ def generate_input(shape):

def sample_predictor_configs(
self, program_config
) -> (paddle_infer.Config, List[int], float):
) -> tuple[paddle_infer.Config, list[int], float]:
def generate_dynamic_shape(attrs):
# The input.dims[1] must be equal to the weight's length.
if self.dims == 0:
Expand Down