提交 7f8dd427 编写于 作者: F felixhjh

add comment

上级 6a75f915
...@@ -39,7 +39,12 @@ class DetOp(Op): ...@@ -39,7 +39,12 @@ class DetOp(Op):
"unclip_ratio": 1.5, "unclip_ratio": 1.5,
"min_size": 3 "min_size": 3
}) })
"""
when opening tensorrt(configure in config.yml) and each time the input shape
for inferring is different, using this method for configuring tensorrt
dynamic shape to infer in each op model
"""
def set_dynamic_shape_info(self): def set_dynamic_shape_info(self):
min_input_shape = { min_input_shape = {
"x": [1, 3, 50, 50], "x": [1, 3, 50, 50],
...@@ -103,6 +108,11 @@ class RecOp(Op): ...@@ -103,6 +108,11 @@ class RecOp(Op):
self.get_rotate_crop_image = GetRotateCropImage() self.get_rotate_crop_image = GetRotateCropImage()
self.sorted_boxes = SortedBoxes() self.sorted_boxes = SortedBoxes()
"""
when opening tensorrt(configure in config.yml) and each time the input shape
for inferring is different, using this method for configuring tensorrt
dynamic shape to infer in each op model
"""
def set_dynamic_shape_info(self): def set_dynamic_shape_info(self):
min_input_shape = { min_input_shape = {
"x": [1, 3, 32, 10], "x": [1, 3, 32, 10],
......
...@@ -116,6 +116,8 @@ class LocalPredictor(object): ...@@ -116,6 +116,8 @@ class LocalPredictor(object):
mkldnn_bf16_op_list: op list accelerated using MKLDNN bf16, None default. mkldnn_bf16_op_list: op list accelerated using MKLDNN bf16, None default.
use_feed_fetch_ops: use feed/fetch ops, False default. use_feed_fetch_ops: use feed/fetch ops, False default.
use_ascend_cl: run predict on Huawei Ascend, False default use_ascend_cl: run predict on Huawei Ascend, False default
min_subgraph_size: the minimal subgraph size for opening tensorrt to optimize, 3 default
dynamic_shape_info: dict including min_input_shape,max_input_shape, opt_input_shape, {} default
""" """
gpu_id = int(gpu_id) gpu_id = int(gpu_id)
client_config = "{}/serving_server_conf.prototxt".format(model_path) client_config = "{}/serving_server_conf.prototxt".format(model_path)
...@@ -155,11 +157,12 @@ class LocalPredictor(object): ...@@ -155,11 +157,12 @@ class LocalPredictor(object):
"use_trt:{}, use_lite:{}, use_xpu:{}, precision:{}, use_calib:{}, " "use_trt:{}, use_lite:{}, use_xpu:{}, precision:{}, use_calib:{}, "
"use_mkldnn:{}, mkldnn_cache_capacity:{}, mkldnn_op_list:{}, " "use_mkldnn:{}, mkldnn_cache_capacity:{}, mkldnn_op_list:{}, "
"mkldnn_bf16_op_list:{}, use_feed_fetch_ops:{}, " "mkldnn_bf16_op_list:{}, use_feed_fetch_ops:{}, "
"use_ascend_cl:{} ".format( "use_ascend_cl:{}, min_subgraph_size:{}, dynamic_shape_info:{}".format(
model_path, use_gpu, gpu_id, use_profile, thread_num, mem_optim, model_path, use_gpu, gpu_id, use_profile, thread_num, mem_optim,
ir_optim, use_trt, use_lite, use_xpu, precision, use_calib, ir_optim, use_trt, use_lite, use_xpu, precision, use_calib,
use_mkldnn, mkldnn_cache_capacity, mkldnn_op_list, use_mkldnn, mkldnn_cache_capacity, mkldnn_op_list,
mkldnn_bf16_op_list, use_feed_fetch_ops, use_ascend_cl)) mkldnn_bf16_op_list, use_feed_fetch_ops, use_ascend_cl,
min_subgraph_size, dynamic_shape_info))
self.feed_names_ = [var.alias_name for var in model_conf.feed_var] self.feed_names_ = [var.alias_name for var in model_conf.feed_var]
self.fetch_names_ = [var.alias_name for var in model_conf.fetch_var] self.fetch_names_ = [var.alias_name for var in model_conf.fetch_var]
...@@ -222,7 +225,9 @@ class LocalPredictor(object): ...@@ -222,7 +225,9 @@ class LocalPredictor(object):
if len(dynamic_shape_info): if len(dynamic_shape_info):
config.set_trt_dynamic_shape_info( config.set_trt_dynamic_shape_info(
dynamic_shape_info['min_input_shape'], dynamic_shape_info['max_input_shape'], dynamic_shape_info['opt_input_shape']) dynamic_shape_info['min_input_shape'],
dynamic_shape_info['max_input_shape'],
dynamic_shape_info['opt_input_shape'])
# set lite # set lite
if use_lite: if use_lite:
config.enable_lite_engine( config.enable_lite_engine(
......
...@@ -182,14 +182,16 @@ class LocalServiceHandler(object): ...@@ -182,14 +182,16 @@ class LocalServiceHandler(object):
"mem_optim:{}, ir_optim:{}, use_profile:{}, thread_num:{}, " "mem_optim:{}, ir_optim:{}, use_profile:{}, thread_num:{}, "
"client_type:{}, fetch_names:{}, precision:{}, use_mkldnn:{}, " "client_type:{}, fetch_names:{}, precision:{}, use_mkldnn:{}, "
"mkldnn_cache_capacity:{}, mkldnn_op_list:{}, " "mkldnn_cache_capacity:{}, mkldnn_op_list:{}, "
"mkldnn_bf16_op_list:{}, use_ascend_cl:{}, min_subgraph_size:{}".format( "mkldnn_bf16_op_list:{}, use_ascend_cl:{}, min_subgraph_size:{},"
"is_set_dynamic_shape_info:{}".format(
model_config, self._device_name, self._use_gpu, self._use_trt, model_config, self._device_name, self._use_gpu, self._use_trt,
self._use_lite, self._use_xpu, device_type, self._devices, self._use_lite, self._use_xpu, device_type, self._devices,
self._mem_optim, self._ir_optim, self._use_profile, self._mem_optim, self._ir_optim, self._use_profile,
self._thread_num, self._client_type, self._fetch_names, self._thread_num, self._client_type, self._fetch_names,
self._precision, self._use_mkldnn, self._mkldnn_cache_capacity, self._precision, self._use_mkldnn, self._mkldnn_cache_capacity,
self._mkldnn_op_list, self._mkldnn_bf16_op_list, self._mkldnn_op_list, self._mkldnn_bf16_op_list,
self._use_ascend_cl, self.min_subgraph_size)) self._use_ascend_cl, self.min_subgraph_sizei,
bool(len(self.dynamic_shape_info))))
def get_fetch_list(self): def get_fetch_list(self):
return self._fetch_names return self._fetch_names
......
...@@ -120,6 +120,11 @@ class Op(object): ...@@ -120,6 +120,11 @@ class Op(object):
self.set_dynamic_shape_info() self.set_dynamic_shape_info()
def set_dynamic_shape_info(self): def set_dynamic_shape_info(self):
"""
when opening tensorrt(configure in config.yml) and each time the input shape
for inferring is different, using this method for configuring tensorrt
dynamic shape to infer in each op model
"""
pass pass
# for feed/fetch dict cehck # for feed/fetch dict cehck
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册