Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
GPT2_migraphx
Commits
6f5d13e8
Commit
6f5d13e8
authored
May 23, 2023
by
liucong
Browse files
修改代码和文档
parent
62fb7f6b
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22561 additions
and
2 deletions
+22561
-2
README.md
README.md
+2
-0
gpt2.py
gpt2.py
+2
-2
model/vocab_shici.txt
model/vocab_shici.txt
+22557
-0
No files found.
README.md
View file @
6f5d13e8
...
...
@@ -22,6 +22,8 @@ docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:ort_dcu_1.14.0_migrap
pip
install
-
r
requirement
.
txt
```
本次采用GPT-2模型进行诗词生成任务,模型文件下载链接:https://pan.baidu.com/s/1KWeoUuakCZ5dualK69qCcw , 提取码:4pmh ,并将GPT2_shici.onnx模型文件保存在model文件夹下。
### 运行示例
我们提供了基于MIGraphX的推理脚本,版本依赖:
...
...
gpt2.py
View file @
6f5d13e8
...
...
@@ -5,7 +5,7 @@ import migraphx
# 加载词汇表
print
(
"INFO: Complete loading the vocabulary"
)
vocab_file
=
os
.
path
.
join
(
'.
./../../Resource/Models/NLP/GPT2
'
,
'vocab_shici.txt'
)
vocab_file
=
os
.
path
.
join
(
'.
/model
'
,
'vocab_shici.txt'
)
tokenizer
=
BertTokenizerFast
(
vocab_file
,
sep_token
=
"[SEP]"
,
pad_token
=
"[PAD]"
,
cls_token
=
"[CLS]"
)
# 设置最大输入shape
...
...
@@ -13,7 +13,7 @@ maxInput={"input":[1,1024]}
# 加载模型
print
(
"INFO: Parsing and compiling the model"
)
model
=
migraphx
.
parse_onnx
(
".
./../../Resource/Models/NLP/GPT2
/GPT2_shici.onnx"
,
map_input_dims
=
maxInput
)
model
=
migraphx
.
parse_onnx
(
".
/model
/GPT2_shici.onnx"
,
map_input_dims
=
maxInput
)
inputName
=
model
.
get_parameter_names
()[
0
]
inputShape
=
model
.
get_parameter_shapes
()[
inputName
].
lens
()
print
(
"inputName:{0}
\n
inputShape:{1}"
.
format
(
inputName
,
inputShape
))
...
...
model/vocab_shici.txt
0 → 100644
View file @
6f5d13e8
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment