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
b3813f86
Commit
b3813f86
authored
Jul 06, 2023
by
Khalique Ahmed
Browse files
update pass to remove old parms
parent
f0f9120a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
19 deletions
+9
-19
src/quantize_fp16.cpp
src/quantize_fp16.cpp
+7
-17
src/targets/gpu/kernels/include/migraphx/kernels/math.hpp
src/targets/gpu/kernels/include/migraphx/kernels/math.hpp
+2
-2
No files found.
src/quantize_fp16.cpp
View file @
b3813f86
...
@@ -78,41 +78,31 @@ static void quantize_module(module& m, const std::vector<std::string>& ins_names
...
@@ -78,41 +78,31 @@ static void quantize_module(module& m, const std::vector<std::string>& ins_names
// Replace original instruction
// Replace original instruction
m
.
replace_instruction
(
ins
,
converted_ins
);
m
.
replace_instruction
(
ins
,
converted_ins
);
}
}
// m.debug_print();
// std::cout << "HERE" << std::endl;
}
}
static
void
quantize_params
(
module
&
m
)
static
void
quantize_params
(
module
&
m
)
{
{
std
::
vector
<
std
::
string
>
param_names
=
m
.
get_parameter_names
();
std
::
vector
<
std
::
string
>
param_names
=
m
.
get_parameter_names
();
std
::
unordered_set
<
std
::
string
>
processed_params
;
for
(
auto
param_name
:
param_names
)
for
(
auto
param_name
:
param_names
)
{
{
auto
param
=
m
.
get_parameter
(
param_name
);
auto
param
=
m
.
get_parameter
(
param_name
);
// m.debug_print(param);
auto
param_shape
=
param
->
get_shape
();
if
(
not
contains
(
processed_params
,
param_name
)
and
if
(
param_shape
.
type
()
==
shape
::
float_type
)
param
->
get_shape
().
type
()
==
shape
::
float_type
)
{
{
auto
new_param
=
m
.
add_parameter
(
auto
new_param
=
m
.
add_parameter
(
param_name
,
migraphx
::
shape
{
shape
::
half_type
,
param
->
get_shape
().
lens
()});
param_name
,
migraphx
::
shape
{
shape
::
half_type
,
param_shape
.
lens
()});
// m.debug_print(new_param);
// m.debug_print();
// m.debug_print();
m
.
replace_instruction
(
param
,
new_param
);
m
.
replace_instruction
(
param
,
new_param
);
// std::cout << "HERE" << std::endl
;
m
.
remove_instruction
(
param
)
;
}
}
processed_params
.
insert
(
param_name
);
}
}
}
}
void
quantize_fp16_pass
::
apply
(
module_pass_manager
&
mpm
)
const
void
quantize_fp16_pass
::
apply
(
module_pass_manager
&
mpm
)
const
{
{
module
m
=
mpm
.
get_module
();
module
&
m
=
mpm
.
get_module
();
quantize_module
(
m
,
ins_names
);
quantize_module
(
m
,
ins_names
);
// mpm.run_pass(dead_code_elimination{});
mpm
.
run_pass
(
dead_code_elimination
{});
// m.debug_print();
quantize_params
(
m
);
// quantize_params(m);
}
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace MIGRAPHX_INLINE_NS
...
...
src/targets/gpu/kernels/include/migraphx/kernels/math.hpp
View file @
b3813f86
...
@@ -188,8 +188,8 @@ MIGRAPHX_DEVICE_MATH_BINARY_FOR(float, max, ::max)
...
@@ -188,8 +188,8 @@ MIGRAPHX_DEVICE_MATH_BINARY_FOR(float, max, ::max)
MIGRAPHX_DEVICE_MATH_BINARY_FOR
(
float
,
min
,
::
min
)
MIGRAPHX_DEVICE_MATH_BINARY_FOR
(
float
,
min
,
::
min
)
MIGRAPHX_DEVICE_MATH_BINARY_FOR
(
double
,
max
,
::
max
)
MIGRAPHX_DEVICE_MATH_BINARY_FOR
(
double
,
max
,
::
max
)
MIGRAPHX_DEVICE_MATH_BINARY_FOR
(
double
,
min
,
::
min
)
MIGRAPHX_DEVICE_MATH_BINARY_FOR
(
double
,
min
,
::
min
)
MIGRAPHX_DEVICE_MATH_BINARY_FOR
(
migraphx
::
half
,
max
,
::
__h
max
)
MIGRAPHX_DEVICE_MATH_BINARY_FOR
(
migraphx
::
half
,
max
,
::
f
max
f
)
MIGRAPHX_DEVICE_MATH_BINARY_FOR
(
migraphx
::
half
,
min
,
::
__h
min
)
MIGRAPHX_DEVICE_MATH_BINARY_FOR
(
migraphx
::
half
,
min
,
::
f
min
f
)
template
<
class
T
,
MIGRAPHX_REQUIRES
(
not
is_any_vec
<
T
>())
>
template
<
class
T
,
MIGRAPHX_REQUIRES
(
not
is_any_vec
<
T
>())
>
constexpr
auto
max
(
const
T
&
a
,
const
T
&
b
)
constexpr
auto
max
(
const
T
&
a
,
const
T
&
b
)
...
...
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