/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace tvm; using namespace tvm::relay; TEST(Relay, LargeGraphPrint) { auto foo = [] { auto add_op = relay::Op::Get("add"); auto c_data = tvm::runtime::NDArray::Empty({1, 2, 3}, {kDLFloat, 32, 1}, {kDLCPU, 0}); auto c1 = relay::Constant(c_data); Call y1 = relay::Call(add_op, {c1, c1}); for (int i = 0; i < 1e6; i++) { y1 = relay::Call(add_op, {c1, y1}); } relay::Function func = relay::Function({}, y1, relay::Type(), {}); std::string result = AsText(func); ASSERT_GT(0, result.size()); }; ASSERT_EXIT((foo(), exit(0)), ::testing::ExitedWithCode(0), ".*"); }