1 | /******************************************************************************* |
2 | * Copyright 2022 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 "dnnl_memory.hpp" |
18 | |
19 | #include "self/self.hpp" |
20 | |
21 | namespace self { |
22 | |
23 | static int check_bool_operator() { |
24 | dnnl_dim_t dims {1}; |
25 | auto md = dnn_mem_t::init_md(1, &dims, dnnl_f32, tag::abx); |
26 | auto md0 = dnn_mem_t::init_md(0, &dims, dnnl_f32, tag::abx); |
27 | { |
28 | dnn_mem_t m; |
29 | SELF_CHECK_EQ(bool(m), false); |
30 | } |
31 | { |
32 | dnn_mem_t m(md, get_test_engine()); |
33 | SELF_CHECK_EQ(bool(m), true); |
34 | dnn_mem_t n(md0, get_test_engine()); |
35 | SELF_CHECK_EQ(bool(n), false); |
36 | } |
37 | { |
38 | dnn_mem_t m(1, &dims, dnnl_f32, tag::abx, get_test_engine()); |
39 | SELF_CHECK_EQ(bool(m), true); |
40 | dnn_mem_t n(0, &dims, dnnl_f32, tag::abx, get_test_engine()); |
41 | SELF_CHECK_EQ(bool(n), false); |
42 | } |
43 | { |
44 | dnn_mem_t m(1, &dims, dnnl_f32, &dims /* strides */, get_test_engine()); |
45 | SELF_CHECK_EQ(bool(m), true); |
46 | dnn_mem_t n(0, &dims, dnnl_f32, &dims /* strides */, get_test_engine()); |
47 | SELF_CHECK_EQ(bool(n), false); |
48 | } |
49 | { |
50 | dnn_mem_t m(md, dnnl_f32, tag::abx, get_test_engine()); |
51 | SELF_CHECK_EQ(bool(m), true); |
52 | dnn_mem_t n(md0, dnnl_f32, tag::abx, get_test_engine()); |
53 | SELF_CHECK_EQ(bool(n), false); |
54 | } |
55 | return OK; |
56 | } |
57 | |
58 | void memory() { |
59 | RUN(check_bool_operator()); |
60 | } |
61 | |
62 | } // namespace self |
63 | |