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
5b53552d
Unverified
Commit
5b53552d
authored
Sep 28, 2023
by
Charlie Lin
Committed by
GitHub
Sep 28, 2023
Browse files
Fix shapes check for allocate (#2258)
parent
28614abd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
src/include/migraphx/op/allocate.hpp
src/include/migraphx/op/allocate.hpp
+9
-4
test/op_shape_test.cpp
test/op_shape_test.cpp
+15
-0
No files found.
src/include/migraphx/op/allocate.hpp
View file @
5b53552d
...
@@ -49,17 +49,22 @@ struct allocate
...
@@ -49,17 +49,22 @@ struct allocate
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
{
migraphx
::
check_shapes
{
inputs
,
*
this
,
true
}.
has
(
0
,
1
);
// check if shape attribute is not default
if
(
s
!=
shape
())
if
(
s
!=
shape
())
{
{
if
(
inputs
.
size
()
==
1
)
{
migraphx
::
check_shapes
{
inputs
,
*
this
,
false
}.
only_dims
(
1
);
}
else
{
migraphx
::
check_shapes
{
inputs
,
*
this
,
false
}.
has
(
0
);
}
return
s
;
return
s
;
}
}
else
else
{
{
migraphx
::
check_shapes
{
inputs
,
*
this
,
false
}.
has
(
1
).
only_dims
(
1
);
const
auto
&
out_dims
=
inputs
.
at
(
0
);
const
auto
&
out_dims
=
inputs
.
at
(
0
);
assert
(
not
out_dims
.
dynamic
());
assert
(
out_dims
.
ndim
()
==
1
);
std
::
size_t
max_val
=
std
::
numeric_limits
<
std
::
size_t
>::
max
();
std
::
size_t
max_val
=
std
::
numeric_limits
<
std
::
size_t
>::
max
();
std
::
vector
<
shape
::
dynamic_dimension
>
dyn_dims
(
out_dims
.
lens
().
at
(
0
),
std
::
vector
<
shape
::
dynamic_dimension
>
dyn_dims
(
out_dims
.
lens
().
at
(
0
),
shape
::
dynamic_dimension
{
0
,
max_val
});
shape
::
dynamic_dimension
{
0
,
max_val
});
...
...
test/op_shape_test.cpp
View file @
5b53552d
...
@@ -88,6 +88,13 @@ TEST_CASE(allocate_static)
...
@@ -88,6 +88,13 @@ TEST_CASE(allocate_static)
expect_shape
(
out_shape
,
migraphx
::
make_op
(
"allocate"
,
{{
"shape"
,
to_value
(
out_shape
)}}));
expect_shape
(
out_shape
,
migraphx
::
make_op
(
"allocate"
,
{{
"shape"
,
to_value
(
out_shape
)}}));
}
}
TEST_CASE
(
allocate_static_input_error
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
int64_type
,
{
3
}};
migraphx
::
shape
out_shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
}};
expect_shape
(
out_shape
,
migraphx
::
make_op
(
"allocate"
,
{{
"shape"
,
to_value
(
out_shape
)}}),
input
);
}
TEST_CASE
(
allocate_dyn
)
TEST_CASE
(
allocate_dyn
)
{
{
migraphx
::
shape
input
{
migraphx
::
shape
::
int64_type
,
{
2
}};
migraphx
::
shape
input
{
migraphx
::
shape
::
int64_type
,
{
2
}};
...
@@ -109,6 +116,14 @@ TEST_CASE(allocate_dyn_with_shape_attr)
...
@@ -109,6 +116,14 @@ TEST_CASE(allocate_dyn_with_shape_attr)
input
);
input
);
}
}
TEST_CASE
(
allocate_dyn_no_input_error
)
{
migraphx
::
shape
shape_attr
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
3
,
3
},
{
4
,
8
,
{
4
,
6
}},
{
4
,
8
},
{
4
,
6
}}};
expect_shape
(
shape_attr
,
migraphx
::
make_op
(
"allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
shape_attr
)}}));
}
TEST_CASE
(
argmax_axis0
)
TEST_CASE
(
argmax_axis0
)
{
{
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
...
...
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