Home | History | Annotate | Download | only in graph
      1 /* Copyright 2015 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 "tensorflow/core/graph/graph_def_builder.h"
     17 
     18 #include "tensorflow/core/framework/versions.pb.h"
     19 #include "tensorflow/core/graph/graph.h"
     20 #include "tensorflow/core/graph/graph_def_builder_util.h"
     21 #include "tensorflow/core/kernels/ops_util.h"
     22 #include "tensorflow/core/lib/core/status_test_util.h"
     23 #include "tensorflow/core/platform/test.h"
     24 #include "tensorflow/core/public/version.h"
     25 
     26 namespace tensorflow {
     27 namespace {
     28 
     29 TEST(GraphDefBuilderTest, Version) {
     30   // Verify that our assertions will be nontrivial
     31   ASSERT_LT(0, TF_GRAPH_DEF_VERSION);
     32 
     33   // Newly built graphs should use the current version
     34   GraphDefBuilder builder(GraphDefBuilder::kFailImmediately);
     35 
     36   // Check version when we convert to a Graph
     37   Graph graph(OpRegistry::Global());
     38   TF_EXPECT_OK(GraphDefBuilderToGraph(builder, &graph));
     39   ASSERT_EQ(graph.versions().producer(), TF_GRAPH_DEF_VERSION);
     40   ASSERT_EQ(graph.versions().min_consumer(), TF_GRAPH_DEF_VERSION_MIN_CONSUMER);
     41 
     42   // Check version when we convert to a GraphDef
     43   GraphDef graph_def;
     44   TF_EXPECT_OK(builder.ToGraphDef(&graph_def));
     45   ASSERT_EQ(graph_def.versions().producer(), TF_GRAPH_DEF_VERSION);
     46   ASSERT_EQ(graph_def.versions().min_consumer(),
     47             TF_GRAPH_DEF_VERSION_MIN_CONSUMER);
     48 }
     49 
     50 }  // namespace
     51 }  // namespace tensorflow
     52