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
9d3fb0b5
Unverified
Commit
9d3fb0b5
authored
Aug 05, 2023
by
Ted Themistokleous
Committed by
GitHub
Aug 05, 2023
Browse files
Merge branch 'develop' into enable_navi_32_ci
parents
9c91c08d
aeb9f78c
Changes
278
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
76 additions
and
59 deletions
+76
-59
src/include/migraphx/rewrite_pooling.hpp
src/include/migraphx/rewrite_pooling.hpp
+1
-1
src/include/migraphx/rewrite_quantization.hpp
src/include/migraphx/rewrite_quantization.hpp
+1
-1
src/include/migraphx/rewrite_rnn.hpp
src/include/migraphx/rewrite_rnn.hpp
+1
-1
src/include/migraphx/schedule.hpp
src/include/migraphx/schedule.hpp
+1
-1
src/include/migraphx/schedule_model.hpp
src/include/migraphx/schedule_model.hpp
+3
-3
src/include/migraphx/shape.hpp
src/include/migraphx/shape.hpp
+28
-18
src/include/migraphx/simplify_algebra.hpp
src/include/migraphx/simplify_algebra.hpp
+1
-1
src/include/migraphx/simplify_qdq.hpp
src/include/migraphx/simplify_qdq.hpp
+1
-1
src/include/migraphx/simplify_reshapes.hpp
src/include/migraphx/simplify_reshapes.hpp
+1
-1
src/include/migraphx/split_single_dyn_dim.hpp
src/include/migraphx/split_single_dyn_dim.hpp
+1
-1
src/include/migraphx/sqlite.hpp
src/include/migraphx/sqlite.hpp
+1
-1
src/include/migraphx/stream_model.hpp
src/include/migraphx/stream_model.hpp
+3
-3
src/include/migraphx/target.hpp
src/include/migraphx/target.hpp
+3
-3
src/include/migraphx/tf.hpp
src/include/migraphx/tf.hpp
+4
-2
src/include/migraphx/tmp_dir.hpp
src/include/migraphx/tmp_dir.hpp
+1
-1
src/include/migraphx/value.hpp
src/include/migraphx/value.hpp
+8
-8
src/include/migraphx/verify.hpp
src/include/migraphx/verify.hpp
+2
-0
src/include/migraphx/verify_args.hpp
src/include/migraphx/verify_args.hpp
+1
-0
src/instruction.cpp
src/instruction.cpp
+3
-9
src/module.cpp
src/module.cpp
+11
-3
No files found.
src/include/migraphx/rewrite_pooling.hpp
View file @
9d3fb0b5
...
...
@@ -35,7 +35,7 @@ struct module;
/**
* Rewrite pooling to reduce_mean
*/
struct
rewrite_pooling
struct
MIGRAPHX_EXPORT
rewrite_pooling
{
std
::
string
name
()
const
{
return
"rewrite_pooling"
;
}
void
apply
(
module
&
m
)
const
;
...
...
src/include/migraphx/rewrite_quantization.hpp
View file @
9d3fb0b5
...
...
@@ -35,7 +35,7 @@ struct module;
/**
* Rewrite quantization ops to equivalent operators
*/
struct
rewrite_quantization
struct
MIGRAPHX_EXPORT
rewrite_quantization
{
std
::
string
name
()
const
{
return
"rewrite_quantization"
;
}
void
apply
(
module
&
m
)
const
;
...
...
src/include/migraphx/rewrite_rnn.hpp
View file @
9d3fb0b5
...
...
@@ -39,7 +39,7 @@ struct module;
/**
* Rewrite rnn to gemm and add.
*/
struct
rewrite_rnn
struct
MIGRAPHX_EXPORT
rewrite_rnn
{
std
::
string
name
()
const
{
return
"rewrite_rnn"
;
}
void
apply
(
module
&
m
)
const
;
...
...
src/include/migraphx/schedule.hpp
View file @
9d3fb0b5
...
...
@@ -37,7 +37,7 @@ struct module;
/**
* Schedule instructions for concurrent execution
*/
struct
schedule
struct
MIGRAPHX_EXPORT
schedule
{
schedule_model
model
{};
bool
enable
=
true
;
...
...
src/include/migraphx/schedule_model.hpp
View file @
9d3fb0b5
...
...
@@ -63,7 +63,7 @@ struct schedule_model
#ifdef TYPE_ERASED_DECLARATION
// Type-erased interface for:
struct
schedule_model
struct
MIGRAPHX_EXPORT
schedule_model
{
//
std
::
size_t
concurrency
()
const
;
...
...
@@ -99,7 +99,7 @@ struct schedule_model
{
using
std
::
swap
;
auto
*
derived
=
this
->
any_cast
<
PrivateDetailTypeErasedT
>
();
if
(
derived
and
private_detail_te_handle_mem_var
.
u
nique
()
)
if
(
derived
and
private_detail_te_handle_mem_var
.
u
se_count
()
==
1
)
{
*
derived
=
std
::
forward
<
PrivateDetailTypeErasedT
>
(
value
);
}
...
...
@@ -274,7 +274,7 @@ struct schedule_model
private_detail_te_handle_base_type
&
private_detail_te_get_handle
()
{
assert
(
private_detail_te_handle_mem_var
!=
nullptr
);
if
(
not
private_detail_te_handle_mem_var
.
u
nique
()
)
if
(
private_detail_te_handle_mem_var
.
u
se_count
()
>
1
)
private_detail_te_handle_mem_var
=
private_detail_te_handle_mem_var
->
clone
();
return
*
private_detail_te_handle_mem_var
;
}
...
...
src/include/migraphx/shape.hpp
View file @
9d3fb0b5
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-202
2
Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-202
3
Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
...
...
@@ -43,7 +43,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct
value
;
struct
shape_impl
;
struct
shape
struct
MIGRAPHX_EXPORT
shape
{
// Add new types here
...
...
@@ -85,7 +85,7 @@ struct shape
{
};
struct
dynamic_dimension
struct
MIGRAPHX_EXPORT
dynamic_dimension
{
std
::
size_t
min
=
0
;
std
::
size_t
max
=
0
;
...
...
@@ -100,22 +100,28 @@ struct shape
bool
is_fixed
()
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
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
dynamic_dimension
&
x
);
MIGRAPHX_EXPORT
friend
bool
operator
==
(
const
dynamic_dimension
&
x
,
const
dynamic_dimension
&
y
);
MIGRAPHX_EXPORT
friend
bool
operator
!=
(
const
dynamic_dimension
&
x
,
const
dynamic_dimension
&
y
);
MIGRAPHX_EXPORT
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
dynamic_dimension
&
x
);
// compare to fixed std::size_t dimension
friend
bool
operator
==
(
const
dynamic_dimension
&
x
,
const
std
::
size_t
&
y
);
friend
bool
operator
==
(
const
std
::
size_t
&
x
,
const
dynamic_dimension
&
y
);
friend
bool
operator
!=
(
const
dynamic_dimension
&
x
,
const
std
::
size_t
&
y
);
friend
bool
operator
!=
(
const
std
::
size_t
&
x
,
const
dynamic_dimension
&
y
);
MIGRAPHX_EXPORT
friend
bool
operator
==
(
const
dynamic_dimension
&
x
,
const
std
::
size_t
&
y
);
MIGRAPHX_EXPORT
friend
bool
operator
==
(
const
std
::
size_t
&
x
,
const
dynamic_dimension
&
y
);
MIGRAPHX_EXPORT
friend
bool
operator
!=
(
const
dynamic_dimension
&
x
,
const
std
::
size_t
&
y
);
MIGRAPHX_EXPORT
friend
bool
operator
!=
(
const
std
::
size_t
&
x
,
const
dynamic_dimension
&
y
);
// add and subtract fixed std::size_t dimension
dynamic_dimension
&
operator
+=
(
const
std
::
size_t
&
x
);
dynamic_dimension
&
operator
-=
(
const
std
::
size_t
&
x
);
friend
dynamic_dimension
operator
+
(
const
dynamic_dimension
&
x
,
const
std
::
size_t
&
y
);
friend
dynamic_dimension
operator
+
(
const
std
::
size_t
&
x
,
const
dynamic_dimension
&
y
);
friend
dynamic_dimension
operator
-
(
const
dynamic_dimension
&
x
,
const
std
::
size_t
&
y
);
MIGRAPHX_EXPORT
friend
dynamic_dimension
operator
+
(
const
dynamic_dimension
&
x
,
const
std
::
size_t
&
y
);
MIGRAPHX_EXPORT
friend
dynamic_dimension
operator
+
(
const
std
::
size_t
&
x
,
const
dynamic_dimension
&
y
);
MIGRAPHX_EXPORT
friend
dynamic_dimension
operator
-
(
const
dynamic_dimension
&
x
,
const
std
::
size_t
&
y
);
};
static
const
std
::
vector
<
type_t
>&
types
();
...
...
@@ -234,6 +240,10 @@ struct shape
template
<
class
Iterator
>
std
::
size_t
index
(
Iterator
start
,
Iterator
last
)
const
{
if
(
this
->
dynamic
())
{
MIGRAPHX_THROW
(
"SHAPE: index() called on dynamic shape"
);
}
assert
(
std
::
distance
(
start
,
last
)
<=
this
->
lens
().
size
());
assert
(
this
->
lens
().
size
()
==
this
->
strides
().
size
());
return
std
::
inner_product
(
start
,
last
,
this
->
strides
().
begin
(),
std
::
size_t
{
0
});
// NOLINT
...
...
@@ -286,9 +296,9 @@ struct shape
// convert the shape to a static one setting any non-fixed dynamic_dimensions to x
shape
to_static
(
std
::
size_t
x
)
const
;
friend
bool
operator
==
(
const
shape
&
x
,
const
shape
&
y
);
friend
bool
operator
!=
(
const
shape
&
x
,
const
shape
&
y
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
shape
&
x
);
MIGRAPHX_EXPORT
friend
bool
operator
==
(
const
shape
&
x
,
const
shape
&
y
);
MIGRAPHX_EXPORT
friend
bool
operator
!=
(
const
shape
&
x
,
const
shape
&
y
);
MIGRAPHX_EXPORT
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
shape
&
x
);
template
<
class
T
>
struct
as
...
...
@@ -396,8 +406,8 @@ struct shape
std
::
shared_ptr
<
const
shape_impl
>
impl
;
};
void
migraphx_to_value
(
value
&
v
,
const
shape
&
s
);
void
migraphx_from_value
(
const
value
&
v
,
shape
&
s
);
MIGRAPHX_EXPORT
void
migraphx_to_value
(
value
&
v
,
const
shape
&
s
);
MIGRAPHX_EXPORT
void
migraphx_from_value
(
const
value
&
v
,
shape
&
s
);
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/simplify_algebra.hpp
View file @
9d3fb0b5
...
...
@@ -35,7 +35,7 @@ struct module;
/**
* Simplify many algebraic instructions to more efficient versions.
*/
struct
simplify_algebra
struct
MIGRAPHX_EXPORT
simplify_algebra
{
std
::
string
name
()
const
{
return
"simplify_algebra"
;
}
void
apply
(
module
&
m
)
const
;
...
...
src/include/migraphx/simplify_qdq.hpp
View file @
9d3fb0b5
...
...
@@ -36,7 +36,7 @@ struct module;
* Inserts quantized operators in place of dq->quantizable_op->q
* then removes remaining fake quantization (q->dq pairs)
*/
struct
simplify_qdq
struct
MIGRAPHX_EXPORT
simplify_qdq
{
std
::
string
name
()
const
{
return
"simplify_qdq"
;
}
void
apply
(
module
&
m
)
const
;
...
...
src/include/migraphx/simplify_reshapes.hpp
View file @
9d3fb0b5
...
...
@@ -36,7 +36,7 @@ struct module;
/**
* Eliminate redundant reshapes.
*/
struct
simplify_reshapes
struct
MIGRAPHX_EXPORT
simplify_reshapes
{
std
::
string
name
()
const
{
return
"simplify_reshapes"
;
}
void
apply
(
module
&
m
)
const
;
...
...
src/include/migraphx/split_single_dyn_dim.hpp
View file @
9d3fb0b5
...
...
@@ -36,7 +36,7 @@ inline namespace MIGRAPHX_INLINE_NS {
* Split dynamic dimension over submodules if exactly one dimension in the parameter list is
* dynamic.
*/
struct
split_single_dyn_dim
struct
MIGRAPHX_EXPORT
split_single_dyn_dim
{
std
::
string
name
()
const
{
return
"split_single_dyn_dim"
;
}
void
apply
(
module_pass_manager
&
)
const
;
...
...
src/include/migraphx/sqlite.hpp
View file @
9d3fb0b5
...
...
@@ -35,7 +35,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct
sqlite_impl
;
struct
sqlite
struct
MIGRAPHX_EXPORT
sqlite
{
sqlite
()
=
default
;
static
sqlite
read
(
const
fs
::
path
&
p
);
...
...
src/include/migraphx/stream_model.hpp
View file @
9d3fb0b5
...
...
@@ -62,7 +62,7 @@ struct stream_model
#ifdef TYPE_ERASED_DECLARATION
// Type-erased interface for:
struct
stream_model
struct
MIGRAPHX_EXPORT
stream_model
{
//
std
::
size_t
get_nstream
()
const
;
...
...
@@ -100,7 +100,7 @@ struct stream_model
{
using
std
::
swap
;
auto
*
derived
=
this
->
any_cast
<
PrivateDetailTypeErasedT
>
();
if
(
derived
and
private_detail_te_handle_mem_var
.
u
nique
()
)
if
(
derived
and
private_detail_te_handle_mem_var
.
u
se_count
()
==
1
)
{
*
derived
=
std
::
forward
<
PrivateDetailTypeErasedT
>
(
value
);
}
...
...
@@ -288,7 +288,7 @@ struct stream_model
private_detail_te_handle_base_type
&
private_detail_te_get_handle
()
{
assert
(
private_detail_te_handle_mem_var
!=
nullptr
);
if
(
not
private_detail_te_handle_mem_var
.
u
nique
()
)
if
(
private_detail_te_handle_mem_var
.
u
se_count
()
>
1
)
private_detail_te_handle_mem_var
=
private_detail_te_handle_mem_var
->
clone
();
return
*
private_detail_te_handle_mem_var
;
}
...
...
src/include/migraphx/target.hpp
View file @
9d3fb0b5
...
...
@@ -127,7 +127,7 @@ supported_segments target_find_supported(T&, const_module_ref, support_metric)
#ifdef TYPE_ERASED_DECLARATION
// Type-erased interface for:
struct
target
struct
MIGRAPHX_EXPORT
target
{
//
std
::
string
name
()
const
;
...
...
@@ -167,7 +167,7 @@ struct target
{
using
std
::
swap
;
auto
*
derived
=
this
->
any_cast
<
PrivateDetailTypeErasedT
>
();
if
(
derived
and
private_detail_te_handle_mem_var
.
u
nique
()
)
if
(
derived
and
private_detail_te_handle_mem_var
.
u
se_count
()
==
1
)
{
*
derived
=
std
::
forward
<
PrivateDetailTypeErasedT
>
(
value
);
}
...
...
@@ -428,7 +428,7 @@ struct target
private_detail_te_handle_base_type
&
private_detail_te_get_handle
()
{
assert
(
private_detail_te_handle_mem_var
!=
nullptr
);
if
(
not
private_detail_te_handle_mem_var
.
u
nique
()
)
if
(
private_detail_te_handle_mem_var
.
u
se_count
()
>
1
)
private_detail_te_handle_mem_var
=
private_detail_te_handle_mem_var
->
clone
();
return
*
private_detail_te_handle_mem_var
;
}
...
...
src/include/migraphx/tf.hpp
View file @
9d3fb0b5
...
...
@@ -26,6 +26,7 @@
#include <migraphx/program.hpp>
#include <migraphx/config.hpp>
#include <migraphx/tf/export.h>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
...
...
@@ -41,9 +42,10 @@ struct tf_options
};
/// Create a program from a tf pb file (default is nhwc format)
program
parse_tf
(
const
std
::
string
&
name
,
const
tf_options
&
options
=
tf_options
{});
MIGRAPHX_TF_EXPORT
program
parse_tf
(
const
std
::
string
&
name
,
const
tf_options
&
options
=
tf_options
{});
std
::
vector
<
std
::
string
>
get_tf_operators
();
MIGRAPHX_TF_EXPORT
std
::
vector
<
std
::
string
>
get_tf_operators
();
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/tmp_dir.hpp
View file @
9d3fb0b5
...
...
@@ -30,7 +30,7 @@
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
struct
tmp_dir
struct
MIGRAPHX_EXPORT
tmp_dir
{
fs
::
path
path
;
tmp_dir
(
const
std
::
string
&
prefix
=
""
);
...
...
src/include/migraphx/value.hpp
View file @
9d3fb0b5
...
...
@@ -141,7 +141,7 @@ To try_convert_value(const From& x)
return
detail
::
try_convert_value_impl
<
To
>
(
rank
<
3
>
{},
x
);
}
struct
value
struct
MIGRAPHX_EXPORT
value
{
// clang-format off
#define MIGRAPHX_VISIT_VALUE_TYPES(m) \
...
...
@@ -453,14 +453,14 @@ struct value
std
::
vector
<
literal_to_string
<
To
>>
{
default_value
.
begin
(),
default_value
.
end
()});
}
friend
bool
operator
==
(
const
value
&
x
,
const
value
&
y
);
friend
bool
operator
!=
(
const
value
&
x
,
const
value
&
y
);
friend
bool
operator
<
(
const
value
&
x
,
const
value
&
y
);
friend
bool
operator
<=
(
const
value
&
x
,
const
value
&
y
);
friend
bool
operator
>
(
const
value
&
x
,
const
value
&
y
);
friend
bool
operator
>=
(
const
value
&
x
,
const
value
&
y
);
MIGRAPHX_EXPORT
friend
bool
operator
==
(
const
value
&
x
,
const
value
&
y
);
MIGRAPHX_EXPORT
friend
bool
operator
!=
(
const
value
&
x
,
const
value
&
y
);
MIGRAPHX_EXPORT
friend
bool
operator
<
(
const
value
&
x
,
const
value
&
y
);
MIGRAPHX_EXPORT
friend
bool
operator
<=
(
const
value
&
x
,
const
value
&
y
);
MIGRAPHX_EXPORT
friend
bool
operator
>
(
const
value
&
x
,
const
value
&
y
);
MIGRAPHX_EXPORT
friend
bool
operator
>=
(
const
value
&
x
,
const
value
&
y
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
value
&
d
);
MIGRAPHX_EXPORT
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
value
&
d
);
std
::
size_t
hash
()
const
;
...
...
src/include/migraphx/verify.hpp
View file @
9d3fb0b5
...
...
@@ -35,6 +35,7 @@
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
verify
{
// Compute the value of a range
template
<
class
R
>
...
...
@@ -196,6 +197,7 @@ bool verify_range(const R1& r1, const R2& r2, double tolerance = 80, double* out
return
error
<=
threshold
;
}
}
// namespace verify
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/include/migraphx/verify_args.hpp
View file @
9d3fb0b5
...
...
@@ -31,6 +31,7 @@
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
MIGRAPHX_EXPORT
bool
verify_args
(
const
std
::
string
&
name
,
const
argument
&
ref_arg
,
const
argument
&
target_arg
,
...
...
src/instruction.cpp
View file @
9d3fb0b5
...
...
@@ -64,10 +64,7 @@ void instruction::replace(const shape& r)
result
=
r
;
for
(
auto
&&
ins
:
output
)
{
if
(
ins
->
name
()
==
"@return"
)
continue
;
assert
(
ins
->
name
().
front
()
!=
'@'
);
assert
(
ins
->
name
()
==
"@return"
or
ins
->
name
().
front
()
!=
'@'
);
ins
->
recompute_shape
();
}
}
...
...
@@ -122,10 +119,6 @@ bool instruction::valid() const
{
computed
=
result
;
}
else
if
(
op
.
name
()
==
"@return"
)
{
computed
=
{};
}
else
{
try
...
...
@@ -145,6 +138,7 @@ bool instruction::valid() const
}
shape
instruction
::
get_shape
()
const
{
return
result
;
}
const
literal
&
instruction
::
get_literal
()
const
{
assert
(
op
.
name
()
==
"@literal"
);
...
...
@@ -467,7 +461,7 @@ operation instruction::normalized_operator() const
if
(
this
->
need_normalization
())
{
auto
s
=
this
->
inputs
().
front
()
->
get_shape
();
if
(
not
normalize_attributes
(
o
,
s
.
max_lens
()
))
if
(
not
normalize_attributes
(
o
,
s
))
return
this
->
get_operator
();
}
return
o
;
...
...
src/module.cpp
View file @
9d3fb0b5
...
...
@@ -460,11 +460,11 @@ instruction_ref module::add_parameter(std::string name, shape s)
instruction_ref
module
::
add_return
(
std
::
vector
<
instruction_ref
>
args
)
{
impl
->
push_back
({
builtin
::
returns
{},
{},
std
::
move
(
args
)});
shape
instr_shape
=
compute_shape
(
builtin
::
returns
{},
args
);
impl
->
push_back
({
builtin
::
returns
{},
instr_shape
,
std
::
move
(
args
)});
auto
result
=
std
::
prev
(
impl
->
instructions
.
end
());
instruction
::
backreference
(
result
);
assert
(
result
->
valid
(
begin
()));
return
result
;
}
...
...
@@ -1011,9 +1011,17 @@ std::vector<module_ref> module::get_sub_modules(bool shallow) const
module
&
module
::
sort
()
{
auto
implicit_deps
=
calc_implicit_deps
();
fix
([
&
](
auto
self
,
auto
ins
)
{
this
->
move_instruction
(
ins
,
this
->
begin
());
for
(
auto
child
:
ins
->
inputs
())
auto
ins_inputs
=
ins
->
inputs
();
if
(
implicit_deps
.
find
(
ins
)
!=
implicit_deps
.
end
())
{
auto
ins_implict_inputs
=
implicit_deps
.
at
(
ins
);
ins_inputs
.
insert
(
ins_inputs
.
end
(),
ins_implict_inputs
.
begin
(),
ins_implict_inputs
.
end
());
}
for
(
auto
child
:
ins_inputs
)
{
if
(
not
contains
(
this
->
impl
->
instructions
,
child
))
{
...
...
Prev
1
2
3
4
5
6
7
8
9
10
…
14
Next
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