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
7afec310
Commit
7afec310
authored
May 30, 2023
by
liucong
Browse files
修改GPT2模型的最大shape
parent
741ac4ae
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
4 additions
and
9 deletions
+4
-9
Doc/Images/GPT_03.png
Doc/Images/GPT_03.png
+0
-0
Doc/Images/GPT_04.png
Doc/Images/GPT_04.png
+0
-0
Python/NLP/GPT2/gpt2.py
Python/NLP/GPT2/gpt2.py
+1
-1
README.md
README.md
+1
-1
Src/NLP/GPT2/GPT2.cpp
Src/NLP/GPT2/GPT2.cpp
+2
-7
No files found.
Doc/Images/GPT_03.png
View replaced file @
741ac4ae
View file @
7afec310
31.4 KB
|
W:
|
H:
15.7 KB
|
W:
|
H:
2-up
Swipe
Onion skin
Doc/Images/GPT_04.png
View replaced file @
741ac4ae
View file @
7afec310
35.8 KB
|
W:
|
H:
35.3 KB
|
W:
|
H:
2-up
Swipe
Onion skin
Python/NLP/GPT2/gpt2.py
View file @
7afec310
...
@@ -9,7 +9,7 @@ vocab_file = os.path.join('../../../Resource/Models/NLP/GPT2', 'vocab_shici.txt'
...
@@ -9,7 +9,7 @@ vocab_file = os.path.join('../../../Resource/Models/NLP/GPT2', 'vocab_shici.txt'
tokenizer
=
BertTokenizerFast
(
vocab_file
,
sep_token
=
"[SEP]"
,
pad_token
=
"[PAD]"
,
cls_token
=
"[CLS]"
)
tokenizer
=
BertTokenizerFast
(
vocab_file
,
sep_token
=
"[SEP]"
,
pad_token
=
"[PAD]"
,
cls_token
=
"[CLS]"
)
# 设置最大输入shape
# 设置最大输入shape
maxInput
=
{
"input"
:[
1
,
10
24
]}
maxInput
=
{
"input"
:[
1
,
10
00
]}
# 加载模型
# 加载模型
print
(
"INFO: Parsing and compiling the model"
)
print
(
"INFO: Parsing and compiling the model"
)
...
...
README.md
View file @
7afec310
...
@@ -116,7 +116,7 @@ export MIGRAPHX_DYNAMIC_SHAPE=1
...
@@ -116,7 +116,7 @@ export MIGRAPHX_DYNAMIC_SHAPE=1
如下所示,采用交互式界面,通过输入开头诗词,GPT2模型可以推理出后续的诗句。
如下所示,采用交互式界面,通过输入开头诗词,GPT2模型可以推理出后续的诗句。
<img
src=
"./Doc/Images/GPT_04.png"
style=
"zoom:
9
0%;"
align=
middle
>
<img
src=
"./Doc/Images/GPT_04.png"
style=
"zoom:
10
0%;"
align=
middle
>
## 历史版本
## 历史版本
...
...
Src/NLP/GPT2/GPT2.cpp
View file @
7afec310
...
@@ -46,7 +46,7 @@ ErrorCode GPT2::Initialize(InitializationParameterOfNLP initParamOfNLPGPT2)
...
@@ -46,7 +46,7 @@ ErrorCode GPT2::Initialize(InitializationParameterOfNLP initParamOfNLPGPT2)
// 设置最大输入shape
// 设置最大输入shape
migraphx
::
onnx_options
onnx_options
;
migraphx
::
onnx_options
onnx_options
;
onnx_options
.
map_input_dims
[
"input"
]
=
{
1
,
10
24
};
onnx_options
.
map_input_dims
[
"input"
]
=
{
1
,
10
00
};
// 加载模型
// 加载模型
if
(
Exists
(
modelPath
)
==
false
)
if
(
Exists
(
modelPath
)
==
false
)
...
@@ -70,12 +70,7 @@ ErrorCode GPT2::Initialize(InitializationParameterOfNLP initParamOfNLPGPT2)
...
@@ -70,12 +70,7 @@ ErrorCode GPT2::Initialize(InitializationParameterOfNLP initParamOfNLPGPT2)
options
.
device_id
=
0
;
// 设置GPU设备,默认为0号设备
options
.
device_id
=
0
;
// 设置GPU设备,默认为0号设备
options
.
offload_copy
=
true
;
// 设置offload_copy
options
.
offload_copy
=
true
;
// 设置offload_copy
net
.
compile
(
gpuTarget
,
options
);
net
.
compile
(
gpuTarget
,
options
);
LOG_INFO
(
logFile
,
"succeed to compile model: %s
\n
"
,
GetFileName
(
modelPath
).
c_str
());
LOG_INFO
(
logFile
,
"succeed to compile model: %s
\n
"
,
GetFileName
(
modelPath
).
c_str
());
// Run once by itself
migraphx
::
parameter_map
inputData
;
inputData
[
inputName
]
=
migraphx
::
generate_argument
(
inputShape
);
net
.
eval
(
inputData
);
return
SUCCESS
;
return
SUCCESS
;
}
}
...
...
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