Home | History | Annotate | Download | only in tests
      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 
     16 #include "tensorflow/compiler/xla/tests/client_library_test_base.h"
     17 
     18 namespace xla {
     19 namespace {
     20 TEST_F(ClientLibraryTestBase, DeepGraph) {
     21   // TODO(b/62624812): To trigger the stack overflow this test is
     22   // intended to track, we need to set kDepth to 20000.
     23   // Unfortunately, setting it that high causes the test to time out.
     24   const int kDepth = 200;
     25   ComputationBuilder b(client_, TestName());
     26   ComputationDataHandle x;
     27   ComputationDataHandle y;
     28   auto x_data = CreateR0Parameter<int32>(3, 0, "x", &b, &x);
     29   auto y_data = CreateR0Parameter<int32>(1, 1, "y", &b, &y);
     30   ComputationDataHandle z = x;
     31   for (int i = 0; i < kDepth; ++i) {
     32     z = b.Add(z, y);
     33   }
     34   ComputeAndCompareR0<int32>(&b, /*expected=*/kDepth + 3,
     35                              {x_data.get(), y_data.get()});
     36 }
     37 }  // namespace
     38 }  // namespace xla
     39