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