1 /* Copyright 2017 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_GRAPH_TRANSFER_UTILS_H_ 17 #define TENSORFLOW_CORE_KERNELS_HEXAGON_GRAPH_TRANSFER_UTILS_H_ 18 19 #include <queue> 20 #include <utility> 21 #include <vector> 22 23 #include "tensorflow/core/framework/types.h" 24 #include "tensorflow/core/kernels/hexagon/graph_transferer.h" 25 #include "tensorflow/core/platform/macros.h" 26 27 namespace tensorflow { 28 29 class RemoteFusedGraphExecuteInfo; 30 31 class GraphTransferUtils { 32 public: 33 static std::priority_queue<std::tuple<float, int, string>> 34 GetTopNFloatResults(const float* const data, const string* const labels, 35 const int element_count); 36 37 static void DumpTopNFloatResults(const float* const data, 38 const string* const labels, 39 const int element_count, const int top_n); 40 41 static GraphDef BuildFusedGraphDef( 42 const IRemoteFusedGraphOpsDefinitions& ops_definitions, 43 const string& remote_graph_execute_name, 44 const std::vector<std::pair<string, Tensor>>& inputs, 45 const std::vector<string>& outputs, GraphDef* original_def); 46 47 private: 48 static RemoteFusedGraphExecuteInfo BuildRemoteFusedGraphExecuteInfo( 49 const GraphDef& graph_def, 50 const std::vector<std::pair<string, Tensor>>& inputs, 51 const std::vector<string>& outputs, 52 const RemoteFusedGraphExecuteUtils::TensorShapeMap& tensor_shape_map); 53 54 TF_DISALLOW_COPY_AND_ASSIGN(GraphTransferUtils); 55 }; 56 57 } // namespace tensorflow 58 59 #endif // TENSORFLOW_CORE_KERNELS_HEXAGON_GRAPH_TRANSFER_UTILS_H_ 60