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
BERT_migraphx
Commits
ab78f8ec
Commit
ab78f8ec
authored
Nov 15, 2023
by
liucong
Browse files
修改bert工程格式
parent
2f699584
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
18 deletions
+1
-18
Python/bert.py
Python/bert.py
+0
-7
Src/Bert.cpp
Src/Bert.cpp
+1
-11
No files found.
Python/bert.py
View file @
ab78f8ec
...
...
@@ -36,15 +36,8 @@ maxInput={"unique_ids_raw_output___9:0":[1], "input_ids:0":[1,256], "input_mask:
model
=
migraphx
.
parse_onnx
(
"../Resource/bertsquad-10.onnx"
,
map_input_dims
=
maxInput
)
# 获取模型输入/输出节点信息
print
(
"inputs:"
)
inputs
=
model
.
get_inputs
()
for
key
,
value
in
inputs
.
items
():
print
(
"{}:{}"
.
format
(
key
,
value
))
print
(
"outputs:"
)
outputs
=
model
.
get_outputs
()
for
key
,
value
in
outputs
.
items
():
print
(
"{}:{}"
.
format
(
key
,
value
))
# 编译
model
.
compile
(
migraphx
.
get_target
(
"gpu"
),
device_id
=
0
)
...
...
Src/Bert.cpp
View file @
ab78f8ec
...
...
@@ -36,7 +36,7 @@ ErrorCode Bert::Initialize()
onnx_options
.
map_input_dims
[
"segment_ids:0"
]
=
{
1
,
256
};
// 加载模型
if
(
Exists
(
modelPath
)
==
false
)
if
(
!
Exists
(
modelPath
))
{
LOG_ERROR
(
stdout
,
"%s not exist!
\n
"
,
modelPath
.
c_str
());
return
MODEL_NOT_EXIST
;
...
...
@@ -45,18 +45,8 @@ ErrorCode Bert::Initialize()
LOG_INFO
(
stdout
,
"succeed to load model: %s
\n
"
,
GetFileName
(
modelPath
).
c_str
());
// 获取模型输入/输出节点信息
std
::
cout
<<
"inputs:"
<<
std
::
endl
;
std
::
unordered_map
<
std
::
string
,
migraphx
::
shape
>
inputs
=
net
.
get_inputs
();
for
(
auto
i
:
inputs
)
{
std
::
cout
<<
i
.
first
<<
":"
<<
i
.
second
<<
std
::
endl
;
}
std
::
cout
<<
"outputs:"
<<
std
::
endl
;
std
::
unordered_map
<
std
::
string
,
migraphx
::
shape
>
outputs
=
net
.
get_outputs
();
for
(
auto
i
:
outputs
)
{
std
::
cout
<<
i
.
first
<<
":"
<<
i
.
second
<<
std
::
endl
;
}
inputName1
=
"unique_ids_raw_output___9:0"
;
inputShape1
=
inputs
.
at
(
inputName1
);
...
...
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