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
9e2946a4
"test/git@developer.sourcefind.cn:gaoqiong/migraphx.git" did not exist on "12beb62250916daa07ca99912c26daedc8376652"
Commit
9e2946a4
authored
Dec 05, 2023
by
Umang Yadav
Browse files
use eliminate_data_type to avoid lossy downcast
parent
39bf5dc5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
15 deletions
+60
-15
src/eliminate_data_type.cpp
src/eliminate_data_type.cpp
+16
-0
src/targets/ref/include/migraphx/ref/convert_quant_ops.hpp
src/targets/ref/include/migraphx/ref/convert_quant_ops.hpp
+29
-0
src/targets/ref/target.cpp
src/targets/ref/target.cpp
+14
-11
test/verify/main.cpp
test/verify/main.cpp
+1
-4
No files found.
src/eliminate_data_type.cpp
View file @
9e2946a4
...
@@ -120,6 +120,22 @@ void eliminate_data_type::apply(module& m) const
...
@@ -120,6 +120,22 @@ void eliminate_data_type::apply(module& m) const
if
(
contains
(
unsupported_ops
,
"all"
)
or
contains
(
unsupported_ops
,
ins
->
name
()))
if
(
contains
(
unsupported_ops
,
"all"
)
or
contains
(
unsupported_ops
,
ins
->
name
()))
insert_convert_to_supported_type
(
m
,
ins
,
target_type
,
unsupported_types
);
insert_convert_to_supported_type
(
m
,
ins
,
target_type
,
unsupported_types
);
}
}
// remove nested converts
for
(
auto
ins
:
iterator_for
(
m
))
{
if
(
ins
->
name
()
==
"convert"
)
{
auto
convert_input
=
ins
->
inputs
().
front
();
while
(
convert_input
->
name
()
==
"convert"
)
{
convert_input
=
convert_input
->
inputs
().
front
();
}
if
(
convert_input
->
get_shape
()
==
ins
->
get_shape
())
{
m
.
replace_instruction
(
ins
,
convert_input
);
}
}
}
}
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace MIGRAPHX_INLINE_NS
...
...
src/targets/ref/include/migraphx/ref/convert_quant_ops.hpp
0 → 100644
View file @
9e2946a4
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <migraphx/eliminate_data_type.hpp>
#include <migraphx/module.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/ranges.hpp>
src/targets/ref/target.cpp
View file @
9e2946a4
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include <migraphx/ref/target.hpp>
#include <migraphx/ref/target.hpp>
#include <migraphx/ref/lowering.hpp>
#include <migraphx/ref/lowering.hpp>
#include <migraphx/eliminate_data_type.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/pass.hpp>
#include <migraphx/pass.hpp>
#include <migraphx/auto_contiguous.hpp>
#include <migraphx/auto_contiguous.hpp>
...
@@ -42,17 +43,19 @@ std::string target::name() const { return "ref"; }
...
@@ -42,17 +43,19 @@ std::string target::name() const { return "ref"; }
std
::
vector
<
pass
>
target
::
get_passes
(
migraphx
::
context
&
,
const
compile_options
&
)
const
std
::
vector
<
pass
>
target
::
get_passes
(
migraphx
::
context
&
,
const
compile_options
&
)
const
{
{
return
{
normalize_ops
{},
return
{
eliminate_pad
{},
normalize_ops
{},
dead_code_elimination
{},
eliminate_pad
{},
insert_pad
{},
dead_code_elimination
{},
dead_code_elimination
{},
eliminate_data_type
{{
migraphx
::
shape
::
fp8e4m3fnuz_type
},
shape
::
float_type
,
{
"quant_dot"
}},
rewrite_rnn
{},
insert_pad
{},
dead_code_elimination
{},
dead_code_elimination
{},
auto_contiguous
{},
rewrite_rnn
{},
dead_code_elimination
{},
dead_code_elimination
{},
lowering
{},
auto_contiguous
{},
dead_code_elimination
{}};
dead_code_elimination
{},
lowering
{},
dead_code_elimination
{}};
}
}
argument
target
::
allocate
(
const
shape
&
s
)
const
{
return
fill_argument
(
s
,
0
);
}
argument
target
::
allocate
(
const
shape
&
s
)
const
{
return
fill_argument
(
s
,
0
);
}
...
...
test/verify/main.cpp
View file @
9e2946a4
...
@@ -76,10 +76,7 @@ int main(int argc, const char* argv[])
...
@@ -76,10 +76,7 @@ int main(int argc, const char* argv[])
"test_select_module_conv"
,
"test_select_module_conv"
,
"test_split_single_dyn_dim"
,
"test_split_single_dyn_dim"
,
"test_instancenorm_large_3d<migraphx::shape::float_type>"
,
"test_instancenorm_large_3d<migraphx::shape::float_type>"
,
"test_instancenorm_large_3d<migraphx::shape::half_type>"
,
"test_instancenorm_large_3d<migraphx::shape::half_type>"
});
"batch_quant_dot_1<migraphx::fp8::fp8e4m3fnuz, float>"
,
"quant_dot_3args_4<migraphx::fp8::fp8e4m3fnuz, float>"
,
"quant_dot_3args_5<migraphx::fp8::fp8e4m3fnuz, float>"
});
rv
.
disable_test_for
(
"gpu"
,
{
"test_conv_bn_add"
});
rv
.
disable_test_for
(
"gpu"
,
{
"test_conv_bn_add"
});
rv
.
run
(
argc
,
argv
);
rv
.
run
(
argc
,
argv
);
...
...
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