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
8f76125c
"vscode:/vscode.git/clone" did not exist on "8390b3622284499df8f94f12ce27564b92c9c7c0"
Commit
8f76125c
authored
May 11, 2022
by
charlie
Browse files
formatting
parent
c497c12d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
49 deletions
+30
-49
src/include/migraphx/shape.hpp
src/include/migraphx/shape.hpp
+2
-1
src/shape.cpp
src/shape.cpp
+27
-44
test/shape_test.cpp
test/shape_test.cpp
+1
-4
No files found.
src/include/migraphx/shape.hpp
View file @
8f76125c
...
...
@@ -176,7 +176,8 @@ struct shape
std
::
vector
<
std
::
size_t
>
multi
(
std
::
size_t
i
)
const
;
void
multi_copy
(
std
::
size_t
i
,
std
::
size_t
*
start
,
const
std
::
size_t
*
end
)
const
;
/// Returns true if the shape is packed (number of elements and buffer size the same) with no padding
/// Returns true if the shape is packed (number of elements and buffer size the same) with no
/// padding
bool
packed
()
const
;
/// Returns true is the shape has been transposed. That is the strides are not in descending
...
...
src/shape.cpp
View file @
8f76125c
...
...
@@ -78,12 +78,7 @@ struct shape_impl
if
(
not
m_dyn_dims
.
empty
())
{
auto
maxes
=
max_lens
();
return
std
::
accumulate
(
maxes
.
begin
(),
maxes
.
end
(),
std
::
size_t
{
1
},
std
::
multiplies
<>
()
);
return
std
::
accumulate
(
maxes
.
begin
(),
maxes
.
end
(),
std
::
size_t
{
1
},
std
::
multiplies
<>
());
}
assert
(
m_lens
.
size
()
==
m_strides
.
size
());
...
...
@@ -115,45 +110,30 @@ struct shape_impl
std
::
vector
<
std
::
size_t
>
min_lens
()
const
{
std
::
vector
<
std
::
size_t
>
ret
(
m_dyn_dims
.
size
());
std
::
transform
(
m_dyn_dims
.
cbegin
(),
m_dyn_dims
.
cend
(),
ret
.
begin
(),
[](
shape
::
dynamic_dimension
x
)
{
return
x
.
min
;
}
);
std
::
transform
(
m_dyn_dims
.
cbegin
(),
m_dyn_dims
.
cend
(),
ret
.
begin
(),
[](
shape
::
dynamic_dimension
x
)
{
return
x
.
min
;
});
return
ret
;
}
std
::
vector
<
std
::
size_t
>
max_lens
()
const
{
std
::
vector
<
std
::
size_t
>
ret
(
m_dyn_dims
.
size
());
std
::
transform
(
m_dyn_dims
.
cbegin
(),
m_dyn_dims
.
cend
(),
ret
.
begin
(),
[](
shape
::
dynamic_dimension
x
)
{
return
x
.
max
;
}
);
std
::
transform
(
m_dyn_dims
.
cbegin
(),
m_dyn_dims
.
cend
(),
ret
.
begin
(),
[](
shape
::
dynamic_dimension
x
)
{
return
x
.
max
;
});
return
ret
;
}
std
::
vector
<
std
::
size_t
>
opt_lens
()
const
{
std
::
vector
<
std
::
size_t
>
ret
(
m_dyn_dims
.
size
());
std
::
transform
(
m_dyn_dims
.
cbegin
(),
m_dyn_dims
.
cend
(),
ret
.
begin
(),
[](
shape
::
dynamic_dimension
x
)
{
return
x
.
opt
;
}
);
std
::
transform
(
m_dyn_dims
.
cbegin
(),
m_dyn_dims
.
cend
(),
ret
.
begin
(),
[](
shape
::
dynamic_dimension
x
)
{
return
x
.
opt
;
});
return
ret
;
}
...
...
@@ -439,29 +419,32 @@ const std::vector<shape::dynamic_dimension>& shape::dyn_dims() const { return im
std
::
vector
<
std
::
size_t
>
shape
::
min_lens
()
const
{
if
(
not
this
->
dynamic
())
if
(
not
this
->
dynamic
())
{
return
this
->
lens
();
}
return
impl
->
min_lens
();;
return
impl
->
min_lens
();
;
}
std
::
vector
<
std
::
size_t
>
shape
::
max_lens
()
const
{
if
(
not
this
->
dynamic
())
if
(
not
this
->
dynamic
())
{
return
this
->
lens
();
}
return
impl
->
max_lens
();;
return
impl
->
max_lens
();
;
}
std
::
vector
<
std
::
size_t
>
shape
::
opt_lens
()
const
{
if
(
not
this
->
dynamic
())
if
(
not
this
->
dynamic
())
{
return
this
->
lens
();
}
return
impl
->
opt_lens
();;
return
impl
->
opt_lens
();
;
}
bool
operator
==
(
const
shape
&
x
,
const
shape
&
y
)
...
...
@@ -520,11 +503,11 @@ void migraphx_to_value(value& v, const shape& s)
result
[
"type"
]
=
migraphx
::
to_value
(
s
.
type_string
());
if
(
s
.
dynamic
())
{
result
[
"dynamic"
]
=
migraphx
::
to_value
(
s
.
dynamic
());
result
[
"min_lens"
]
=
migraphx
::
to_value
(
s
.
min_lens
());
result
[
"max_lens"
]
=
migraphx
::
to_value
(
s
.
max_lens
());
result
[
"opt_lens"
]
=
migraphx
::
to_value
(
s
.
opt_lens
());
result
[
"sub_shapes"
]
=
migraphx
::
to_value
(
s
.
sub_shapes
());
result
[
"dynamic"
]
=
migraphx
::
to_value
(
s
.
dynamic
());
result
[
"min_lens"
]
=
migraphx
::
to_value
(
s
.
min_lens
());
result
[
"max_lens"
]
=
migraphx
::
to_value
(
s
.
max_lens
());
result
[
"opt_lens"
]
=
migraphx
::
to_value
(
s
.
opt_lens
());
result
[
"sub_shapes"
]
=
migraphx
::
to_value
(
s
.
sub_shapes
());
}
else
{
...
...
test/shape_test.cpp
View file @
8f76125c
...
...
@@ -91,10 +91,7 @@ TEST_CASE(test_shape_dynamic_compares)
EXPECT
(
s0
!=
s3
);
}
TEST_CASE
(
test_shape_dynamic_bytes
)
{
}
TEST_CASE
(
test_shape_dynamic_bytes
)
{}
TEST_CASE
(
test_shape_dynamic_errors
)
{
...
...
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