Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
c8712215
Commit
c8712215
authored
Apr 19, 2019
by
Shucai Xiao
Browse files
clang format
parent
ad774473
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
17 deletions
+16
-17
test/gpu/adjust_allocation.cpp
test/gpu/adjust_allocation.cpp
+14
-15
test/gpu/miopen.cpp
test/gpu/miopen.cpp
+2
-2
No files found.
test/gpu/adjust_allocation.cpp
View file @
c8712215
...
@@ -16,20 +16,18 @@ struct lowering_target
...
@@ -16,20 +16,18 @@ struct lowering_target
std
::
string
name
()
const
{
return
"gpu::lowering"
;
}
std
::
string
name
()
const
{
return
"gpu::lowering"
;
}
std
::
vector
<
migraphx
::
pass
>
get_passes
(
migraphx
::
context
&
gctx
)
const
std
::
vector
<
migraphx
::
pass
>
get_passes
(
migraphx
::
context
&
gctx
)
const
{
{
auto
&
ctx
=
migraphx
::
any_cast
<
migraphx
::
gpu
::
context
>
(
gctx
);
auto
&
ctx
=
migraphx
::
any_cast
<
migraphx
::
gpu
::
context
>
(
gctx
);
return
{
migraphx
::
gpu
::
lowering
{
ctx
},
migraphx
::
dead_code_elimination
{}};
return
{
migraphx
::
gpu
::
lowering
{
ctx
},
migraphx
::
dead_code_elimination
{}};
}
}
migraphx
::
gpu
::
context
get_context
()
const
{
return
migraphx
::
gpu
::
context
{};
}
migraphx
::
gpu
::
context
get_context
()
const
{
return
migraphx
::
gpu
::
context
{};
}
};
};
TEST_CASE
(
trans_tanh
)
TEST_CASE
(
trans_tanh
)
{
{
auto
create_program
=
[]{
auto
create_program
=
[]
{
migraphx
::
program
p
;
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
sm
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
x
);
auto
sm
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
x
);
p
.
add_instruction
(
migraphx
::
op
::
tanh
{},
sm
);
p
.
add_instruction
(
migraphx
::
op
::
tanh
{},
sm
);
...
@@ -40,17 +38,17 @@ TEST_CASE(trans_tanh)
...
@@ -40,17 +38,17 @@ TEST_CASE(trans_tanh)
auto
p2
=
create_program
();
auto
p2
=
create_program
();
EXPECT
(
p1
==
p2
);
EXPECT
(
p1
==
p2
);
// relace the add instruction with using a incorrect
// relace the add instruction with using a incorrect
// output shape
// output shape
for
(
auto
ins
:
iterator_for
(
p1
))
for
(
auto
ins
:
iterator_for
(
p1
))
{
{
if
(
ins
->
name
()
==
"add"
)
if
(
ins
->
name
()
==
"add"
)
{
{
migraphx
::
shape
wrong_s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
}};
migraphx
::
shape
wrong_s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
}};
migraphx
::
instruction
::
replace
(
ins
,
ins
->
get_operator
(),
wrong_s
,
ins
->
inputs
());
migraphx
::
instruction
::
replace
(
ins
,
ins
->
get_operator
(),
wrong_s
,
ins
->
inputs
());
}
}
if
(
ins
->
name
()
==
"tanh"
)
if
(
ins
->
name
()
==
"tanh"
)
{
{
migraphx
::
shape
orig_s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
migraphx
::
shape
orig_s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
migraphx
::
instruction
::
replace
(
ins
,
ins
->
get_operator
(),
orig_s
,
ins
->
inputs
());
migraphx
::
instruction
::
replace
(
ins
,
ins
->
get_operator
(),
orig_s
,
ins
->
inputs
());
...
@@ -58,13 +56,13 @@ TEST_CASE(trans_tanh)
...
@@ -58,13 +56,13 @@ TEST_CASE(trans_tanh)
}
}
EXPECT
(
p1
!=
p2
);
EXPECT
(
p1
!=
p2
);
p1
.
compile
(
lowering_target
{});
p1
.
compile
(
lowering_target
{});
p2
.
compile
(
lowering_target
{});
p2
.
compile
(
lowering_target
{});
EXPECT
(
p1
!=
p2
);
EXPECT
(
p1
!=
p2
);
for
(
auto
ins
:
iterator_for
(
p1
))
for
(
auto
ins
:
iterator_for
(
p1
))
{
{
if
(
ins
->
name
()
==
"gpu::add"
)
if
(
ins
->
name
()
==
"gpu::add"
)
{
{
migraphx
::
shape
correct_s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
migraphx
::
shape
correct_s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
migraphx
::
instruction
::
replace
(
ins
,
ins
->
get_operator
(),
correct_s
,
ins
->
inputs
());
migraphx
::
instruction
::
replace
(
ins
,
ins
->
get_operator
(),
correct_s
,
ins
->
inputs
());
...
@@ -72,7 +70,8 @@ TEST_CASE(trans_tanh)
...
@@ -72,7 +70,8 @@ TEST_CASE(trans_tanh)
}
}
EXPECT
(
p1
!=
p2
);
EXPECT
(
p1
!=
p2
);
migraphx
::
run_passes
(
p1
,
{
migraphx
::
gpu
::
adjust_allocation
{},
migraphx
::
dead_code_elimination
{}});
migraphx
::
run_passes
(
p1
,
{
migraphx
::
gpu
::
adjust_allocation
{},
migraphx
::
dead_code_elimination
{}});
EXPECT
(
p1
==
p2
);
EXPECT
(
p1
==
p2
);
}
}
...
...
test/gpu/miopen.cpp
View file @
c8712215
...
@@ -332,7 +332,7 @@ struct test_trans_tanh : verify_program<test_trans_tanh>
...
@@ -332,7 +332,7 @@ struct test_trans_tanh : verify_program<test_trans_tanh>
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
x
=
p
.
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}});
auto
x
=
p
.
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}});
auto
tx
=
p
.
add_instruction
(
migraphx
::
op
::
transpose
{{
0
,
1
,
3
,
2
}},
x
);
auto
tx
=
p
.
add_instruction
(
migraphx
::
op
::
transpose
{{
0
,
1
,
3
,
2
}},
x
);
auto
tanhx
=
p
.
add_instruction
(
migraphx
::
op
::
tanh
{},
tx
);
auto
tanhx
=
p
.
add_instruction
(
migraphx
::
op
::
tanh
{},
tx
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
tanhx
,
tanhx
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
tanhx
,
tanhx
);
...
@@ -692,7 +692,7 @@ struct test_trans_abs : verify_program<test_trans_abs>
...
@@ -692,7 +692,7 @@ struct test_trans_abs : verify_program<test_trans_abs>
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
x
=
p
.
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}});
auto
x
=
p
.
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}});
auto
tx
=
p
.
add_instruction
(
migraphx
::
op
::
transpose
{{
0
,
1
,
3
,
2
}},
x
);
auto
tx
=
p
.
add_instruction
(
migraphx
::
op
::
transpose
{{
0
,
1
,
3
,
2
}},
x
);
auto
tanhx
=
p
.
add_instruction
(
migraphx
::
op
::
abs
{},
tx
);
auto
tanhx
=
p
.
add_instruction
(
migraphx
::
op
::
abs
{},
tx
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
tanhx
,
tanhx
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
tanhx
,
tanhx
);
...
...
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