1 /*
2  * Copyright (C) 2019 The Android Open Source Project
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 #ifndef ANDROID_FRAMEWORKS_ML_NN_EXTENSIONS_EXAMPLE_FIBONACCI_FIBONACCI_EXTENSION_H
18 #define ANDROID_FRAMEWORKS_ML_NN_EXTENSIONS_EXAMPLE_FIBONACCI_FIBONACCI_EXTENSION_H
19 
20 /**
21  * A sample extension definition.
22  *
23  * "Example" is a stand-in for the vendor name.
24  *
25  * Tests are available in
26  * runtime/test/fibonacci_extension/FibonacciExtensionTest.cpp
27  */
28 
29 const char EXAMPLE_FIBONACCI_EXTENSION_NAME[] = "com.example.fibonacci";
30 
31 /**
32  * Quantization parameters for {@link EXAMPLE_TENSOR_QUANT64_ASYMM}.
33  */
34 typedef struct ExampleQuant64AsymmParams {
35     double scale;
36     int64_t zeroPoint;
37 } ExampleQuant64AsymmParams;
38 
39 enum {
40     /**
41      * A signed 64-bit integer scalar value.
42      */
43     EXAMPLE_INT64 = 0,
44 
45     /**
46      * A tensor of 64-bit unsigned integers that represent real numbers.
47      *
48      * Attached to this tensor is {@link ExampleQuant64AsymmParams} that is
49      * used to convert the 64-bit bit integer to the real value and vice versa.
50      *
51      * The formula is:
52      *   real_value = (integer_value - zeroPoint) * scale.
53      */
54     EXAMPLE_TENSOR_QUANT64_ASYMM = 1,
55 };
56 
57 enum {
58     /**
59      * Computes the Fibonacci sequence up to n.
60      *
61      * Supported input types:
62      * - {@link EXAMPLE_INT64}
63      * - {@link ANEURALNETWORKS_TENSOR_FLOAT32} (must contain exactly 1 element)
64      *
65      * Supported output types:
66      * - {@link EXAMPLE_TENSOR_QUANT64_ASYMM}
67      * - {@link ANEURALNETWORKS_TENSOR_FLOAT32}
68      *
69      * Inputs:
70      * * 0: A scalar n.
71      *
72      * Outputs:
73      * * 0: A 1-D tensor of size n.
74      */
75     EXAMPLE_FIBONACCI = 0,
76 };
77 
78 #endif  // ANDROID_FRAMEWORKS_ML_NN_EXTENSIONS_EXAMPLE_FIBONACCI_FIBONACCI_EXTENSION_H
79