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
af7e6eaa
Unverified
Commit
af7e6eaa
authored
Nov 17, 2022
by
Ted Themistokleous
Committed by
GitHub
Nov 17, 2022
Browse files
Fix logical_xor type checking (#1458)
Fix to stop types failing for logical_xor during our fusions.
parent
95d82a51
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
src/fuse_pointwise.cpp
src/fuse_pointwise.cpp
+10
-1
test/fuse_pointwise.cpp
test/fuse_pointwise.cpp
+29
-0
No files found.
src/fuse_pointwise.cpp
View file @
af7e6eaa
...
@@ -45,7 +45,16 @@ static literal get_scalar(instruction_ref ins)
...
@@ -45,7 +45,16 @@ static literal get_scalar(instruction_ref ins)
return
{};
return
{};
auto
e
=
ins
->
eval
();
auto
e
=
ins
->
eval
();
literal
r
{};
literal
r
{};
// needed for bool as visit_at invokes as() which promotes bool to int8
// Without this we'll break type checks for logical ops that are fused.
if
(
e
.
get_shape
().
type
()
==
shape
::
bool_type
)
{
r
=
literal
{
e
.
at
<
bool
>
()};
}
else
{
e
.
visit_at
([
&
](
auto
x
)
{
r
=
literal
{
x
};
});
e
.
visit_at
([
&
](
auto
x
)
{
r
=
literal
{
x
};
});
}
return
r
;
return
r
;
}
}
...
...
test/fuse_pointwise.cpp
View file @
af7e6eaa
...
@@ -272,6 +272,35 @@ TEST_CASE(contiguous_input)
...
@@ -272,6 +272,35 @@ TEST_CASE(contiguous_input)
EXPECT
(
p1
==
p2
);
EXPECT
(
p1
==
p2
);
}
}
TEST_CASE
(
contiguous_boolean_input
)
{
migraphx
::
shape
s
{
migraphx
::
shape
::
bool_type
,
{
2
,
3
}};
migraphx
::
shape
s_lit
{
migraphx
::
shape
::
bool_type
,
{
1
},
{
0
}};
migraphx
::
program
p1
;
{
auto
*
mm
=
p1
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
one
=
mm
->
add_literal
(
migraphx
::
literal
(
s_lit
,
{
1.0
}));
auto
yb
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
s
.
lens
()}}),
one
);
auto
y
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
yb
);
auto
xor1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"logical_xor"
),
x
,
y
);
mm
->
add_return
({
xor1
});
}
run_pass
(
p1
);
migraphx
::
program
p2
;
{
auto
*
mm
=
p2
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
xor1
=
add_pointwise
(
p2
,
"main:pointwise0"
,
{
x
},
[
=
](
auto
*
pm
,
const
auto
&
inputs
)
{
auto
y
=
pm
->
add_literal
(
migraphx
::
literal
(
s_lit
,
{
1
}));
return
pm
->
add_instruction
(
migraphx
::
make_op
(
"logical_xor"
),
inputs
[
0
],
y
);
});
mm
->
add_return
({
xor1
});
}
}
TEST_CASE
(
all_scalar_input
)
TEST_CASE
(
all_scalar_input
)
{
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
};
...
...
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