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
gaoqiong
MIGraphX
Commits
1bdd55e8
Commit
1bdd55e8
authored
Jan 16, 2019
by
Shucai Xiao
Browse files
clang format.
parent
eb1e4353
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
14 deletions
+14
-14
src/include/migraphx/operators.hpp
src/include/migraphx/operators.hpp
+2
-4
src/onnx/onnx.cpp
src/onnx/onnx.cpp
+11
-9
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+1
-1
No files found.
src/include/migraphx/operators.hpp
View file @
1bdd55e8
...
@@ -659,10 +659,8 @@ struct gather
...
@@ -659,10 +659,8 @@ struct gather
// max dimension in axis
// max dimension in axis
std
::
size_t
max_dim
=
args
[
0
].
get_shape
().
lens
()[
axis
];
std
::
size_t
max_dim
=
args
[
0
].
get_shape
().
lens
()[
axis
];
std
::
vector
<
std
::
size_t
>
vec_indices
(
args
[
1
].
get_shape
().
lens
().
size
());
std
::
vector
<
std
::
size_t
>
vec_indices
(
args
[
1
].
get_shape
().
lens
().
size
());
args
[
1
].
visit
([
&
](
auto
indices
)
{
args
[
1
].
visit
([
&
](
auto
indices
)
{
vec_indices
.
assign
(
indices
.
begin
(),
indices
.
end
());
});
vec_indices
.
assign
(
indices
.
begin
(),
indices
.
end
());
std
::
size_t
idx
=
vec_indices
.
at
(
out_idx
[
axis
]);
});
std
::
size_t
idx
=
vec_indices
.
at
(
out_idx
[
axis
]);
if
(
idx
>=
max_dim
)
if
(
idx
>=
max_dim
)
{
{
MIGRAPHX_THROW
(
"Gather, indices are out of range in input tensor"
);
MIGRAPHX_THROW
(
"Gather, indices are out of range in input tensor"
);
...
...
src/onnx/onnx.cpp
View file @
1bdd55e8
...
@@ -556,7 +556,6 @@ struct onnx_parser
...
@@ -556,7 +556,6 @@ struct onnx_parser
return
prog
.
add_literal
(
migraphx
::
literal
{
s
,
vec_shape
});
return
prog
.
add_literal
(
migraphx
::
literal
{
s
,
vec_shape
});
}
}
// Use a literal instruction to replace the constantFill operator. In RNN, input shape
// Use a literal instruction to replace the constantFill operator. In RNN, input shape
// and value are fixed, so no need to do the actual computation for the constantFill
// and value are fixed, so no need to do the actual computation for the constantFill
// operator
// operator
...
@@ -584,26 +583,28 @@ struct onnx_parser
...
@@ -584,26 +583,28 @@ struct onnx_parser
value
=
parse_value
(
attributes
.
at
(
"value"
)).
at
<
float
>
();
value
=
parse_value
(
attributes
.
at
(
"value"
)).
at
<
float
>
();
}
}
if
(
contains
(
attributes
,
"extra_shape"
))
{
if
(
contains
(
attributes
,
"extra_shape"
))
{
MIGRAPHX_THROW
(
"ConstantFill, cannot handle extra shape attribute"
);
MIGRAPHX_THROW
(
"ConstantFill, cannot handle extra shape attribute"
);
}
}
if
(
input_as_shape
==
1
)
if
(
input_as_shape
==
1
)
{
{
if
(
args
.
size
()
!=
1
)
if
(
args
.
size
()
!=
1
)
{
{
MIGRAPHX_THROW
(
"ConstantFill, need an input argument as output shape"
);
MIGRAPHX_THROW
(
"ConstantFill, need an input argument as output shape"
);
}
}
if
(
contains
(
attributes
,
"shape"
))
{
if
(
contains
(
attributes
,
"shape"
))
MIGRAPHX_THROW
(
"ConstantFill, cannot set the shape argument and pass in an input at the same time"
);
{
MIGRAPHX_THROW
(
"ConstantFill, cannot set the shape argument and pass in an input "
"at the same time"
);
}
}
migraphx
::
argument
in
=
args
[
0
]
->
eval
();
migraphx
::
argument
in
=
args
[
0
]
->
eval
();
if
(
in
.
empty
())
if
(
in
.
empty
())
{
{
MIGRAPHX_THROW
(
MIGRAPHX_THROW
(
"ConstantFill, cannot handle dynamic shape as input"
);
"ConstantFill, cannot handle dynamic shape as input"
);
}
}
std
::
vector
<
std
::
size_t
>
dims
;
std
::
vector
<
std
::
size_t
>
dims
;
...
@@ -614,13 +615,14 @@ struct onnx_parser
...
@@ -614,13 +615,14 @@ struct onnx_parser
}
}
else
if
(
input_as_shape
==
0
)
else
if
(
input_as_shape
==
0
)
{
{
if
(
!
contains
(
attributes
,
"shape"
))
{
if
(
!
contains
(
attributes
,
"shape"
))
{
MIGRAPHX_THROW
(
"ConstantFill, attribute output shape is needed"
);
MIGRAPHX_THROW
(
"ConstantFill, attribute output shape is needed"
);
}
}
literal
ls
=
parse_value
(
attributes
.
at
(
"shape"
));
literal
ls
=
parse_value
(
attributes
.
at
(
"shape"
));
std
::
vector
<
std
::
size_t
>
dims
(
ls
.
get_shape
().
elements
());
std
::
vector
<
std
::
size_t
>
dims
(
ls
.
get_shape
().
elements
());
ls
.
visit
([
&
]
(
auto
s
)
{
dims
.
assign
(
s
.
begin
(),
s
.
end
());
}
);
ls
.
visit
([
&
](
auto
s
)
{
dims
.
assign
(
s
.
begin
(),
s
.
end
());
});
migraphx
::
shape
s
{
type
,
dims
};
migraphx
::
shape
s
{
type
,
dims
};
std
::
vector
<
float
>
values
(
s
.
elements
(),
value
);
std
::
vector
<
float
>
values
(
s
.
elements
(),
value
);
return
prog
.
add_literal
(
migraphx
::
literal
(
s
,
values
));
return
prog
.
add_literal
(
migraphx
::
literal
(
s
,
values
));
...
...
test/onnx/onnx_test.cpp
View file @
1bdd55e8
...
@@ -498,7 +498,7 @@ TEST_CASE(constant_fill_test)
...
@@ -498,7 +498,7 @@ TEST_CASE(constant_fill_test)
{
{
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
l0
=
p
.
add_literal
(
migraphx
::
literal
{{
migraphx
::
shape
::
int32_type
,
{
2
}},
{
2
,
3
}});
auto
l0
=
p
.
add_literal
(
migraphx
::
literal
{{
migraphx
::
shape
::
int32_type
,
{
2
}},
{
2
,
3
}});
std
::
vector
<
std
::
size_t
>
dims
(
l0
->
get_shape
().
elements
());
std
::
vector
<
std
::
size_t
>
dims
(
l0
->
get_shape
().
elements
());
migraphx
::
literal
ls
=
l0
->
get_literal
();
migraphx
::
literal
ls
=
l0
->
get_literal
();
ls
.
visit
([
&
](
auto
s
)
{
dims
.
assign
(
s
.
begin
(),
s
.
end
());
});
ls
.
visit
([
&
](
auto
s
)
{
dims
.
assign
(
s
.
begin
(),
s
.
end
());
});
...
...
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