Skip to content

fix bug unimo fp16 infer error #4166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 20, 2022
Merged
Changes from 1 commit
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
20 changes: 9 additions & 11 deletions examples/question_generation/unimo-text/export_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import argparse
import os
from pprint import pprint

import paddle

from pprint import pprint

from paddlenlp.transformers import UNIMOLMHeadModel, UNIMOTokenizer
from paddlenlp.ops import FasterUNIMOText

from paddlenlp.transformers import UNIMOLMHeadModel, UNIMOTokenizer
from paddlenlp.utils.log import logger


Expand Down Expand Up @@ -65,24 +63,24 @@ def do_predict(args):
unimo_text,
input_spec=[
# input_ids
paddle.static.InputSpec(shape=[None, None], dtype="int64"),
paddle.static.InputSpec(shape=[None, None], dtype="int32"),
# token_type_ids
paddle.static.InputSpec(shape=[None, None], dtype="int64"),
paddle.static.InputSpec(shape=[None, None], dtype="int32"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里有个问题是,windows默认的numpy是int64,这里的改动是不是对windows的部署有影响?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

更新后的修改只对attention mask进行了精度变换,其他部分仍是64

# attention_mask
paddle.static.InputSpec(shape=[None, 1, None, None],
dtype="float64"),
dtype="float32"),
# seq_len
paddle.static.InputSpec(shape=[None], dtype="int64"),
paddle.static.InputSpec(shape=[None], dtype="int32"),
args.max_dec_len,
args.min_dec_len,
args.topk,
args.topp,
args.num_beams, # num_beams. Used for beam_search.
args.num_beams, # num_beams. Used for beam_search.
args.decoding_strategy,
tokenizer.cls_token_id, # cls/bos
tokenizer.mask_token_id, # mask/eos
tokenizer.pad_token_id, # pad
args.diversity_rate, # diversity rate. Used for beam search.
args.diversity_rate, # diversity rate. Used for beam search.
args.temperature,
args.num_return_sequences,
args.length_penalty,
Expand Down