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
8143e4fb
Commit
8143e4fb
authored
Nov 05, 2018
by
wsttiger
Browse files
Merge branch 'master' into remove_concat
parents
0a4583b7
9ca0fbf1
Changes
71
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
337 additions
and
60 deletions
+337
-60
src/targets/gpu/target.cpp
src/targets/gpu/target.cpp
+1
-5
test/CMakeLists.txt
test/CMakeLists.txt
+5
-2
test/cpu_ops_test.cpp
test/cpu_ops_test.cpp
+131
-41
test/dead_code_elimination_test.cpp
test/dead_code_elimination_test.cpp
+17
-0
test/fwd_conv_batchnorm_rewrite_test.cpp
test/fwd_conv_batchnorm_rewrite_test.cpp
+3
-3
test/gpu/miopen.cpp
test/gpu/miopen.cpp
+100
-8
test/onnx/globalavgpool_test.onnx
test/onnx/globalavgpool_test.onnx
+15
-0
test/onnx/globalmaxpool_test.onnx
test/onnx/globalmaxpool_test.onnx
+15
-0
test/onnx/imagescaler_test.onnx
test/onnx/imagescaler_test.onnx
+0
-0
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+49
-0
test/op_shape_test.cpp
test/op_shape_test.cpp
+1
-1
No files found.
src/targets/gpu/target.cpp
View file @
8143e4fb
...
@@ -58,10 +58,6 @@ std::vector<pass> target::get_passes(migraph::context& gctx) const
...
@@ -58,10 +58,6 @@ std::vector<pass> target::get_passes(migraph::context& gctx) const
std
::
string
target
::
name
()
const
{
return
"miopen"
;
}
std
::
string
target
::
name
()
const
{
return
"miopen"
;
}
migraph
::
context
target
::
get_context
()
const
migraph
::
context
target
::
get_context
()
const
{
return
context
{};
}
{
return
context
{
share
(
make_obj
<
miopen_handle
>
(
&
miopenCreate
)),
share
(
create_rocblas_handle_ptr
()),
{}};
}
}
// namespace gpu
}
// namespace gpu
}
// namespace migraph
}
// namespace migraph
test/CMakeLists.txt
View file @
8143e4fb
...
@@ -7,7 +7,7 @@ find_package(Threads REQUIRED)
...
@@ -7,7 +7,7 @@ find_package(Threads REQUIRED)
include
(
ProcessorCount
)
include
(
ProcessorCount
)
ProcessorCount
(
N
)
ProcessorCount
(
N
)
set
(
CTEST_PARALLEL_LEVEL
${
N
}
CACHE STRING
"CTest parallel level"
)
set
(
CTEST_PARALLEL_LEVEL
${
N
}
CACHE STRING
"CTest parallel level"
)
add_custom_target
(
check COMMAND
${
CMAKE_CTEST_COMMAND
}
--output-on-failure -j
${
CTEST_PARALLEL_LEVEL
}
-C
${
CMAKE_CFG_INTDIR
}
)
add_custom_target
(
check COMMAND
${
CMAKE_CTEST_COMMAND
}
--output-on-failure -j
${
CTEST_PARALLEL_LEVEL
}
-C
${
CMAKE_CFG_INTDIR
}
--timeout 1500
)
add_custom_target
(
tests
)
add_custom_target
(
tests
)
find_program
(
MIGRAPH_GDB gdb
)
find_program
(
MIGRAPH_GDB gdb
)
...
@@ -103,7 +103,10 @@ if(MIGRAPH_ENABLE_GPU)
...
@@ -103,7 +103,10 @@ if(MIGRAPH_ENABLE_GPU)
get_filename_component
(
BASE_NAME
${
TEST
}
NAME_WE
)
get_filename_component
(
BASE_NAME
${
TEST
}
NAME_WE
)
add_test_executable
(
test_gpu_
${
BASE_NAME
}
${
TEST
}
)
add_test_executable
(
test_gpu_
${
BASE_NAME
}
${
TEST
}
)
rocm_clang_tidy_check
(
test_gpu_
${
BASE_NAME
}
)
rocm_clang_tidy_check
(
test_gpu_
${
BASE_NAME
}
)
set_tests_properties
(
test_gpu_
${
BASE_NAME
}
PROPERTIES COST 10
)
set_tests_properties
(
test_gpu_
${
BASE_NAME
}
PROPERTIES
COST 10
RESOURCE_LOCK gpu
)
target_link_libraries
(
test_gpu_
${
BASE_NAME
}
migraph_gpu
)
target_link_libraries
(
test_gpu_
${
BASE_NAME
}
migraph_gpu
)
endforeach
()
endforeach
()
endif
()
endif
()
...
...
test/cpu_ops_test.cpp
View file @
8143e4fb
This diff is collapsed.
Click to expand it.
test/dead_code_elimination_test.cpp
View file @
8143e4fb
...
@@ -43,6 +43,22 @@ void simple_test_nop()
...
@@ -43,6 +43,22 @@ void simple_test_nop()
EXPECT
(
result
!=
migraph
::
literal
{
4
});
EXPECT
(
result
!=
migraph
::
literal
{
4
});
}
}
void
simple_test_nop2
()
{
migraph
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
p
.
add_instruction
(
nop
{});
p
.
add_instruction
(
sum_op
{},
one
,
two
);
p
.
add_instruction
(
nop
{});
p
.
compile
(
dce_target
{});
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
==
2
);
auto
result
=
p
.
eval
({});
EXPECT
(
result
==
migraph
::
literal
{});
EXPECT
(
result
!=
migraph
::
literal
{
4
});
}
void
duplicate_test1
()
void
duplicate_test1
()
{
{
migraph
::
program
p
;
migraph
::
program
p
;
...
@@ -99,6 +115,7 @@ int main()
...
@@ -99,6 +115,7 @@ int main()
{
{
simple_test
();
simple_test
();
simple_test_nop
();
simple_test_nop
();
simple_test_nop2
();
duplicate_test1
();
duplicate_test1
();
duplicate_test2
();
duplicate_test2
();
depth_test
();
depth_test
();
...
...
test/fwd_conv_batchnorm_rewrite_test.cpp
View file @
8143e4fb
#include <migraph/fwd_conv_batchnorm_rewrite.hpp>
#include <migraph/fwd_conv_batchnorm_rewrite.hpp>
#include <migraph/program.hpp>
#include <migraph/program.hpp>
#include <migraph/cpu/
cpu_
target.hpp>
#include <migraph/cpu/target.hpp>
#include <migraph/operators.hpp>
#include <migraph/operators.hpp>
#include <migraph/instruction.hpp>
#include <migraph/instruction.hpp>
#include <test.hpp>
#include <test.hpp>
...
@@ -51,8 +51,8 @@ void fwd_conv_batchnorm_rewrite_test()
...
@@ -51,8 +51,8 @@ void fwd_conv_batchnorm_rewrite_test()
migraph
::
program
p2
=
create_program
();
migraph
::
program
p2
=
create_program
();
migraph
::
fwd_conv_batchnorm_rewrite
opt
;
migraph
::
fwd_conv_batchnorm_rewrite
opt
;
opt
.
apply
(
p2
);
opt
.
apply
(
p2
);
p1
.
compile
(
migraph
::
cpu
::
cpu_
target
{});
p1
.
compile
(
migraph
::
cpu
::
target
{});
p2
.
compile
(
migraph
::
cpu
::
cpu_
target
{});
p2
.
compile
(
migraph
::
cpu
::
target
{});
auto
result1
=
p1
.
eval
({});
auto
result1
=
p1
.
eval
({});
auto
result2
=
p2
.
eval
({});
auto
result2
=
p2
.
eval
({});
...
...
test/gpu/miopen.cpp
View file @
8143e4fb
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#include <migraph/program.hpp>
#include <migraph/program.hpp>
#include <migraph/operators.hpp>
#include <migraph/operators.hpp>
#include <migraph/generate.hpp>
#include <migraph/generate.hpp>
#include <migraph/cpu/
cpu_
target.hpp>
#include <migraph/cpu/target.hpp>
#include <migraph/gpu/target.hpp>
#include <migraph/gpu/target.hpp>
#include <migraph/gpu/miopen.hpp>
#include <migraph/gpu/miopen.hpp>
#include <migraph/gpu/hip.hpp>
#include <migraph/gpu/hip.hpp>
...
@@ -100,7 +100,7 @@ migraph::argument run_cpu(migraph::program& p)
...
@@ -100,7 +100,7 @@ migraph::argument run_cpu(migraph::program& p)
V
v
;
V
v
;
p
=
v
.
create_program
();
p
=
v
.
create_program
();
auto_print
pp
{
p
,
0
};
auto_print
pp
{
p
,
0
};
compile_check
(
p
,
migraph
::
cpu
::
cpu_
target
{});
compile_check
(
p
,
migraph
::
cpu
::
target
{});
migraph
::
program
::
parameter_map
m
;
migraph
::
program
::
parameter_map
m
;
for
(
auto
&&
x
:
p
.
get_parameter_shapes
())
for
(
auto
&&
x
:
p
.
get_parameter_shapes
())
{
{
...
@@ -129,11 +129,13 @@ template <class V>
...
@@ -129,11 +129,13 @@ template <class V>
void
verify_program
()
void
verify_program
()
{
{
auto_print
::
set_terminate_handler
(
migraph
::
get_type_name
<
V
>
());
auto_print
::
set_terminate_handler
(
migraph
::
get_type_name
<
V
>
());
// std::cout << migraph::get_type_name<V>() << std::endl;
migraph
::
program
cpu_prog
;
migraph
::
program
cpu_prog
;
migraph
::
program
gpu_prog
;
migraph
::
program
gpu_prog
;
auto
cpu_arg_f
=
detach_async
([
&
]
{
return
run_cpu
<
V
>
(
cpu_prog
);
});
auto
cpu_arg_f
=
detach_async
([
&
]
{
return
run_cpu
<
V
>
(
cpu_prog
);
});
auto
gpu_arg
=
run_gpu
<
V
>
(
gpu_prog
);
auto
gpu_arg
=
run_gpu
<
V
>
(
gpu_prog
);
bool
passed
=
verify_args
(
migraph
::
get_type_name
<
V
>
(),
cpu_arg_f
.
get
(),
gpu_arg
);
auto
cpu_arg
=
cpu_arg_f
.
get
();
bool
passed
=
verify_args
(
migraph
::
get_type_name
<
V
>
(),
cpu_arg
,
gpu_arg
);
if
(
not
passed
)
if
(
not
passed
)
{
{
V
v
;
V
v
;
...
@@ -174,6 +176,46 @@ struct test_add
...
@@ -174,6 +176,46 @@ struct test_add
}
}
};
};
struct
test_add_half
{
migraph
::
program
create_program
()
const
{
migraph
::
program
p
;
migraph
::
shape
s
{
migraph
::
shape
::
half_type
,
{
3
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
y
=
p
.
add_parameter
(
"y"
,
s
);
p
.
add_instruction
(
migraph
::
op
::
add
{},
x
,
y
);
return
p
;
}
};
struct
test_mul
{
migraph
::
program
create_program
()
const
{
migraph
::
program
p
;
migraph
::
shape
s
{
migraph
::
shape
::
float_type
,
{
3
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
y
=
p
.
add_parameter
(
"y"
,
s
);
p
.
add_instruction
(
migraph
::
op
::
mul
{},
x
,
y
);
return
p
;
}
};
struct
test_scale
{
migraph
::
program
create_program
()
const
{
migraph
::
program
p
;
migraph
::
shape
s
{
migraph
::
shape
::
float_type
,
{
3
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
y
=
p
.
add_parameter
(
"y"
,
migraph
::
shape
::
float_type
);
auto
scale
=
p
.
add_instruction
(
migraph
::
op
::
scalar
{
s
},
y
);
p
.
add_instruction
(
migraph
::
op
::
mul
{},
x
,
scale
);
return
p
;
}
};
struct
test_triadd
struct
test_triadd
{
{
migraph
::
program
create_program
()
const
migraph
::
program
create_program
()
const
...
@@ -355,6 +397,20 @@ struct test_conv_relu
...
@@ -355,6 +397,20 @@ struct test_conv_relu
}
}
};
};
struct
test_conv_relu_half
{
migraph
::
program
create_program
()
const
{
migraph
::
program
p
;
auto
input
=
p
.
add_parameter
(
"x"
,
migraph
::
shape
{
migraph
::
shape
::
half_type
,
{
4
,
3
,
3
,
3
}});
auto
weights
=
p
.
add_parameter
(
"w"
,
migraph
::
shape
{
migraph
::
shape
::
half_type
,
{
4
,
3
,
3
,
3
}});
auto
conv
=
p
.
add_instruction
(
migraph
::
op
::
convolution
{},
input
,
weights
);
p
.
add_instruction
(
migraph
::
op
::
activation
{
"relu"
},
conv
);
return
p
;
}
};
struct
test_add_relu
struct
test_add_relu
{
{
migraph
::
program
create_program
()
const
migraph
::
program
create_program
()
const
...
@@ -395,6 +451,36 @@ struct test_conv_pooling
...
@@ -395,6 +451,36 @@ struct test_conv_pooling
}
}
};
};
struct
test_global_avg_pooling
{
migraph
::
program
create_program
()
const
{
migraph
::
program
p
;
auto
input
=
p
.
add_parameter
(
"x"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
1
,
3
,
16
,
16
}});
auto
op
=
migraph
::
op
::
pooling
{
"average"
};
auto
lens
=
input
->
get_shape
().
lens
();
op
.
lengths
=
{
lens
[
2
],
lens
[
3
]};
p
.
add_instruction
(
op
,
input
);
return
p
;
}
};
struct
test_global_max_pooling
{
migraph
::
program
create_program
()
const
{
migraph
::
program
p
;
auto
input
=
p
.
add_parameter
(
"x"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
1
,
3
,
16
,
16
}});
auto
op
=
migraph
::
op
::
pooling
{
"max"
};
auto
lens
=
input
->
get_shape
().
lens
();
op
.
lengths
=
{
lens
[
2
],
lens
[
3
]};
p
.
add_instruction
(
op
,
input
);
return
p
;
}
};
struct
test_gemm
struct
test_gemm
{
{
migraph
::
program
create_program
()
const
migraph
::
program
create_program
()
const
...
@@ -402,7 +488,7 @@ struct test_gemm
...
@@ -402,7 +488,7 @@ struct test_gemm
migraph
::
program
p
;
migraph
::
program
p
;
auto
a
=
p
.
add_parameter
(
"a"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
5
}});
auto
a
=
p
.
add_parameter
(
"a"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
5
}});
auto
b
=
p
.
add_parameter
(
"b"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
5
,
3
}});
auto
b
=
p
.
add_parameter
(
"b"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
5
,
3
}});
p
.
add_instruction
(
migraph
::
op
::
gemm
{},
a
,
b
);
p
.
add_instruction
(
migraph
::
op
::
dot
{},
a
,
b
);
return
p
;
return
p
;
}
}
};
};
...
@@ -414,7 +500,7 @@ struct test_gemm_ld
...
@@ -414,7 +500,7 @@ struct test_gemm_ld
migraph
::
program
p
;
migraph
::
program
p
;
auto
a
=
p
.
add_parameter
(
"a"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
5
},
{
10
,
1
}});
auto
a
=
p
.
add_parameter
(
"a"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
5
},
{
10
,
1
}});
auto
b
=
p
.
add_parameter
(
"b"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
5
,
3
},
{
20
,
1
}});
auto
b
=
p
.
add_parameter
(
"b"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
5
,
3
},
{
20
,
1
}});
p
.
add_instruction
(
migraph
::
op
::
gemm
{},
a
,
b
);
p
.
add_instruction
(
migraph
::
op
::
dot
{},
a
,
b
);
return
p
;
return
p
;
}
}
};
};
...
@@ -427,7 +513,7 @@ struct test_gemm_transposeb
...
@@ -427,7 +513,7 @@ struct test_gemm_transposeb
auto
a
=
p
.
add_parameter
(
"a"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
5
}});
auto
a
=
p
.
add_parameter
(
"a"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
5
}});
auto
b
=
p
.
add_parameter
(
"b"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
3
,
5
}});
auto
b
=
p
.
add_parameter
(
"b"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
3
,
5
}});
auto
bt
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
b
);
auto
bt
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
b
);
p
.
add_instruction
(
migraph
::
op
::
gemm
{},
a
,
bt
);
p
.
add_instruction
(
migraph
::
op
::
dot
{},
a
,
bt
);
return
p
;
return
p
;
}
}
};
};
...
@@ -440,7 +526,7 @@ struct test_gemm_transposea
...
@@ -440,7 +526,7 @@ struct test_gemm_transposea
auto
a
=
p
.
add_parameter
(
"a"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
5
,
4
}});
auto
a
=
p
.
add_parameter
(
"a"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
5
,
4
}});
auto
b
=
p
.
add_parameter
(
"b"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
5
,
3
}});
auto
b
=
p
.
add_parameter
(
"b"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
5
,
3
}});
auto
at
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
a
);
auto
at
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
a
);
p
.
add_instruction
(
migraph
::
op
::
gemm
{},
at
,
b
);
p
.
add_instruction
(
migraph
::
op
::
dot
{},
at
,
b
);
return
p
;
return
p
;
}
}
};
};
...
@@ -454,7 +540,7 @@ struct test_gemm_transposeab
...
@@ -454,7 +540,7 @@ struct test_gemm_transposeab
auto
b
=
p
.
add_parameter
(
"b"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
3
,
5
}});
auto
b
=
p
.
add_parameter
(
"b"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
3
,
5
}});
auto
at
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
a
);
auto
at
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
a
);
auto
bt
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
b
);
auto
bt
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
b
);
p
.
add_instruction
(
migraph
::
op
::
gemm
{},
at
,
bt
);
p
.
add_instruction
(
migraph
::
op
::
dot
{},
at
,
bt
);
return
p
;
return
p
;
}
}
};
};
...
@@ -720,6 +806,9 @@ int main()
...
@@ -720,6 +806,9 @@ int main()
verify_program
<
test_concat2
>
();
verify_program
<
test_concat2
>
();
verify_program
<
test_concat_relu
>
();
verify_program
<
test_concat_relu
>
();
verify_program
<
test_add
>
();
verify_program
<
test_add
>
();
verify_program
<
test_add_half
>
();
verify_program
<
test_mul
>
();
verify_program
<
test_scale
>
();
verify_program
<
test_triadd
>
();
verify_program
<
test_triadd
>
();
verify_program
<
test_triadd2
>
();
verify_program
<
test_triadd2
>
();
verify_program
<
test_add_broadcast
>
();
verify_program
<
test_add_broadcast
>
();
...
@@ -733,9 +822,12 @@ int main()
...
@@ -733,9 +822,12 @@ int main()
verify_program
<
test_conv
>
();
verify_program
<
test_conv
>
();
verify_program
<
test_conv2
>
();
verify_program
<
test_conv2
>
();
verify_program
<
test_conv_relu
>
();
verify_program
<
test_conv_relu
>
();
verify_program
<
test_conv_relu_half
>
();
verify_program
<
test_add_relu
>
();
verify_program
<
test_add_relu
>
();
verify_program
<
test_leaky_relu
>
();
verify_program
<
test_leaky_relu
>
();
verify_program
<
test_conv_pooling
>
();
verify_program
<
test_conv_pooling
>
();
verify_program
<
test_global_avg_pooling
>
();
verify_program
<
test_global_max_pooling
>
();
verify_program
<
test_gemm
>
();
verify_program
<
test_gemm
>
();
// verify_program<test_gemm_ld>();
// verify_program<test_gemm_ld>();
verify_program
<
test_gemm_transposeb
>
();
verify_program
<
test_gemm_transposeb
>
();
...
...
test/onnx/globalavgpool_test.onnx
0 → 100644
View file @
8143e4fb
globalavgpool-example:i
01"GlobalAveragePooltest-globalavgpoolZ
0
b
1
B
\ No newline at end of file
test/onnx/globalmaxpool_test.onnx
0 → 100644
View file @
8143e4fb
globalmaxpool-example:e
01" GlobalMaxPooltest-globalmaxpoolZ
0
b
1
B
\ No newline at end of file
test/onnx/imagescaler_test.onnx
0 → 100644
View file @
8143e4fb
File added
test/onnx/onnx_test.cpp
View file @
8143e4fb
...
@@ -100,6 +100,52 @@ void leaky_relu_test()
...
@@ -100,6 +100,52 @@ void leaky_relu_test()
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
void
imagescaler_test
()
{
migraph
::
program
p
;
migraph
::
shape
s
{
migraph
::
shape
::
float_type
,
{
1
,
3
,
16
,
16
}};
auto
l0
=
p
.
add_parameter
(
"0"
,
s
);
auto
scale_val
=
p
.
add_literal
(
0.5
f
);
auto
bias_vals
=
p
.
add_literal
(
migraph
::
literal
{
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
3
}},
{
0.01
,
0.02
,
0.03
}});
auto
scaled_tensor
=
p
.
add_instruction
(
migraph
::
op
::
scalar
{
s
},
scale_val
);
auto
img_scaled
=
p
.
add_instruction
(
migraph
::
op
::
mul
{},
l0
,
scaled_tensor
);
auto
bias_bcast
=
p
.
add_instruction
(
migraph
::
op
::
broadcast
{
1
,
s
},
bias_vals
);
p
.
add_instruction
(
migraph
::
op
::
add
{},
img_scaled
,
bias_bcast
);
auto
prog
=
migraph
::
parse_onnx
(
"imagescaler_test.onnx"
);
EXPECT
(
p
==
prog
);
}
void
globalavgpool_test
()
{
migraph
::
program
p
;
auto
input
=
p
.
add_parameter
(
"0"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
1
,
3
,
16
,
16
}});
auto
op
=
migraph
::
op
::
pooling
{
"average"
};
auto
lens
=
input
->
get_shape
().
lens
();
op
.
lengths
=
{
lens
[
2
],
lens
[
3
]};
p
.
add_instruction
(
op
,
input
);
auto
prog
=
migraph
::
parse_onnx
(
"globalavgpool_test.onnx"
);
EXPECT
(
p
==
prog
);
}
void
globalmaxpool_test
()
{
migraph
::
program
p
;
auto
input
=
p
.
add_parameter
(
"0"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
1
,
3
,
16
,
16
}});
auto
op
=
migraph
::
op
::
pooling
{
"max"
};
auto
lens
=
input
->
get_shape
().
lens
();
op
.
lengths
=
{
lens
[
2
],
lens
[
3
]};
p
.
add_instruction
(
op
,
input
);
auto
prog
=
migraph
::
parse_onnx
(
"globalmaxpool_test.onnx"
);
EXPECT
(
p
==
prog
);
}
int
main
()
int
main
()
{
{
pytorch_conv_bias_test
();
pytorch_conv_bias_test
();
...
@@ -107,4 +153,7 @@ int main()
...
@@ -107,4 +153,7 @@ int main()
pytorch_conv_bn_relu_maxpool
();
pytorch_conv_bn_relu_maxpool
();
pytorch_conv_relu_maxpool_x2
();
pytorch_conv_relu_maxpool_x2
();
leaky_relu_test
();
leaky_relu_test
();
imagescaler_test
();
globalavgpool_test
();
globalmaxpool_test
();
}
}
test/op_shape_test.cpp
View file @
8143e4fb
...
@@ -93,7 +93,7 @@ void contiguous_shape()
...
@@ -93,7 +93,7 @@ void contiguous_shape()
throws_shape
(
migraph
::
op
::
contiguous
{},
input
,
input
);
throws_shape
(
migraph
::
op
::
contiguous
{},
input
,
input
);
migraph
::
shape
single
{
migraph
::
shape
::
float_type
,
{
2
}};
migraph
::
shape
single
{
migraph
::
shape
::
float_type
,
{
2
}};
throws
_shape
(
migraph
::
op
::
contiguous
{},
single
);
expect
_shape
(
single
,
migraph
::
op
::
contiguous
{},
single
);
}
}
void
reshape_shape
()
void
reshape_shape
()
...
...
Prev
1
2
3
4
Next
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