• 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 vcyou 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_HEXAGON_OPS_DEFINITIONS_H_
17 #define TENSORFLOW_CORE_KERNELS_HEXAGON_HEXAGON_OPS_DEFINITIONS_H_
18 
19 #include <unordered_map>
20 
21 #include "tensorflow/core/framework/types.h"
22 #include "tensorflow/core/kernels/i_remote_fused_graph_ops_definitions.h"
23 #include "tensorflow/core/platform/macros.h"
24 
25 namespace tensorflow {
26 
27 // HexagonOpsDefinitions provides ops definitions supported in hexagon library
28 // TODO(satok): add a functionality to call functions in hexagon library
29 class HexagonOpsDefinitions final : public IRemoteFusedGraphOpsDefinitions {
30  public:
31   static const IRemoteFusedGraphOpsDefinitions& getInstance();
32 
33   int GetTotalOpsCount() const final;
34   int GetOpIdFor(const string& op_type, const DataTypeVector& dt) const final;
35 
36  private:
37   enum class SupportedOpType;
38   using DataTypeToOp = std::tuple<DataTypeVector, SupportedOpType>;
39 
40   HexagonOpsDefinitions();
41 
42   static void EmplaceOpType(
43       const string& op_type, const DataTypeVector& dt_vec,
44       const SupportedOpType supported_op_type,
45       std::unordered_map<string, std::vector<DataTypeToOp>>* map);
46 
47   static std::unordered_map<string, std::vector<DataTypeToOp>>
48   BuildOpNameToSocOpTypeMap();
49 
50   const std::unordered_map<string, std::vector<DataTypeToOp>>
51       op_name_to_soc_op_type_map_;
52 
53   TF_DISALLOW_COPY_AND_ASSIGN(HexagonOpsDefinitions);
54 };
55 
56 }  // namespace tensorflow
57 
58 #endif  // TENSORFLOW_CORE_KERNELS_HEXAGON_HEXAGON_OPS_DEFINITIONS_H_
59