Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / api / C / contract.h
1 // Copyright (c) 2019 Intel Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 ///////////////////////////////////////////////////////////////////////////////////////////////////
16 #ifndef CONTRACT_H
17 #define CONTRACT_H
18
19 #include "cldnn.h"
20
21
22 /// @addtogroup c_api C API
23 /// @{
24 /// @addtogroup c_topology Network Topology
25 /// @{
26 /// @addtogroup c_primitives Primitives
27 /// @{
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33     /// @brief Select reduction operation for contract layer ( @CLDNN_PRIMITIVE_DESC{contract} ?).
34     typedef enum /*:int32_t*/
35     {
36         /// @brief Sum reduction.
37         cldnn_contract_sum,
38         /// @brief Product reduction.
39         cldnn_contract_product,
40         /// @brief All reduction.
41         cldnn_contract_all,
42         /// @brief Any reduction.
43         cldnn_contract_any,
44         /// @brief Max reduction.
45         cldnn_contract_max
46     } cldnn_contract_mode;
47
48     /// @brief Reduces input with an operation defined by @p mode along defined
49     ///        by @p reduction_axes dimensions.
50     ///
51     /// @details Reduces the input using the binary operation determined by
52     ///          @p mode. The @p reduction_axes determine the final shape of the
53     ///          output, which is calculated based on the input shape by
54     ///          collapsing the dimensions along which the reduction happens.
55     ///          For example, for the input with
56     /// @n      <tt>input_sizes = (in_b, in_f, in_y, in_x)</tt>
57     /// @n a reduction with
58     /// @n      <tt>reduction_axes = (2)</tt>
59     /// @n would collapse the Y dimension, producing
60     /// @n      <tt>output_shape = (1, in_b, in_f, in_x)</tt>
61     /// @n where every element is a @p mode reduction of the input elements with
62     /// @n the same B, F and X coordinates.
63     /// @n
64     /// @n@b Requirements:
65     /// @n - @p reduction_axes size (dimensions count) must be within (inclusive) range
66     ///      1 - 4.
67     /// @n - @p reduction_axes mustn't have duplicate values.
68     /// @n - Values of @p reduction_axes must be within (inclusive) range 0 - 3
69     /// @n Breaking any of these conditions will raise an exception.
70     CLDNN_BEGIN_PRIMITIVE_DESC(contract)
71     /// @brief Reduction mode. See #cldnn_contract_mode.
72     int32_t mode; /*cldnn_contract_mode*/
73     /// @brief Array of axes positions from input shape (0-based, from left to right)
74     ///        along which reduction should happen.
75     cldnn_uint16_t_arr reduction_axes;
76
77     CLDNN_END_PRIMITIVE_DESC(contract)
78
79
80         CLDNN_DECLARE_PRIMITIVE_TYPE_ID(contract);
81
82 #ifdef __cplusplus
83 }
84 #endif
85
86 /// @}
87 /// @}
88 /// @}
89 #endif // CONTRACT_H