Home | History | Annotate | Download | only in util
      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 %include <std_string.i>
     17 %include "tensorflow/python/lib/core/strings.i"
     18 %include "tensorflow/python/platform/base.i"
     19 
     20 %{
     21 #include "tensorflow/core/lib/core/status.h"
     22 #include "tensorflow/core/util/stat_summarizer.h"
     23 #include "tensorflow/python/lib/core/py_func.h"
     24 
     25 #include "tensorflow/core/framework/step_stats.pb.h"
     26 %}
     27 
     28 %ignoreall
     29 
     30 %unignore _NewStatSummarizer;
     31 %unignore _DeleteStatSummarizer;
     32 %unignore tensorflow;
     33 %unignore tensorflow::StatSummarizer;
     34 %unignore tensorflow::StatSummarizer::StatSummarizer;
     35 %unignore tensorflow::StatSummarizer::~StatSummarizer;
     36 %unignore tensorflow::StatSummarizer::Initialize;
     37 %unignore tensorflow::StatSummarizer::InitializeStr;
     38 %unignore tensorflow::StatSummarizer::ProcessStepStats;
     39 %unignore tensorflow::StatSummarizer::ProcessStepStatsStr;
     40 %unignore tensorflow::StatSummarizer::PrintStepStats;
     41 %unignore tensorflow::StatSummarizer::GetOutputString;
     42 
     43 
     44 // TODO(ashankar): Remove the unused argument from the API.
     45 %{
     46 tensorflow::StatSummarizer* _NewStatSummarizer(
     47       const string& unused) {
     48   return new tensorflow::StatSummarizer(tensorflow::StatSummarizerOptions());
     49 }
     50 %}
     51 
     52 %{
     53 void _DeleteStatSummarizer(tensorflow::StatSummarizer* ss) {
     54   delete ss;
     55 }
     56 %}
     57 
     58 tensorflow::StatSummarizer* _NewStatSummarizer(const string& unused);
     59 void _DeleteStatSummarizer(tensorflow::StatSummarizer* ss);
     60 
     61 %extend tensorflow::StatSummarizer {
     62   void ProcessStepStatsStr(const string& step_stats_str) {
     63     tensorflow::StepStats step_stats;
     64     step_stats.ParseFromString(step_stats_str);
     65     $self->ProcessStepStats(step_stats);
     66 }
     67 }
     68 
     69 %extend tensorflow::StatSummarizer {
     70   StatSummarizer() {
     71     tensorflow::StatSummarizer* ss = new tensorflow::StatSummarizer(
     72       tensorflow::StatSummarizerOptions());
     73     return ss;
     74 }
     75 }
     76 
     77 %include "tensorflow/core/util/stat_summarizer.h"
     78 %unignoreall
     79 
     80 %insert("python") %{
     81 
     82 # Wrapping NewStatSummarizer and DeletStatSummarizer because
     83 # SWIG-generated functions are built-in functions and do not support
     84 # setting _tf_api_names attribute.
     85 
     86 def NewStatSummarizer(unused):
     87   return _NewStatSummarizer(unused)
     88 
     89 def DeleteStatSummarizer(stat_summarizer):
     90   _DeleteStatSummarizer(stat_summarizer)
     91 
     92 NewStatSummarizer._tf_api_names = ["contrib.stat_summarizer.NewStatSummarizer"]
     93 DeleteStatSummarizer._tf_api_names = [
     94     "contrib.stat_summarizer.DeleteStatSummarizer"]
     95 StatSummarizer._tf_api_names = ["contrib.stat_summarizer.StatSummarizer"]
     96 %}
     97