• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2020 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/c/eager/c_api_remote_test_util.h"
17 #include "tensorflow/core/platform/test.h"
18 
19 namespace {
20 
TestRemoteExecuteSilentCopiesFunc(bool async,bool remote,bool heavy_load_on_streaming_rpc,bool remote_func_outputs=false,bool has_packed_input=false)21 void TestRemoteExecuteSilentCopiesFunc(bool async, bool remote,
22                                        bool heavy_load_on_streaming_rpc,
23                                        bool remote_func_outputs = false,
24                                        bool has_packed_input = false) {
25   return TestRemoteExecuteSilentCopies(async, remote, /*func=*/true,
26                                        heavy_load_on_streaming_rpc,
27                                        remote_func_outputs, has_packed_input);
28 }
29 
TEST(CAPI,RemoteExecuteSilentCopiesAsyncFunc)30 TEST(CAPI, RemoteExecuteSilentCopiesAsyncFunc) {
31   TestRemoteExecuteSilentCopiesFunc(/*async=*/true, /*remote=*/true,
32                                     /*heavy_load_on_streaming_rpc=*/false);
33 }
TEST(CAPI,RemoteExecuteSilentCopiesFuncRemoteOutputs)34 TEST(CAPI, RemoteExecuteSilentCopiesFuncRemoteOutputs) {
35   TestRemoteExecuteSilentCopiesFunc(/*async=*/false, /*remote=*/true,
36                                     /*heavy_load_on_streaming_rpc=*/false,
37                                     /*remote_func_outputs=*/true);
38 }
TEST(CAPI,RemoteExecuteSilentCopiesAsyncFuncRemoteOutputs)39 TEST(CAPI, RemoteExecuteSilentCopiesAsyncFuncRemoteOutputs) {
40   TestRemoteExecuteSilentCopiesFunc(/*async=*/true, /*remote=*/true,
41                                     /*heavy_load_on_streaming_rpc=*/false,
42                                     /*remote_func_outputs=*/true);
43 }
TEST(CAPI,RemoteExecuteSilentCopiesLocalAsyncFunc)44 TEST(CAPI, RemoteExecuteSilentCopiesLocalAsyncFunc) {
45   TestRemoteExecuteSilentCopiesFunc(/*async=*/true, /*remote=*/false,
46                                     /*heavy_load_on_streaming_rpc=*/false);
47 }
TEST(CAPI,RemoteExecuteSilentCopiesLocalFuncRemoteOutputs)48 TEST(CAPI, RemoteExecuteSilentCopiesLocalFuncRemoteOutputs) {
49   TestRemoteExecuteSilentCopiesFunc(/*async=*/false, /*remote=*/false,
50                                     /*heavy_load_on_streaming_rpc=*/false,
51                                     /*remote_func_outputs=*/true);
52 }
TEST(CAPI,RemoteExecuteSilentCopiesLocalAsyncFuncRemoteOutputs)53 TEST(CAPI, RemoteExecuteSilentCopiesLocalAsyncFuncRemoteOutputs) {
54   TestRemoteExecuteSilentCopiesFunc(/*async=*/true, /*remote=*/false,
55                                     /*heavy_load_on_streaming_rpc=*/false,
56                                     /*remote_func_outputs=*/true);
57 }
TEST(CAPI,RemoteExecuteSilentCopiesLocalAsyncFuncOrdering)58 TEST(CAPI, RemoteExecuteSilentCopiesLocalAsyncFuncOrdering) {
59   // A remote input may be not ready when we start running a function. Test that
60   // the function execution should wait until the remote input is ready.
61   TestRemoteExecuteSilentCopiesFunc(/*async=*/true, /*remote=*/false,
62                                     /*heavy_load_on_streaming_rpc=*/true);
63 }
TEST(CAPI,RemoteExecuteSilentCopiesRemoteAsyncPackedInputFuncOrdering)64 TEST(CAPI, RemoteExecuteSilentCopiesRemoteAsyncPackedInputFuncOrdering) {
65   // A remote input (packed) may be not ready when we start running a function.
66   // Test that the function execution should wait until the remote input is
67   // ready.
68   TestRemoteExecuteSilentCopiesFunc(/*async=*/true, /*remote=*/true,
69                                     /*heavy_load_on_streaming_rpc=*/true,
70                                     /*remote_func_outputs*/ true,
71                                     /*has_packed_input=*/true);
72 }
73 
74 }  // namespace
75