Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
8f06fc57
Commit
8f06fc57
authored
Aug 28, 2019
by
Shucai Xiao
Browse files
Merge branch 'develop' of
https://github.com/ROCmSoftwarePlatform/AMDMIGraphX
into int8_quantize
parents
7c109398
97108410
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
src/onnx/onnx.cpp
src/onnx/onnx.cpp
+15
-9
No files found.
src/onnx/onnx.cpp
View file @
8f06fc57
...
@@ -524,15 +524,7 @@ struct onnx_parser
...
@@ -524,15 +524,7 @@ struct onnx_parser
if
(
contains
(
attributes
,
"ends"
))
if
(
contains
(
attributes
,
"ends"
))
{
{
literal
s
=
parse_value
(
attributes
.
at
(
"ends"
));
op
.
ends
=
get_indices
(
attributes
.
at
(
"ends"
));
s
.
visit
([
&
](
auto
v
)
{
copy
(
v
,
std
::
back_inserter
(
op
.
ends
));
});
for
(
size_t
i
=
0
;
i
<
num_dims
;
i
++
)
{
if
(
static_cast
<
size_t
>
(
op
.
ends
[
i
])
>
dims
[
i
])
{
op
.
ends
[
i
]
=
dims
[
i
];
}
}
}
}
if
(
contains
(
attributes
,
"starts"
))
if
(
contains
(
attributes
,
"starts"
))
{
{
...
@@ -1548,6 +1540,20 @@ struct onnx_parser
...
@@ -1548,6 +1540,20 @@ struct onnx_parser
return
result
;
return
result
;
}
}
static
std
::
vector
<
int64_t
>
get_indices
(
const
onnx
::
AttributeProto
&
attr
)
{
std
::
vector
<
int64_t
>
result
;
literal
s
=
parse_value
(
attr
);
s
.
visit
([
&
](
auto
v
)
{
copy
(
v
,
std
::
back_inserter
(
result
));
});
// Clamp large indices to -1
std
::
replace_if
(
result
.
begin
(),
result
.
end
(),
[](
auto
x
)
{
return
x
>
int64_t
{
std
::
numeric_limits
<
std
::
int32_t
>::
max
()}
/
2
;
},
-
1
);
return
result
;
}
template
<
class
T
>
template
<
class
T
>
static
literal
from_repeated
(
shape
::
type_t
t
,
const
T
&
r
)
static
literal
from_repeated
(
shape
::
type_t
t
,
const
T
&
r
)
{
{
...
...
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