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
c3861fb1
Commit
c3861fb1
authored
May 11, 2022
by
charlie
Browse files
formatting
parent
d9cd32a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
36 deletions
+18
-36
src/include/migraphx/shape.hpp
src/include/migraphx/shape.hpp
+1
-1
src/shape.cpp
src/shape.cpp
+17
-35
No files found.
src/include/migraphx/shape.hpp
View file @
c3861fb1
...
@@ -70,7 +70,7 @@ struct shape
...
@@ -70,7 +70,7 @@ struct shape
bool
is_fixed
()
const
;
bool
is_fixed
()
const
;
bool
has_optimal
()
const
;
bool
has_optimal
()
const
;
friend
bool
operator
==
(
const
dynamic_dimension
&
x
,
const
dynamic_dimension
&
y
);
friend
bool
operator
==
(
const
dynamic_dimension
&
x
,
const
dynamic_dimension
&
y
);
friend
bool
operator
!=
(
const
dynamic_dimension
&
x
,
const
dynamic_dimension
&
y
);
friend
bool
operator
!=
(
const
dynamic_dimension
&
x
,
const
dynamic_dimension
&
y
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
dynamic_dimension
&
x
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
dynamic_dimension
&
x
);
...
...
src/shape.cpp
View file @
c3861fb1
...
@@ -209,7 +209,6 @@ shape shape::from_permutation(type_t t,
...
@@ -209,7 +209,6 @@ shape shape::from_permutation(type_t t,
return
result
;
return
result
;
}
}
shape
::
type_t
shape
::
type
()
const
{
return
impl
->
m_type
;
}
shape
::
type_t
shape
::
type
()
const
{
return
impl
->
m_type
;
}
const
std
::
vector
<
std
::
size_t
>&
shape
::
lens
()
const
{
return
impl
->
m_lens
;
}
const
std
::
vector
<
std
::
size_t
>&
shape
::
lens
()
const
{
return
impl
->
m_lens
;
}
...
@@ -448,22 +447,14 @@ std::vector<std::size_t> shape::opt_lens() const
...
@@ -448,22 +447,14 @@ std::vector<std::size_t> shape::opt_lens() const
;
;
}
}
bool
shape
::
dynamic_dimension
::
is_fixed
()
const
bool
shape
::
dynamic_dimension
::
is_fixed
()
const
{
return
this
->
min
==
this
->
max
;
}
{
return
this
->
min
==
this
->
max
;
}
bool
shape
::
dynamic_dimension
::
has_optimal
()
const
bool
shape
::
dynamic_dimension
::
has_optimal
()
const
{
return
opt
!=
0
;
}
{
return
opt
!=
0
;
}
template
<
class
Self
,
class
F
>
template
<
class
Self
,
class
F
>
auto
shape
::
dynamic_dimension
::
reflect
(
Self
&
self
,
F
f
)
auto
shape
::
dynamic_dimension
::
reflect
(
Self
&
self
,
F
f
)
{
{
return
pack
(
f
(
self
.
min
,
"min"
),
return
pack
(
f
(
self
.
min
,
"min"
),
f
(
self
.
max
,
"max"
),
f
(
self
.
opt
,
"opt"
));
f
(
self
.
max
,
"max"
),
f
(
self
.
opt
,
"opt"
));
}
}
bool
operator
==
(
const
shape
::
dynamic_dimension
&
x
,
const
shape
::
dynamic_dimension
&
y
)
bool
operator
==
(
const
shape
::
dynamic_dimension
&
x
,
const
shape
::
dynamic_dimension
&
y
)
...
@@ -534,12 +525,12 @@ const std::vector<shape>& shape::sub_shapes() const { return impl->m_shapes; }
...
@@ -534,12 +525,12 @@ const std::vector<shape>& shape::sub_shapes() const { return impl->m_shapes; }
void
migraphx_to_value
(
value
&
v
,
const
shape
&
s
)
void
migraphx_to_value
(
value
&
v
,
const
shape
&
s
)
{
{
value
result
;
value
result
;
result
[
"type"
]
=
migraphx
::
to_value
(
s
.
type_string
());
result
[
"type"
]
=
migraphx
::
to_value
(
s
.
type_string
());
result
[
"lens"
]
=
migraphx
::
to_value
(
s
.
lens
());
result
[
"lens"
]
=
migraphx
::
to_value
(
s
.
lens
());
result
[
"strides"
]
=
migraphx
::
to_value
(
s
.
strides
());
result
[
"strides"
]
=
migraphx
::
to_value
(
s
.
strides
());
result
[
"sub_shapes"
]
=
migraphx
::
to_value
(
s
.
sub_shapes
());
result
[
"sub_shapes"
]
=
migraphx
::
to_value
(
s
.
sub_shapes
());
result
[
"dynamic_dimensions"
]
=
migraphx
::
to_value
(
s
.
dyn_dims
());
result
[
"dynamic_dimensions"
]
=
migraphx
::
to_value
(
s
.
dyn_dims
());
v
=
result
;
v
=
result
;
}
}
void
migraphx_from_value
(
const
value
&
v
,
shape
&
s
)
void
migraphx_from_value
(
const
value
&
v
,
shape
&
s
)
...
@@ -561,23 +552,14 @@ void migraphx_from_value(const value& v, shape& s)
...
@@ -561,23 +552,14 @@ void migraphx_from_value(const value& v, shape& s)
{
{
auto
v_dd
=
v
.
at
(
"dynamic_dimensions"
);
auto
v_dd
=
v
.
at
(
"dynamic_dimensions"
);
std
::
vector
<
shape
::
dynamic_dimension
>
dyn_dims
(
v
.
at
(
"dynamic_dimensions"
).
size
());
std
::
vector
<
shape
::
dynamic_dimension
>
dyn_dims
(
v
.
at
(
"dynamic_dimensions"
).
size
());
std
::
transform
(
std
::
transform
(
v_dd
.
begin
(),
v_dd
.
end
(),
dyn_dims
.
begin
(),
[](
migraphx
::
value
x
)
{
v_dd
.
begin
(),
auto
x_min
=
x
.
at
(
"min"
).
template
to
<
size_t
>();
v_dd
.
end
(),
auto
x_max
=
x
.
at
(
"max"
).
template
to
<
size_t
>();
dyn_dims
.
begin
(),
auto
x_opt
=
x
.
at
(
"opt"
).
template
to
<
size_t
>();
[](
migraphx
::
value
x
)
return
shape
::
dynamic_dimension
{
x_min
,
x_max
,
x_opt
};
{
});
auto
x_min
=
x
.
at
(
"min"
).
template
to
<
size_t
>();
auto
x_max
=
x
.
at
(
"max"
).
template
to
<
size_t
>();
s
=
shape
{
shape
::
parse_type
(
t
),
dyn_dims
};
auto
x_opt
=
x
.
at
(
"opt"
).
template
to
<
size_t
>();
return
shape
::
dynamic_dimension
{
x_min
,
x_max
,
x_opt
};
}
);
s
=
shape
{
shape
::
parse_type
(
t
),
dyn_dims
};
}
}
}
}
}
}
...
...
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