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