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"""Tests for tensorflow.ops.remote_fused_graph_ops.""" 16from __future__ import absolute_import 17from __future__ import division 18from __future__ import print_function 19 20import numpy as np 21 22# pylint: disable=unused-import,wildcard-import, line-too-long 23from tensorflow.contrib.remote_fused_graph.pylib.python.ops import remote_fused_graph_ops 24# pylint: enable=unused-import,wildcard-import,line-too-long 25 26from tensorflow.core.framework import graph_pb2 27from tensorflow.python.framework import dtypes 28from tensorflow.python.framework import ops 29from tensorflow.python.framework import test_util 30from tensorflow.python.platform import googletest 31 32 33class RemoteFusedGraphExecuteTest(test_util.TensorFlowTestCase): 34 """Tests for RemoteFusedGraphExecute op.""" 35 36 def testBuild(self): 37 graph = graph_pb2.GraphDef() 38 node = graph.node.add() 39 node.name = "a" 40 node.op = "op0" 41 node = graph.node.add() 42 node.name = "b" 43 node.op = "op1" 44 inputs = [ops.convert_n_to_tensor([1], dtypes.int64)] 45 output_types = [np.int64, np.int64] 46 graph_input_node_names = ["a"] 47 graph_output_node_names = ["a", "b"] 48 executor_name = "" 49 serialized_executor_parameters = b"" 50 default_graph_input_tensor_type_shapes = [[dtypes.int64, [1]]] 51 default_graph_output_tensor_type_shapes = [[dtypes.int64, [1]], 52 [dtypes.int64, [1]]] 53 54 output_nodes = remote_fused_graph_ops.remote_fused_graph_execute( 55 inputs, output_types, graph, graph_input_node_names, 56 graph_output_node_names, executor_name, serialized_executor_parameters, 57 default_graph_input_tensor_type_shapes, 58 default_graph_output_tensor_type_shapes) 59 self.assertEqual(2, len(output_nodes)) 60 for output_node in output_nodes: 61 with self.test_session(use_gpu=False): 62 output_node.eval() 63 64 65if __name__ == "__main__": 66 googletest.main() 67