Skip to content

Commit ec29e4f

Browse files
authored
fix ernie-csc depoly core dumped (#5117)
* fix ernie-csc depoly core dumped * fix codestyel
1 parent ccfb774 commit ec29e4f

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

examples/text_correction/ernie-csc/predict.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,42 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
import os
16-
1715
import argparse
18-
import numpy as np
1916
from functools import partial
2017

2118
import paddle
22-
from paddle import inference
23-
from paddlenlp.data import Stack, Tuple, Pad, Vocab
24-
from paddlenlp.transformers import ErnieTokenizer
25-
2619
from utils import convert_example, parse_decode
2720

28-
# yapf: disable
21+
from paddlenlp.data import Pad, Stack, Tuple, Vocab
22+
from paddlenlp.transformers import ErnieTokenizer
23+
2924
parser = argparse.ArgumentParser(__doc__)
30-
parser.add_argument("--model_file", type=str, required=True, default='./static_graph_params.pdmodel', help="The path to model info in static graph.")
31-
parser.add_argument("--params_file", type=str, required=True, default='./static_graph_params.pdiparams', help="The path to parameters in static graph.")
25+
parser.add_argument(
26+
"--model_file",
27+
type=str,
28+
required=True,
29+
default="./static_graph_params.pdmodel",
30+
help="The path to model info in static graph.",
31+
)
32+
parser.add_argument(
33+
"--params_file",
34+
type=str,
35+
required=True,
36+
default="./static_graph_params.pdiparams",
37+
help="The path to parameters in static graph.",
38+
)
3239
parser.add_argument("--batch_size", type=int, default=2, help="The number of sequences contained in a mini-batch.")
3340
parser.add_argument("--max_seq_len", type=int, default=64, help="Number of words of the longest seqence.")
34-
parser.add_argument("--device", default="gpu", type=str, choices=["cpu", "gpu"] ,help="The device to select to train the model, is must be cpu/gpu.")
41+
parser.add_argument(
42+
"--device",
43+
default="gpu",
44+
type=str,
45+
choices=["cpu", "gpu"],
46+
help="The device to select to train the model, is must be cpu/gpu.",
47+
)
3548
parser.add_argument("--pinyin_vocab_file_path", type=str, default="pinyin_vocab.txt", help="pinyin vocab file path")
3649

3750
args = parser.parse_args()
38-
# yapf: enable
3951

4052

4153
class Predictor(object):
@@ -51,6 +63,7 @@ def __init__(self, model_file, params_file, device, max_seq_length, tokenizer, p
5163
# such as enable_mkldnn, set_cpu_math_library_num_threads
5264
config.disable_gpu()
5365
config.switch_use_feed_fetch_ops(False)
66+
config.delete_pass("fused_multi_transformer_encoder_pass")
5467
self.predictor = paddle.inference.create_predictor(config)
5568

5669
self.input_handles = [self.predictor.get_input_handle(name) for name in self.predictor.get_input_names()]

scripts/regression/requirements_ci.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ scikit-learn
2828
cma
2929
paddleocr
3030
fast_tokenizer_python
31-
https://paddle-qa.bj.bcebos.com/PaddleSlim/paddleslim-0.0.0.dev0-py3-none-any.whl
31+
https://paddle-qa.bj.bcebos.com/PaddleSlim/paddleslim-0.0.0.dev0-py3-none-any.whl
32+
onnxruntime

scripts/regression/run_release.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export log_path=${nlp_dir}/logs
2626
####################################
2727
# for paddlenlp env
2828
python -c 'import sys; print(sys.version_info[:])'
29+
python -c 'import nltk; nltk.download("punkt")'
2930
set -x
3031
python -c "import paddle; print('paddle version:',paddle.__version__,'\npaddle commit:',paddle.version.commit)";
3132
nlp1_build (){

0 commit comments

Comments
 (0)