Home | History | Annotate | Download | only in segment
      1 /* Copyright 2018 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_CONTRIB_TENSORRT_SEGMENT_SEGMENT_H_
     17 #define TENSORFLOW_CONTRIB_TENSORRT_SEGMENT_SEGMENT_H_
     18 
     19 #include <set>
     20 #include <vector>
     21 
     22 #include "tensorflow/core/framework/graph.pb.h"
     23 #include "tensorflow/core/lib/core/status.h"
     24 #include "tensorflow/core/platform/types.h"
     25 
     26 namespace tensorflow {
     27 namespace tensorrt {
     28 namespace segment {
     29 
     30 using SegmentNodesVector = std::vector<std::set<string>>;
     31 
     32 struct SegmentOptions {
     33   // Segment must contain at least this many nodes.
     34   int minimum_segment_size = 2;
     35   std::set<string> exclude_node_list;
     36 };
     37 
     38 // Get the subgraphs of a graph that can be handled by TensorRT.
     39 //
     40 // @param gdef The GraphDef describing the network
     41 // @param candidate_fn A function that returns true for a NodeDef if
     42 // that node can be handled by TensorRT.
     43 // @param segments Returns the TensorRT segments/subgraphs. Each entry
     44 // in the vector describes a subgraph by giving a set of the names of
     45 // all the NodeDefs in that subgraph.
     46 // @return the status.
     47 tensorflow::Status SegmentGraph(
     48     const tensorflow::GraphDef& gdef,
     49     const std::function<bool(const tensorflow::NodeDef&)>& candidate_fn,
     50     const SegmentOptions& options, SegmentNodesVector* segments);
     51 
     52 }  // namespace segment
     53 }  // namespace tensorrt
     54 }  // namespace tensorflow
     55 
     56 #endif  // TENSORFLOW_CONTRIB_TENSORRT_SEGMENT_SEGMENT_H_
     57