1 | /******************************************************************************* |
2 | * Copyright 2016-2018 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 <assert.h> |
18 | #include "mkldnn.h" |
19 | |
20 | #include "c_types_map.hpp" |
21 | #include "engine.hpp" |
22 | #include "primitive_desc.hpp" |
23 | #include "utils.hpp" |
24 | |
25 | using namespace mkldnn::impl; |
26 | using namespace mkldnn::impl::utils; |
27 | using namespace mkldnn::impl::status; |
28 | |
29 | status_t mkldnn_primitive_desc_query(const primitive_desc_t *primitive_desc, |
30 | query_t what, int index, void *result) { |
31 | if (any_null(primitive_desc, result)) |
32 | return invalid_arguments; |
33 | |
34 | return primitive_desc->query(what, index, result); |
35 | } |
36 | |
37 | const memory_desc_t *mkldnn_primitive_desc_query_md( |
38 | const primitive_desc_t *primitive_desc, query_t what, int index) { |
39 | const memory_desc_t *res_md = nullptr; |
40 | bool args_ok = true |
41 | && primitive_desc != nullptr |
42 | && (what & query::some_md) == query::some_md |
43 | && what != query::some_md |
44 | && mkldnn_primitive_desc_query(primitive_desc, |
45 | what, index, &res_md) == success; |
46 | return args_ok ? res_md : nullptr; |
47 | } |
48 | |
49 | int mkldnn_primitive_desc_query_s32(const primitive_desc_t *primitive_desc, |
50 | query_t what, int index) { |
51 | int res_s32; |
52 | bool args_ok = primitive_desc != nullptr |
53 | && one_of(what, query::num_of_inputs_s32, query::num_of_outputs_s32) |
54 | && mkldnn_primitive_desc_query(primitive_desc, what, index, &res_s32) |
55 | == success; |
56 | return args_ok ? res_s32 : 0; |
57 | } |
58 | |
59 | // vim: et ts=4 sw=4 cindent cino^=l0,\:0,N-s |
60 | |