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
19ef6b6d
"git@developer.sourcefind.cn:gaoqiong/migraphx.git" did not exist on "9b5e0c18b468b603f35b4b4160e99fb9e88742df"
Commit
19ef6b6d
authored
Apr 23, 2019
by
Shucai Xiao
Browse files
add one more test for the adjust allocation pass
parent
2a3042b1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
test/gpu/adjust_allocation.cpp
test/gpu/adjust_allocation.cpp
+71
-0
No files found.
test/gpu/adjust_allocation.cpp
0 → 100644
View file @
19ef6b6d
#include <migraphx/gpu/adjust_allocation.hpp>
#include <migraphx/gpu/target.hpp>
#include <migraphx/gpu/lowering.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/auto_contiguous.hpp>
#include <migraphx/eliminate_contiguous.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/op/add.hpp>
#include <migraphx/op/transpose.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/pass_manager.hpp>
#include <migraphx/op/tanh.hpp>
#include <basic_ops.hpp>
#include <test.hpp>
struct
lowering_target
{
std
::
string
name
()
const
{
return
"gpu::lowering"
;
}
std
::
vector
<
migraphx
::
pass
>
get_passes
(
migraphx
::
context
&
gctx
)
const
{
auto
&
ctx
=
migraphx
::
any_cast
<
migraphx
::
gpu
::
context
>
(
gctx
);
return
{
migraphx
::
auto_contiguous
{},
migraphx
::
gpu
::
lowering
{
ctx
},
migraphx
::
dead_code_elimination
{},
migraphx
::
eliminate_contiguous
{},
migraphx
::
dead_code_elimination
{}};
}
migraphx
::
gpu
::
context
get_context
()
const
{
return
migraphx
::
gpu
::
context
{};
}
};
TEST_CASE
(
trans_tanh
)
{
auto
create_program
=
[]
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
txh
=
p
.
add_instruction
(
migraphx
::
op
::
tanh
{},
x
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
txh
,
txh
);
return
p
;
};
auto
p1
=
create_program
();
auto
p2
=
create_program
();
EXPECT
(
p1
==
p2
);
std
::
cout
<<
"p1 = "
<<
p1
<<
std
::
endl
;
std
::
cout
<<
"p2 = "
<<
p2
<<
std
::
endl
;
p1
.
compile
(
lowering_target
{});
p2
.
compile
(
lowering_target
{});
EXPECT
(
p1
==
p2
);
for
(
auto
ins
:
iterator_for
(
p1
))
{
if
(
ins
->
name
()
==
"hip::allocate"
)
{
migraphx
::
shape
wrong_s
{
migraphx
::
shape
::
float_type
,
{
4
,
3
}};
ins
->
replace
(
wrong_s
);
}
}
EXPECT
(
p1
!=
p2
);
std
::
cout
<<
"p1 = "
<<
p1
<<
std
::
endl
;
std
::
cout
<<
"p2 = "
<<
p2
<<
std
::
endl
;
migraphx
::
run_passes
(
p1
,
{
migraphx
::
gpu
::
adjust_allocation
{},
migraphx
::
dead_code_elimination
{}});
EXPECT
(
p1
==
p2
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
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