• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
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 TENSORFLOW_CORE_KERNELS_HEXAGON_SOC_INTERFACE_H_
17 #define TENSORFLOW_CORE_KERNELS_HEXAGON_SOC_INTERFACE_H_
18 
19 // Declaration of APIs provided by hexagon shared library. This header is shared
20 // with both hexagon library built with qualcomm SDK and tensorflow.
21 // All functions defined here must have prefix "soc_interface" to avoid
22 // naming conflicts.
23 #ifdef __cplusplus
24 #include <cstdint>
25 extern "C" {
26 #else
27 #include <stdbool.h>
28 #endif  // __cplusplus
29 // Returns the version of loaded hexagon wrapper shared library.
30 // You should assert that the version matches the expected version before
31 // calling APIs defined in this header.
32 int soc_interface_GetWrapperVersion();
33 // Returns the version of hexagon binary.
34 // You should assert that the version matches the expected version before
35 // calling APIs defined in this header.
36 int soc_interface_GetSocControllerVersion();
37 // Initialize SOC
38 bool soc_interface_Init();
39 // Finalize SOC
40 bool soc_interface_Finalize();
41 // Execute graph on SOC
42 bool soc_interface_ExecuteGraph();
43 // Teardown graph setup
44 bool soc_interface_TeardownGraph();
45 
46 // Allocate buffers for input node and output node
47 bool soc_interface_AllocateInOutNodeBuffers(int input_count, int* input_sizes,
48                                             int output_count,
49                                             int* output_sizes);
50 
51 // Send input data to SOC with port
52 bool soc_interface_FillInputNodeWithPort(int port, int x, int y, int z, int d,
53                                          const uint8_t* const buf,
54                                          uint64_t buf_byte_size);
55 
56 // Send input data to SOC
57 bool soc_interface_FillInputNodeFloat(int x, int y, int z, int d,
58                                       const uint8_t* const buf,
59                                       uint64_t buf_byte_size);
60 
61 // Load output data from SOC with port
62 bool soc_interface_ReadOutputNodeWithPort(int port, uint8_t** buf,
63                                           uint64_t* buf_byte_size);
64 
65 // Load output data from SOC
66 bool soc_interface_ReadOutputNodeFloat(const char* const node_name,
67                                        uint8_t** buf, uint64_t* buf_byte_size);
68 
69 // Setup graph
70 // TODO(satok): Remove and use runtime version
71 bool soc_interface_setupDummyGraph(int version);
72 
73 // Allocate memory for params of node inputs and node outputs
74 bool soc_interface_AllocateNodeInputAndNodeOutputArray(int total_input_count,
75                                                        int total_output_count);
76 
77 // Release memory for params of node inputs and node outputs
78 bool soc_interface_ReleaseNodeInputAndNodeOutputArray();
79 
80 // Set one node's inputs and return pointer to that struct
81 void* soc_interface_SetOneNodeInputs(int input_count, const int* const node_id,
82                                      const int* const port);
83 
84 // Set one node's outputs and return pointer to that struct
85 void* soc_interface_SetOneNodeOutputs(int output_count, int* max_size);
86 
87 // Append const node to the graph
88 bool soc_interface_AppendConstNode(const char* const name, int node_id,
89                                    int batch, int height, int width, int depth,
90                                    const uint8_t* const data, int data_length);
91 
92 // Append node to the graph
93 bool soc_interface_AppendNode(const char* const name, int node_id, int op_id,
94                               int padding_id, const void* const inputs,
95                               int inputs_count, const void* const outputs,
96                               int outputs_count);
97 
98 // Instantiate graph
99 bool soc_interface_InstantiateGraph();
100 
101 // Construct graph
102 bool soc_interface_ConstructGraph();
103 
104 // Set log level
105 void soc_interface_SetLogLevel(int log_level);
106 
107 // Set debug flag
108 void soc_interface_SetDebugFlag(uint64_t flag);
109 
110 #ifdef __cplusplus
111 }
112 #endif  // __cplusplus
113 
114 #endif  // TENSORFLOW_CORE_KERNELS_HEXAGON_SOC_INTERFACE_H_
115