1 | /******************************************************************************* |
2 | * Copyright 2019-2021 Intel Corporation |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | *******************************************************************************/ |
16 | |
17 | #include <utility> |
18 | |
19 | #include "dnnl_test_common.hpp" |
20 | #include "test_reorder_common.hpp" |
21 | #include "gtest/gtest.h" |
22 | |
23 | #include "oneapi/dnnl/dnnl.hpp" |
24 | |
25 | namespace dnnl { |
26 | |
27 | using f32_f32 = std::pair<float, float>; |
28 | |
29 | using tag = memory::format_tag; |
30 | |
31 | using cfg_f32 = test_simple_params<f32_f32>; |
32 | |
33 | using reorder_simple_test_f32_f32 = reorder_simple_test<f32_f32>; |
34 | |
35 | #if DNNL_CPU_RUNTIME != DNNL_RUNTIME_NONE |
36 | TEST_P(reorder_simple_test_f32_f32, CPU_GPU) { |
37 | SKIP_IF(engine::get_count(engine::kind::gpu) == 0, |
38 | "GPU engines not found." ); |
39 | |
40 | engine eng_cpu(engine::kind::cpu, 0); |
41 | engine eng_gpu(engine::kind::gpu, 0); |
42 | |
43 | Test(eng_cpu, eng_gpu); |
44 | } |
45 | |
46 | TEST_P(reorder_simple_test_f32_f32, GPU_CPU) { |
47 | SKIP_IF(engine::get_count(engine::kind::gpu) == 0, |
48 | "GPU engines not found." ); |
49 | |
50 | engine eng_gpu(engine::kind::gpu, 0); |
51 | engine eng_cpu(engine::kind::cpu, 0); |
52 | |
53 | Test(eng_gpu, eng_cpu); |
54 | } |
55 | #endif |
56 | |
57 | TEST_P(reorder_simple_test_f32_f32, GPU_GPU) { |
58 | SKIP_IF(engine::get_count(engine::kind::gpu) == 0, |
59 | "GPU engines not found." ); |
60 | |
61 | engine eng_gpu1(engine::kind::gpu, 0); |
62 | engine eng_gpu2(engine::kind::gpu, 0); |
63 | |
64 | // Reorder within one engine |
65 | Test(eng_gpu1, eng_gpu1); |
66 | |
67 | // Different GPU engines |
68 | Test(eng_gpu1, eng_gpu2); |
69 | } |
70 | |
71 | INSTANTIATE_TEST_SUITE_P(Data, reorder_simple_test_f32_f32, |
72 | ::testing::Values(cfg_f32 {tag::nchw, tag::nhwc, {32, 48, 5, 4}}, |
73 | cfg_f32 {tag::oihw, tag::IOhw16i16o, {32, 48, 2, 3}}, |
74 | cfg_f32 {tag::oihw, tag::OIhw16o16i, {32, 32, 1, 1}}, |
75 | cfg_f32 {tag::hwigo, tag::gIOhw16i16o, {2, 64, 32, 1, 3}}, |
76 | cfg_f32 {tag::goihw, tag::gOIhw16o16i, {2, 32, 64, 2, 3}}, |
77 | cfg_f32 {tag::OIhw16o16i, tag::IOhw16i16o, {32, 48, 2, 3}}, |
78 | cfg_f32 {tag::gOIhw16o16i, tag::gIOhw16i16o, {2, 64, 32, 3, 2}}, |
79 | cfg_f32 {tag::oidhw, tag::OIdhw16i16o, {64, 32, 3, 9, 5}}, |
80 | cfg_f32 {tag::goidhw, tag::gOIdhw16i16o, {2, 32, 64, 4, 1, 7}}, |
81 | cfg_f32 {tag::nchw, tag::nhwc, {32, 48, 5, 4}}, |
82 | cfg_f32 {tag::nchw, tag::NChw16n16c, {64, 32, 5, 6}}, |
83 | cfg_f32 {tag::nChw16c, tag::NChw16n16c, {32, 48, 6, 9}})); |
84 | |
85 | } // namespace dnnl |
86 | |