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
623634ed
"docs/vscode:/vscode.git/clone" did not exist on "74e5ea90a04276ba93f99fad21d2f49e91a85149"
Commit
623634ed
authored
Jul 14, 2022
by
charlie
Browse files
Merge branch 'dyn_conv' of github.com:ROCmSoftwarePlatform/AMDMIGraphX into dyn_nms
parents
271497af
604e4493
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
15 additions
and
13 deletions
+15
-13
src/dead_code_elimination.cpp
src/dead_code_elimination.cpp
+4
-2
src/include/migraphx/normalize_attributes.hpp
src/include/migraphx/normalize_attributes.hpp
+1
-1
src/include/migraphx/operation.hpp
src/include/migraphx/operation.hpp
+1
-1
src/insert_pad.cpp
src/insert_pad.cpp
+1
-0
src/instruction.cpp
src/instruction.cpp
+1
-1
src/normalize_attributes.cpp
src/normalize_attributes.cpp
+5
-6
src/normalize_ops.cpp
src/normalize_ops.cpp
+1
-1
tools/include/operation.hpp
tools/include/operation.hpp
+1
-1
No files found.
src/dead_code_elimination.cpp
View file @
623634ed
...
@@ -48,9 +48,11 @@ void dead_code_elimination::apply(module& m) const
...
@@ -48,9 +48,11 @@ void dead_code_elimination::apply(module& m) const
// Skip the last instruction
// Skip the last instruction
if
(
i
==
last
)
if
(
i
==
last
)
break
;
break
;
// Skip instruction with empty shape as output unless its a builtin or undefined or identity
// Skip instruction with empty shape as output unless its [dynamic, builtin, undefined,
// identity, allocate]
if
((
not
i
->
get_shape
().
dynamic
()
and
i
->
get_shape
().
elements
()
==
0
)
and
if
((
not
i
->
get_shape
().
dynamic
()
and
i
->
get_shape
().
elements
()
==
0
)
and
i
->
name
().
front
()
!=
'@'
and
not
contains
({
"undefined"
,
"identity"
,
"allocate"
},
i
->
name
()))
i
->
name
().
front
()
!=
'@'
and
not
contains
({
"undefined"
,
"identity"
,
"allocate"
},
i
->
name
()))
continue
;
continue
;
assert
(
std
::
distance
(
m
.
begin
(),
i
)
<=
std
::
distance
(
m
.
begin
(),
last
));
assert
(
std
::
distance
(
m
.
begin
(),
i
)
<=
std
::
distance
(
m
.
begin
(),
last
));
std
::
unordered_set
<
instruction_ref
>
visited
;
std
::
unordered_set
<
instruction_ref
>
visited
;
...
...
src/include/migraphx/normalize_attributes.hpp
View file @
623634ed
...
@@ -42,7 +42,7 @@ struct select_dependent_type
...
@@ -42,7 +42,7 @@ struct select_dependent_type
template
<
class
T
,
class
...
Ts
>
template
<
class
T
,
class
...
Ts
>
using
dependent_type
=
typename
select_dependent_type
<
T
,
Ts
...
>::
type
;
using
dependent_type
=
typename
select_dependent_type
<
T
,
Ts
...
>::
type
;
bool
normalize_attributes
(
operation
&
op
,
const
s
hape
&
s
);
bool
normalize_attributes
(
operation
&
op
,
const
s
td
::
vector
<
std
::
size_t
>&
len
s
);
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
}
// namespace migraphx
...
...
src/include/migraphx/operation.hpp
View file @
623634ed
...
@@ -140,7 +140,7 @@ auto compute_shape_op(rank<2>, const T& x, const std::vector<shape>& inputs)
...
@@ -140,7 +140,7 @@ auto compute_shape_op(rank<2>, const T& x, const std::vector<shape>& inputs)
->
decltype
(
x
.
normalize_compute_shape
(
inputs
))
->
decltype
(
x
.
normalize_compute_shape
(
inputs
))
{
{
dependent_type
<
operation
,
T
>
y
=
x
;
dependent_type
<
operation
,
T
>
y
=
x
;
normalize_attributes
(
y
,
inputs
[
0
]);
normalize_attributes
(
y
,
inputs
[
0
]
.
max_lens
()
);
return
any_cast
<
T
>
(
y
).
normalize_compute_shape
(
inputs
);
return
any_cast
<
T
>
(
y
).
normalize_compute_shape
(
inputs
);
}
}
...
...
src/insert_pad.cpp
View file @
623634ed
...
@@ -40,6 +40,7 @@ static void update_op(const instruction_ref& input, const instruction_ref& ins,
...
@@ -40,6 +40,7 @@ static void update_op(const instruction_ref& input, const instruction_ref& ins,
auto
val
=
op
.
to_value
();
auto
val
=
op
.
to_value
();
auto
op_padding
=
val
.
at
(
"padding"
).
to_vector
<
size_t
>
();
auto
op_padding
=
val
.
at
(
"padding"
).
to_vector
<
size_t
>
();
// skip if shape is dynamic
if
(
input
->
get_shape
().
dynamic
())
if
(
input
->
get_shape
().
dynamic
())
{
{
return
;
return
;
...
...
src/instruction.cpp
View file @
623634ed
...
@@ -446,7 +446,7 @@ operation instruction::normalized_operator() const
...
@@ -446,7 +446,7 @@ operation instruction::normalized_operator() const
if
(
this
->
need_normalization
())
if
(
this
->
need_normalization
())
{
{
auto
s
=
this
->
inputs
().
front
()
->
get_shape
();
auto
s
=
this
->
inputs
().
front
()
->
get_shape
();
if
(
!
normalize_attributes
(
o
,
s
))
if
(
!
normalize_attributes
(
o
,
s
.
max_lens
()
))
return
this
->
get_operator
();
return
this
->
get_operator
();
}
}
return
o
;
return
o
;
...
...
src/normalize_attributes.cpp
View file @
623634ed
...
@@ -150,22 +150,21 @@ auto tune_pad_attribute(const value& val)
...
@@ -150,22 +150,21 @@ auto tune_pad_attribute(const value& val)
return
result
;
return
result
;
}
}
bool
normalize_attributes
(
operation
&
op
,
const
s
hape
&
s
)
bool
normalize_attributes
(
operation
&
op
,
const
s
td
::
vector
<
std
::
size_t
>&
len
s
)
{
{
bool
tuned
=
false
;
bool
tuned
=
false
;
auto
attrs
=
op
.
attributes
();
auto
attrs
=
op
.
attributes
();
auto
val
=
op
.
to_value
();
auto
val
=
op
.
to_value
();
if
(
attrs
.
contains
(
"normalize_padding"
))
if
(
attrs
.
contains
(
"normalize_padding"
))
{
{
auto
num_dims
=
s
.
max_lens
().
size
();
auto
padding
=
val
.
at
(
attrs
.
at
(
"normalize_padding"
).
to
<
std
::
string
>
());
auto
padding
=
val
.
at
(
attrs
.
at
(
"normalize_padding"
).
to
<
std
::
string
>
());
auto
padding_size
=
padding
.
size
();
auto
padding_size
=
padding
.
size
();
// for now, assume the dimensions to pad start at dim 2
// for now, assume the dimensions to pad start at dim 2
auto
padding_start
=
2
;
auto
padding_start
=
2
;
if
(
padding_size
==
2
*
(
num_dims
-
padding_start
))
if
(
padding_size
==
2
*
(
lens
.
size
()
-
padding_start
))
tuned
=
true
;
tuned
=
true
;
else
if
(
padding_size
!=
(
num_dims
-
padding_start
))
else
if
(
padding_size
!=
(
lens
.
size
()
-
padding_start
))
MIGRAPHX_THROW
(
"inconsistent padding size"
);
MIGRAPHX_THROW
(
"inconsistent padding size"
);
else
else
{
{
...
@@ -195,7 +194,7 @@ bool normalize_attributes(operation& op, const shape& s)
...
@@ -195,7 +194,7 @@ bool normalize_attributes(operation& op, const shape& s)
axes
=
val
.
at
(
"axes"
).
without_key
().
to_vector
<
int64_t
>
();
axes
=
val
.
at
(
"axes"
).
without_key
().
to_vector
<
int64_t
>
();
}
}
auto
vec
=
vv
.
to_vector
<
int64_t
>
();
auto
vec
=
vv
.
to_vector
<
int64_t
>
();
auto
result
=
tune_attribute
(
vec
,
axes
,
rv
.
without_key
(),
s
.
lens
()
);
auto
result
=
tune_attribute
(
vec
,
axes
,
rv
.
without_key
(),
lens
);
val
[
key
]
=
result
;
val
[
key
]
=
result
;
op
.
from_value
(
val
);
op
.
from_value
(
val
);
val
=
op
.
to_value
();
val
=
op
.
to_value
();
...
@@ -204,7 +203,7 @@ bool normalize_attributes(operation& op, const shape& s)
...
@@ -204,7 +203,7 @@ bool normalize_attributes(operation& op, const shape& s)
else
else
{
{
auto
num
=
vv
.
to
<
int64_t
>
();
auto
num
=
vv
.
to
<
int64_t
>
();
auto
result
=
tune_attribute
({
num
},
{
num
},
rv
.
without_key
(),
s
.
lens
()
);
auto
result
=
tune_attribute
({
num
},
{
num
},
rv
.
without_key
(),
lens
);
val
[
key
]
=
result
.
front
();
val
[
key
]
=
result
.
front
();
op
.
from_value
(
val
);
op
.
from_value
(
val
);
val
=
op
.
to_value
();
val
=
op
.
to_value
();
...
...
src/normalize_ops.cpp
View file @
623634ed
...
@@ -45,7 +45,7 @@ void normalize_ops::apply(module& m) const
...
@@ -45,7 +45,7 @@ void normalize_ops::apply(module& m) const
auto
s
=
inputs
[
0
]
->
get_shape
();
auto
s
=
inputs
[
0
]
->
get_shape
();
migraphx
::
operation
tuned_op
=
ins
->
get_operator
();
migraphx
::
operation
tuned_op
=
ins
->
get_operator
();
if
(
normalize_attributes
(
tuned_op
,
s
))
if
(
normalize_attributes
(
tuned_op
,
s
.
max_lens
()
))
{
{
m
.
replace_instruction
(
ins
,
tuned_op
,
inputs
);
m
.
replace_instruction
(
ins
,
tuned_op
,
inputs
);
ins
->
set_normalized
();
ins
->
set_normalized
();
...
...
tools/include/operation.hpp
View file @
623634ed
...
@@ -139,7 +139,7 @@ auto compute_shape_op(rank<2>, const T& x, const std::vector<shape>& inputs)
...
@@ -139,7 +139,7 @@ auto compute_shape_op(rank<2>, const T& x, const std::vector<shape>& inputs)
->
decltype
(
x
.
normalize_compute_shape
(
inputs
))
->
decltype
(
x
.
normalize_compute_shape
(
inputs
))
{
{
dependent_type
<
operation
,
T
>
y
=
x
;
dependent_type
<
operation
,
T
>
y
=
x
;
normalize_attributes
(
y
,
inputs
[
0
]);
normalize_attributes
(
y
,
inputs
[
0
]
.
max_lens
()
);
return
any_cast
<
T
>
(
y
).
normalize_compute_shape
(
inputs
);
return
any_cast
<
T
>
(
y
).
normalize_compute_shape
(
inputs
);
}
}
...
...
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