xref: /aosp_15_r20/external/XNNPACK/src/xnnpack/post-operation.h (revision 4bdc94577ba0e567308109d787f7fec7b531ce36)
1 // Copyright 2022 Google LLC
2 //
3 // This source code is licensed under the BSD-style license found in the
4 // LICENSE file in the root directory of this source tree.
5 
6 #pragma once
7 
8 #include <stddef.h>
9 
10 // Operators that can be applied post convolution.
11 enum xnn_post_operation_type {
12   xnn_post_operation_type_none,
13   xnn_post_operation_type_hardswish,
14 };
15 
16 // Struct representing a post operation and its associated data. For example,
17 // an addition with constant will specify the constant in the arg1 field, a
18 // clamp will specify min in arg1, and max in arg2.
19 struct xnn_post_operation {
20   enum xnn_post_operation_type op_type;
21   float arg1;
22   float arg2;
23 };
24 
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 // Allocate space for params required for post_operations and initialize all params.
31 // This allocation will be freed when the operator holding these params is deleted.
32 char* allocate_and_initialize_post_operation_params(
33     size_t num_post_operations,
34     struct xnn_post_operation* post_operations);
35 
36 #ifdef __cplusplus
37 }  // extern "C"
38 #endif
39