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
40fbef9b
Unverified
Commit
40fbef9b
authored
Aug 05, 2023
by
Ted Themistokleous
Committed by
GitHub
Aug 05, 2023
Browse files
Merge branch 'develop' into threaded_nms
parents
d164b151
aeb9f78c
Changes
440
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
68 additions
and
45 deletions
+68
-45
src/include/migraphx/optimize_module.hpp
src/include/migraphx/optimize_module.hpp
+1
-1
src/include/migraphx/pad_calc.hpp
src/include/migraphx/pad_calc.hpp
+3
-0
src/include/migraphx/pass.hpp
src/include/migraphx/pass.hpp
+4
-4
src/include/migraphx/pass_manager.hpp
src/include/migraphx/pass_manager.hpp
+9
-2
src/include/migraphx/permutation.hpp
src/include/migraphx/permutation.hpp
+10
-6
src/include/migraphx/preallocate_param.hpp
src/include/migraphx/preallocate_param.hpp
+1
-1
src/include/migraphx/process.hpp
src/include/migraphx/process.hpp
+1
-1
src/include/migraphx/program.hpp
src/include/migraphx/program.hpp
+9
-3
src/include/migraphx/promote_literals.hpp
src/include/migraphx/promote_literals.hpp
+1
-1
src/include/migraphx/propagate_constant.hpp
src/include/migraphx/propagate_constant.hpp
+1
-1
src/include/migraphx/quantization.hpp
src/include/migraphx/quantization.hpp
+7
-5
src/include/migraphx/quantize_fp16.hpp
src/include/migraphx/quantize_fp16.hpp
+1
-1
src/include/migraphx/quantize_int8.hpp
src/include/migraphx/quantize_int8.hpp
+2
-2
src/include/migraphx/raw_data.hpp
src/include/migraphx/raw_data.hpp
+1
-0
src/include/migraphx/reduce_dims.hpp
src/include/migraphx/reduce_dims.hpp
+1
-1
src/include/migraphx/reflect.hpp
src/include/migraphx/reflect.hpp
+1
-1
src/include/migraphx/register_op.hpp
src/include/migraphx/register_op.hpp
+6
-6
src/include/migraphx/register_target.hpp
src/include/migraphx/register_target.hpp
+5
-5
src/include/migraphx/replace_allocate.hpp
src/include/migraphx/replace_allocate.hpp
+3
-3
src/include/migraphx/rewrite_gelu.hpp
src/include/migraphx/rewrite_gelu.hpp
+1
-1
No files found.
src/include/migraphx/optimize_module.hpp
View file @
40fbef9b
...
...
@@ -36,7 +36,7 @@ struct module_pass_manager;
/**
* Runs several passes in a loop
*/
struct
optimize_module
struct
MIGRAPHX_EXPORT
optimize_module
{
std
::
string
name
()
const
{
return
"optimize_module"
;
}
void
apply
(
module_pass_manager
&
mpm
)
const
;
...
...
src/include/migraphx/pad_calc.hpp
View file @
40fbef9b
...
...
@@ -32,6 +32,7 @@
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
MIGRAPHX_EXPORT
void
calculate_padding
(
int64_t
idx
,
std
::
vector
<
int64_t
>&
pads
,
int64_t
input_dim
,
...
...
@@ -45,6 +46,7 @@ void calculate_padding(int64_t idx,
* where the padding calculation must be done at evaluation time.
* \return padding in the form of {x0_begin, x1_begin, ... x0_end , x1_end, ...}
*/
MIGRAPHX_EXPORT
std
::
vector
<
std
::
size_t
>
calc_dyn_auto_pad
(
const
std
::
vector
<
std
::
size_t
>&
input_lens
,
const
std
::
vector
<
std
::
size_t
>&
wei_lens
,
const
std
::
vector
<
std
::
size_t
>&
strides
,
...
...
@@ -53,6 +55,7 @@ std::vector<std::size_t> calc_dyn_auto_pad(const std::vector<std::size_t>& input
// Used for dynamic auto padding of convolution operators since padding needs to be computed at
// evaulation time.
MIGRAPHX_EXPORT
shape
compute_padded_shape
(
const
shape
&
input
,
const
shape
&
weights
,
const
std
::
vector
<
std
::
size_t
>&
padding
,
...
...
src/include/migraphx/pass.hpp
View file @
40fbef9b
...
...
@@ -57,7 +57,7 @@ struct pass
#else
module
&
get_module
(
module_pass_manager
&
mpm
);
MIGRAPHX_EXPORT
module
&
get_module
(
module_pass_manager
&
mpm
);
namespace
detail
{
...
...
@@ -84,7 +84,7 @@ void module_pass_manager_apply(const T& x, module_pass_manager& mpm)
#ifdef TYPE_ERASED_DECLARATION
// Type-erased interface for:
struct
pass
struct
MIGRAPHX_EXPORT
pass
{
//
std
::
string
name
()
const
;
...
...
@@ -116,7 +116,7 @@ struct pass
{
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
);
}
...
...
@@ -292,7 +292,7 @@ struct pass
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/pass_manager.hpp
View file @
40fbef9b
...
...
@@ -26,6 +26,7 @@
#include <migraphx/config.hpp>
#include <migraphx/pass.hpp>
#include <migraphx/module_ref.hpp>
#include <migraphx/tracer.hpp>
#include <vector>
...
...
@@ -46,8 +47,14 @@ struct module_pass_manager
virtual
~
module_pass_manager
()
{}
};
void
run_passes
(
module
&
mod
,
const
std
::
vector
<
pass
>&
passes
,
tracer
trace
=
tracer
{});
void
run_passes
(
program
&
prog
,
const
std
::
vector
<
pass
>&
passes
,
tracer
trace
=
tracer
{});
MIGRAPHX_EXPORT
void
run_passes
(
program
&
prog
,
module_ref
root_mod
,
const
std
::
vector
<
pass
>&
passes
,
tracer
trace
=
tracer
{});
MIGRAPHX_EXPORT
void
run_passes
(
module
&
mod
,
const
std
::
vector
<
pass
>&
passes
,
tracer
trace
=
tracer
{});
MIGRAPHX_EXPORT
void
run_passes
(
program
&
prog
,
const
std
::
vector
<
pass
>&
passes
,
tracer
trace
=
tracer
{});
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/permutation.hpp
View file @
40fbef9b
...
...
@@ -43,7 +43,7 @@ inline Vector reorder_dims(const Vector& dims, const std::vector<int64_t>& permu
return
result
;
}
shape
reorder_shape
(
const
shape
&
s
,
const
std
::
vector
<
int64_t
>&
permutation
);
MIGRAPHX_EXPORT
shape
reorder_shape
(
const
shape
&
s
,
const
std
::
vector
<
int64_t
>&
permutation
);
template
<
class
Vector
,
class
Op
>
inline
std
::
vector
<
int64_t
>
sort_permutation
(
const
Vector
&
data
,
Op
op
)
...
...
@@ -56,15 +56,19 @@ inline std::vector<int64_t> sort_permutation(const Vector& data, Op op)
}
/*!
* Returns the permutation
needed to apply to the shape
to undo the
current
permutation
* Returns the
inverse
permutation
that could be applied
to undo the
inputted
permutation
*/
std
::
vector
<
int64_t
>
invert_permutation
(
const
std
::
vector
<
int64_t
>&
permutation
);
MIGRAPHX_EXPORT
std
::
vector
<
int64_t
>
invert_permutation
(
const
std
::
vector
<
int64_t
>&
permutation
);
/*!
* Finds the permutation
most likely from a transpose operator that has been applied to the shape.
* Finds the permutation
that would make the shape not transposed (refering to shape.transposed())
*/
std
::
vector
<
int64_t
>
find_permutation
(
const
shape
&
s
);
std
::
vector
<
int64_t
>
find_permutation
(
const
std
::
vector
<
shape
>&
shapes
);
MIGRAPHX_EXPORT
std
::
vector
<
int64_t
>
find_permutation
(
const
shape
&
s
);
MIGRAPHX_EXPORT
std
::
vector
<
int64_t
>
find_permutation
(
const
std
::
vector
<
shape
>&
shapes
);
/// Normalize the shapes so the order of dimensions will be in the order it is
/// in memory as much as possible.
MIGRAPHX_EXPORT
std
::
vector
<
shape
>
normalize_permutation
(
const
std
::
vector
<
shape
>&
shapes
);
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/preallocate_param.hpp
View file @
40fbef9b
...
...
@@ -32,7 +32,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct
module
;
struct
preallocate_param
struct
MIGRAPHX_EXPORT
preallocate_param
{
std
::
string
param
;
allocation_model
model
;
...
...
src/include/migraphx/process.hpp
View file @
40fbef9b
...
...
@@ -35,7 +35,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct
process_impl
;
struct
process
struct
MIGRAPHX_EXPORT
process
{
using
writer
=
std
::
function
<
void
(
const
char
*
,
std
::
size_t
)
>
;
process
(
const
std
::
string
&
cmd
);
...
...
src/include/migraphx/program.hpp
View file @
40fbef9b
...
...
@@ -54,7 +54,7 @@ struct marker;
/**
* @brief Stores the instruction stream
*/
struct
program
struct
MIGRAPHX_EXPORT
program
{
program
();
...
...
@@ -79,6 +79,9 @@ struct program
std
::
vector
<
argument
>
eval
(
parameter_map
params
,
execution_environment
exec_env
=
execution_environment
{})
const
;
void
finish
()
const
;
std
::
size_t
size
()
const
;
std
::
vector
<
shape
>
get_output_shapes
()
const
;
...
...
@@ -92,6 +95,9 @@ struct program
void
compile
(
const
target
&
t
,
compile_options
options
=
compile_options
{});
void
compile
(
const
std
::
vector
<
target
>&
targets
,
std
::
vector
<
compile_options
>
compile_opts
=
{});
bool
is_compiled
()
const
;
void
finalize
();
...
...
@@ -124,8 +130,8 @@ struct program
program
&
sort
();
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
program
&
p
);
friend
bool
operator
==
(
const
program
&
x
,
const
program
&
y
);
MIGRAPHX_EXPORT
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
program
&
p
);
MIGRAPHX_EXPORT
friend
bool
operator
==
(
const
program
&
x
,
const
program
&
y
);
friend
bool
operator
!=
(
const
program
&
x
,
const
program
&
y
)
{
return
not
(
x
==
y
);
}
// module related api
...
...
src/include/migraphx/promote_literals.hpp
View file @
40fbef9b
...
...
@@ -35,7 +35,7 @@ inline namespace MIGRAPHX_INLINE_NS {
* Replace literals in submodules with literals in the root module.
* Intended to allow for reuse of the literals between submodules.
*/
struct
promote_literals
struct
MIGRAPHX_EXPORT
promote_literals
{
std
::
string
name
()
const
{
return
"promote_literals"
;
}
void
apply
(
module_pass_manager
&
)
const
;
...
...
src/include/migraphx/propagate_constant.hpp
View file @
40fbef9b
...
...
@@ -35,7 +35,7 @@ struct module;
/**
* Replace instructions which take all literals with a literal of the computation.
*/
struct
propagate_constant
struct
MIGRAPHX_EXPORT
propagate_constant
{
std
::
string
name
()
const
{
return
"propagate_constant"
;
}
void
apply
(
module
&
m
)
const
;
...
...
src/include/migraphx/quantization.hpp
View file @
40fbef9b
...
...
@@ -38,12 +38,14 @@ inline namespace MIGRAPHX_INLINE_NS {
struct
program
;
void
quantize_fp16
(
program
&
prog
,
const
std
::
vector
<
std
::
string
>&
ins_names
=
{
"all"
});
MIGRAPHX_EXPORT
void
quantize_fp16
(
program
&
prog
,
const
std
::
vector
<
std
::
string
>&
ins_names
=
{
"all"
});
void
quantize_int8
(
program
&
prog
,
const
target
&
t
,
const
std
::
vector
<
parameter_map
>&
calibration
,
const
std
::
vector
<
std
::
string
>&
ins_names
=
{
"dot"
,
"convolution"
});
MIGRAPHX_EXPORT
void
quantize_int8
(
program
&
prog
,
const
target
&
t
,
const
std
::
vector
<
parameter_map
>&
calibration
,
const
std
::
vector
<
std
::
string
>&
ins_names
=
{
"dot"
,
"convolution"
});
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/quantize_fp16.hpp
View file @
40fbef9b
...
...
@@ -37,7 +37,7 @@ struct module;
/**
* quantize a program to fp16
*/
struct
quantize_fp16_pass
struct
MIGRAPHX_EXPORT
quantize_fp16_pass
{
std
::
vector
<
std
::
string
>
ins_names
=
{
"all"
};
std
::
string
name
()
const
{
return
"quantize_fp16"
;
}
...
...
src/include/migraphx/quantize_int8.hpp
View file @
40fbef9b
...
...
@@ -39,7 +39,7 @@ struct module;
/**
* capture inputs of operators to be quantized to int8
*/
struct
capture_arguments_pass
struct
MIGRAPHX_EXPORT
capture_arguments_pass
{
std
::
vector
<
std
::
string
>
ins_names
=
{
"dot"
,
"convolution"
};
std
::
function
<
void
(
std
::
size_t
,
std
::
vector
<
argument
>
)
>
f
{};
...
...
@@ -51,7 +51,7 @@ struct capture_arguments_pass
/**
* quantize a program to int8
*/
struct
quantize_int8_pass
struct
MIGRAPHX_EXPORT
quantize_int8_pass
{
std
::
vector
<
std
::
string
>
ins_names
=
{
"dot"
,
"convolution"
};
std
::
vector
<
std
::
pair
<
float
,
float
>>
quant_params
;
...
...
src/include/migraphx/raw_data.hpp
View file @
40fbef9b
...
...
@@ -187,6 +187,7 @@ struct raw_data : raw_data_base
std
::
string
to_string
()
const
{
std
::
stringstream
ss
;
ss
.
precision
(
std
::
numeric_limits
<
double
>::
max_digits10
);
ss
<<
static_cast
<
const
Derived
&>
(
*
this
);
return
ss
.
str
();
}
...
...
src/include/migraphx/reduce_dims.hpp
View file @
40fbef9b
...
...
@@ -31,7 +31,7 @@
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
std
::
vector
<
shape
>
reduce_dims
(
const
std
::
vector
<
shape
>&
shapes
);
MIGRAPHX_EXPORT
std
::
vector
<
shape
>
reduce_dims
(
const
std
::
vector
<
shape
>&
shapes
);
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/reflect.hpp
View file @
40fbef9b
...
...
@@ -78,7 +78,7 @@ template <class T>
struct
wrapper
{
using
type
=
typename
remove_rvalue_reference
<
T
>::
type
;
type
data
;
type
data
;
// NOLINT
type
get
()
const
{
return
data
;
}
};
...
...
src/include/migraphx/register_op.hpp
View file @
40fbef9b
...
...
@@ -34,7 +34,7 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
// unregister all ops for specified target, useful when unloading dynamically plugged-in target lib
void
unregister_op
(
const
std
::
string
&
op_name
);
MIGRAPHX_EXPORT
void
unregister_op
(
const
std
::
string
&
op_name
);
namespace
detail
{
struct
op_handler
...
...
@@ -47,15 +47,15 @@ struct op_handler
}
// namespace detail
void
register_op_init
();
MIGRAPHX_EXPORT
void
register_op_init
();
void
register_op
(
const
operation
&
op
);
MIGRAPHX_EXPORT
void
register_op
(
const
operation
&
op
);
operation
load_op
(
const
std
::
string
&
name
);
MIGRAPHX_EXPORT
operation
load_op
(
const
std
::
string
&
name
);
bool
has_op
(
const
std
::
string
&
name
);
MIGRAPHX_EXPORT
bool
has_op
(
const
std
::
string
&
name
);
std
::
vector
<
std
::
string
>
get_operators
();
MIGRAPHX_EXPORT
std
::
vector
<
std
::
string
>
get_operators
();
template
<
class
T
>
void
register_op
()
...
...
src/include/migraphx/register_target.hpp
View file @
40fbef9b
...
...
@@ -33,11 +33,11 @@
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
void
register_target_init
();
void
register_target
(
const
target
&
t
);
void
unregister_target
(
const
std
::
string
&
name
);
target
make_target
(
const
std
::
string
&
name
);
std
::
vector
<
std
::
string
>
get_targets
();
MIGRAPHX_EXPORT
void
register_target_init
();
MIGRAPHX_EXPORT
void
register_target
(
const
target
&
t
);
MIGRAPHX_EXPORT
void
unregister_target
(
const
std
::
string
&
name
);
MIGRAPHX_EXPORT
target
make_target
(
const
std
::
string
&
name
);
MIGRAPHX_EXPORT
std
::
vector
<
std
::
string
>
get_targets
();
namespace
detail
{
struct
target_handler
...
...
src/include/migraphx/replace_allocate.hpp
View file @
40fbef9b
...
...
@@ -30,17 +30,17 @@
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
struct
module
;
struct
module
_pass_manager
;
/**
* Replace `allocate` instructions with target allocations or output parameters.
*/
struct
replace_allocate
struct
MIGRAPHX_EXPORT
replace_allocate
{
allocation_model
model
;
bool
offload_copy
=
false
;
std
::
string
name
()
const
{
return
"replace_allocate"
;
}
void
apply
(
module
&
m
)
const
;
void
apply
(
module
_pass_manager
&
mp
m
)
const
;
};
}
// namespace MIGRAPHX_INLINE_NS
...
...
src/include/migraphx/rewrite_gelu.hpp
View file @
40fbef9b
...
...
@@ -36,7 +36,7 @@ struct module;
/**
* Rewrite gelu standard formula as the sigmoid approximation formula
*/
struct
rewrite_gelu
struct
MIGRAPHX_EXPORT
rewrite_gelu
{
std
::
string
name
()
const
{
return
"rewrite_gelu"
;
}
void
apply
(
module
&
m
)
const
;
...
...
Prev
1
…
4
5
6
7
8
9
10
11
12
…
22
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