diff --git a/docs/zh_cn/tutorials/analysis/dygraph/latency_predictor.md b/docs/zh_cn/tutorials/analysis/dygraph/latency_predictor.md index 860b96a37213dfaaae5c4447805fba07f5fa1b2b..b8f80b9a52b52486f57af026fe10960cb3c513f0 100644 --- a/docs/zh_cn/tutorials/analysis/dygraph/latency_predictor.md +++ b/docs/zh_cn/tutorials/analysis/dygraph/latency_predictor.md @@ -7,9 +7,10 @@ ## 1. 准备环境 ### 1.1 版本要求 ```bash -python>=3.7 +python==3.7\3.9 PaddleSlim>=2.3.0 ``` +> 注:在 macOS 环境下要求 python==3.9; linux 环境下要求 python==3.7\3.9 ### 1.2 安装 PaddleSlim * 通过 pip install 的方式进行安装: ```bash @@ -40,7 +41,7 @@ tar -xf mobilenetv1.tar from paddleslim.analysis import TableLatencyPredictor predictor = TableLatencyPredictor(table_file='SD710') -latency = predictor.predict(model_file='mobilenetv1_fp32.pdmodel', param_file='mobilenetv1_fp32.pdiparams, data_type='fp32') +latency = predictor.predict(model_file='mobilenetv1_fp32.pdmodel', param_file='mobilenetv1_fp32.pdiparams', data_type='fp32') print('predicted latency = {}ms'.format(latency)) ``` 通过设置 table_file 来指定硬件信息,当前支持“SD625”、“SD710”、“SD845”三款骁龙芯片。 @@ -61,7 +62,7 @@ print('predicted latency = {}ms'.format(latency)) from paddleslim.analysis import TableLatencyPredictor predictor = TableLatencyPredictor(table_file='SD710') -predictor.predict(model_file='mobilenetv1_int8.pdmodel', param_file='mobilenetv1_int8.pdiparams, data_type='int8') +predictor.predict(model_file='mobilenetv1_int8.pdmodel', param_file='mobilenetv1_int8.pdiparams', data_type='int8') ``` ## 4. 预估效果 diff --git a/paddleslim/analysis/_utils.py b/paddleslim/analysis/_utils.py index bd674b5dc876a5b8b9cd7d33094f6cc2adbf20b5..f0673b1f769561feab9c591492d62e6c552aa086 100644 --- a/paddleslim/analysis/_utils.py +++ b/paddleslim/analysis/_utils.py @@ -248,7 +248,7 @@ def download_predictor(op_dir, op): def load_predictor(op_type, op_dir, data_type='fp32'): op = op_type if 'conv2d' in op_type: - op = 'conv2d_' + data_type + op = f'{op_type}_{data_type}' elif 'matmul' in op_type: op = 'matmul' diff --git a/paddleslim/analysis/extract_features.py b/paddleslim/analysis/extract_features.py index 38f67bce924b00055854ac9cca67305411d1c073..aa646a921100b5a484f02e821b144eb075337633 100644 --- a/paddleslim/analysis/extract_features.py +++ b/paddleslim/analysis/extract_features.py @@ -214,7 +214,7 @@ def get_features_from_paramkey(param_key, op_type, data_type): for i in range(len(X)): if X[i] == '': continue - features[i - 1] = int(X[i]) + features[i] = int(X[i]) for i in range(0, len(Y)): if len(Y) == 4 and i == 0: continue