Commit 87b5baa1 authored by Sang Ik Lee's avatar Sang Ik Lee Committed by Scott Cyphers

Add Fluid test. (#3987)

* Add FLuid test.

* Fix typo.

* Fix Typo.
parent bc23562a
......@@ -26,5 +26,8 @@ NORMALIZE_BOOL(NGRAPH_FLUID_ENABLE)
message(STATUS "NGRAPH_FLUID_ENABLE: ${NGRAPH_FLUID_ENABLE}")
if (NGRAPH_FLUID_ENABLE)
option(NGRAPH_FLUID_TEST_ENABLE "Enable PaddlePaddle Fluid operator tests" OFF)
NORMALIZE_BOOL(NGRAPH_FLUID_TEST_ENABLE)
message(STATUS "NGRAPH_FLUID_TEST_ENABLE: ${NGRAPH_FLUID_TEST_ENABLE}")
add_subdirectory(fluid)
endif()
......@@ -19,3 +19,7 @@ target_sources (ngraph PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/operators/reduce_sum.cpp
${CMAKE_CURRENT_SOURCE_DIR}/operators/reduce_sum.hpp
)
if (NGRAPH_FLUID_TEST_ENABLE)
add_subdirectory(operators/test)
endif()
# ******************************************************************************
# Copyright 2017-2019 Intel Corporation
#
# Licensed 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.
# ******************************************************************************
if(NOT NGRAPH_FLUID_TEST_ENABLE)
message(STATUS "Fluid tests disabled")
return()
endif()
if(NOT NGRAPH_CPU_ENABLE)
message(STATUS "Fluid tests needs CPU enabled")
return()
endif()
message(STATUS "fluid tests enabled")
if(LINUX)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.0.0")
# gtest has issues with this with v1.8.x
# gtest issue is supposed to be addressed after v1.8.x
add_compile_options(-Wno-zero-as-null-pointer-constant)
endif()
endif()
set(SRC
main.cpp
reduce_sum.cpp
)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../../../../../test)
add_executable(fluid-test ${SRC})
target_include_directories(fluid-test PRIVATE "../../../../../../test")
target_link_libraries(fluid-test PRIVATE ngraph_test_util)
target_link_libraries(fluid-test PRIVATE ngraph libgtest)
if(NOT WIN32)
target_link_libraries(fluid-test PRIVATE pthread)
endif()
target_link_libraries(fluid-test PRIVATE ${CMAKE_DL_LIBS})
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(Apple)?Clang$")
target_compile_options(fluid-test PRIVATE -Wno-undef -Wno-reserved-id-macro)
endif()
# So many type_prop tests these days that we need to set /bigobj flag for MSVC.
# We should probably split up type_prop.cpp.
if (MSVC)
target_compile_options(fluid-test PRIVATE "/bigobj")
endif()
# The INTERPRETER backend is required for convolution, and backwards unit tests
target_link_libraries(fluid-test PRIVATE cpu_backend)
target_link_libraries(fluid-test PRIVATE libmkldnn)
target_compile_definitions(fluid-test PRIVATE NGRAPH_CPU_ENABLE)
if (NGRAPH_TBB_ENABLE)
target_compile_definitions(fluid-test PRIVATE "NGRAPH_TBB_ENABLE")
endif()
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed 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 <chrono>
#include <iostream>
#undef IN_NGRAPH_LIBRARY
#include "gtest/gtest.h"
#include "ngraph/log.hpp"
#include "ngraph/ngraph.hpp"
#include "ngraph/runtime/backend.hpp"
#include "ngraph/runtime/backend_manager.hpp"
using namespace std;
int main(int argc, char** argv)
{
const string cpath_flag{"--cpath"};
string cpath;
const char* exclude = "--gtest_filter=-benchmark.*";
vector<char*> argv_vector;
argv_vector.push_back(argv[0]);
argv_vector.push_back(const_cast<char*>(exclude));
for (int i = 1; i < argc; i++)
{
argv_vector.push_back(argv[i]);
}
argc = argv_vector.size();
::testing::InitGoogleTest(&argc, argv_vector.data());
for (int i = 1; i < argc; i++)
{
if (cpath_flag == argv[i] && (++i) < argc)
{
cpath = argv[i];
}
}
ngraph::runtime::Backend::set_backend_shared_library_search_directory(cpath);
#ifdef NGRAPH_CPU_ENABLE
ngraph_register_cpu_backend();
#endif
auto start = std::chrono::system_clock::now();
int rc = RUN_ALL_TESTS();
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now() - start);
NGRAPH_DEBUG_PRINT("[MAIN] Tests finished: Time: %d ms Exit code: %d", elapsed.count(), rc);
return rc;
}
This diff is collapsed.
# Add test names to disable
# This does not work for now
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment