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
938792b0
"vscode:/vscode.git/clone" did not exist on "3c4cc60277951581562508215c6be96edad69fb5"
Commit
938792b0
authored
Jul 19, 2022
by
Ted Themistokleous
Browse files
Initial working commit of tested compile trap of detected divzero instructions
parent
f919cb7e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
30 deletions
+66
-30
src/include/migraphx/module.hpp
src/include/migraphx/module.hpp
+1
-1
src/include/migraphx/op/divzero.hpp
src/include/migraphx/op/divzero.hpp
+57
-0
src/module.cpp
src/module.cpp
+5
-26
src/program.cpp
src/program.cpp
+1
-3
src/targets/ref/lowering.cpp
src/targets/ref/lowering.cpp
+2
-0
No files found.
src/include/migraphx/module.hpp
View file @
938792b0
...
@@ -182,7 +182,7 @@ struct module
...
@@ -182,7 +182,7 @@ struct module
instruction_ref
validate
()
const
;
instruction_ref
validate
()
const
;
instruction_ref
find_dangling_reference
()
const
;
instruction_ref
find_dangling_reference
()
const
;
instruction_ref
f
ind
_division_by_zero
()
const
;
instruction_ref
f
lag
_division_by_zero
()
const
;
void
finalize
(
context
&
ctx
);
void
finalize
(
context
&
ctx
);
...
...
src/include/migraphx/op/divzero.hpp
0 → 100644
View file @
938792b0
/*
* 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.
*/
#ifndef MIGRAPHX_GUARD_OPERATORS_MUL_HPP
#define MIGRAPHX_GUARD_OPERATORS_MUL_HPP
#include <array>
#include <migraphx/op/binary.hpp>
#include <migraphx/check_shapes.hpp>
#include <migraphx/stringutils.hpp>
#include <migraphx/streamutils.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/shape_for_each.hpp>
#include <migraphx/config.hpp>
#include <cmath>
#include <utility>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
divzero
:
binary
<
divzero
>
{
std
::
string
name
()
const
{
return
"divzero"
;
}
std
::
string
point_function
()
const
{
return
"divzero"
;
}
auto
apply
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
0
*
x
*
y
;
};
}
};
}
// namespace op
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/module.cpp
View file @
938792b0
...
@@ -628,35 +628,14 @@ instruction_ref module::find_dangling_reference() const
...
@@ -628,35 +628,14 @@ instruction_ref module::find_dangling_reference() const
return
end
();
return
end
();
}
}
bool
is_div_zero
(
instruction_ref
ins
)
instruction_ref
module
::
flag_division_by_zero
()
const
{
{
const
auto
&
op
=
instruction
::
get_output_alias
(
ins
)
->
get_operator
();
std
::
cout
<<
op
.
name
()
<<
std
::
endl
;
return
op
.
name
().
find
(
"divzero"
)
!=
std
::
string
::
npos
;
}
instruction_ref
module
::
find_division_by_zero
()
const
{
std
::
cout
<<
"start search"
<<
std
::
endl
;
auto
last
=
std
::
prev
(
end
());
auto
last
=
std
::
prev
(
end
());
if
(
last
->
name
()
==
"divzero"
)
auto
ins
=
end
();
{
if
(
last
->
name
()
==
"divzero"
)
{
std
::
cout
<<
"search"
<<
std
::
endl
;
ins
=
begin
();
auto
div_zero
=
std
::
find_if
(
last
->
inputs
().
begin
(),
last
->
inputs
().
end
(),
[](
auto
x
)
{
return
is_div_zero
(
x
);
});
if
(
div_zero
!=
last
->
inputs
().
end
())
{
std
::
cout
<<
"found divzero"
<<
std
::
endl
;
return
*
div_zero
;
}
}
else
if
(
is_div_zero
(
last
))
{
std
::
cout
<<
"check last ref"
<<
std
::
endl
;
return
last
;
}
}
std
::
cout
<<
"End ref"
<<
std
::
endl
;
return
ins
;
return
end
();
}
}
void
module
::
finalize
(
context
&
ctx
)
void
module
::
finalize
(
context
&
ctx
)
...
...
src/program.cpp
View file @
938792b0
...
@@ -195,9 +195,7 @@ void program::compile(const target& t, compile_options options)
...
@@ -195,9 +195,7 @@ void program::compile(const target& t, compile_options options)
std
::
to_string
(
index
));
std
::
to_string
(
index
));
}
}
std
::
cout
<<
"find div by zero"
<<
std
::
endl
;
auto
divide_by_zero
=
mod
->
flag_division_by_zero
();
std
::
cout
<<
*
mod
<<
std
::
endl
;
auto
divide_by_zero
=
mod
->
find_division_by_zero
();
if
(
divide_by_zero
!=
mod
->
end
())
if
(
divide_by_zero
!=
mod
->
end
())
{
{
auto
index
=
std
::
distance
(
mod
->
begin
(),
divide_by_zero
);
auto
index
=
std
::
distance
(
mod
->
begin
(),
divide_by_zero
);
...
...
src/targets/ref/lowering.cpp
View file @
938792b0
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
#include <migraphx/op/argmax.hpp>
#include <migraphx/op/argmax.hpp>
#include <migraphx/op/argmin.hpp>
#include <migraphx/op/argmin.hpp>
#include <migraphx/op/rnn_var_sl_last_output.hpp>
#include <migraphx/op/rnn_var_sl_last_output.hpp>
#include <migraphx/op/divzero.hpp>
#include <migraphx/shape_for_each.hpp>
#include <migraphx/shape_for_each.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/par_dfor.hpp>
#include <migraphx/par_dfor.hpp>
...
@@ -695,6 +696,7 @@ struct ref_apply
...
@@ -695,6 +696,7 @@ struct ref_apply
apply_map
[
"softmax"
]
=
extend_op
<
ref_softmax
<
op
::
softmax
>
,
op
::
softmax
>
();
apply_map
[
"softmax"
]
=
extend_op
<
ref_softmax
<
op
::
softmax
>
,
op
::
softmax
>
();
apply_map
[
"rnn_var_sl_last_output"
]
=
apply_map
[
"rnn_var_sl_last_output"
]
=
extend_op
<
ref_rnn_var_sl_last_output
,
op
::
rnn_var_sl_last_output
>
();
extend_op
<
ref_rnn_var_sl_last_output
,
op
::
rnn_var_sl_last_output
>
();
apply_map
[
"divzero"
]
=
simple_op
<
op
::
divzero
>
();
}
}
void
apply
()
void
apply
()
...
...
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