Skip to content

Commit 4112fb3

Browse files
authored
support cinn flag (#16745)
1 parent eb07d56 commit 4112fb3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

paddleocr/_common_args.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
DEFAULT_PRECISION,
2424
DEFAULT_USE_TENSORRT,
2525
SUPPORTED_PRECISION_LIST,
26+
DEFAULT_USE_CINN,
2627
)
2728
from ._utils.cli import str2bool
2829

@@ -36,6 +37,7 @@ def parse_common_args(kwargs, *, default_enable_hpi):
3637
"enable_mkldnn": DEFAULT_ENABLE_MKLDNN,
3738
"mkldnn_cache_capacity": DEFAULT_MKLDNN_CACHE_CAPACITY,
3839
"cpu_threads": DEFAULT_CPU_THREADS,
40+
"enable_cinn": DEFAULT_USE_CINN,
3941
}
4042

4143
unknown_names = kwargs.keys() - default_vals.keys()
@@ -86,6 +88,7 @@ def prepare_common_init_args(model_name, common_args):
8688
pp_option.cpu_threads = common_args["cpu_threads"]
8789
else:
8890
pp_option.run_mode = "paddle"
91+
pp_option.enable_cinn = common_args["enable_cinn"]
8992
init_kwargs["pp_option"] = pp_option
9093

9194
return init_kwargs
@@ -139,3 +142,9 @@ def add_common_cli_opts(parser, *, default_enable_hpi, allow_multiple_devices):
139142
default=DEFAULT_CPU_THREADS,
140143
help="Number of threads to use for inference on CPUs.",
141144
)
145+
parser.add_argument(
146+
"--enable_cinn",
147+
type=str2bool,
148+
default=DEFAULT_USE_CINN,
149+
help="Whether to use the CINN compiler.",
150+
)

paddleocr/_constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919
DEFAULT_MKLDNN_CACHE_CAPACITY = 10
2020
DEFAULT_CPU_THREADS = 10
2121
SUPPORTED_PRECISION_LIST = ["fp32", "fp16"]
22+
DEFAULT_USE_CINN = False

0 commit comments

Comments
 (0)