Unverified Commit 14cac0dd authored by Sang Ik Lee's avatar Sang Ik Lee Committed by GitHub

Add basic build files for ATen helpers (#4255)

* Add folder to keep helper classes for PyTorch.

* Add basic build structure.

* Disable ATen support by default.

* Style.
parent 9f1afc65
# ******************************************************************************
# Copyright 2017-2020 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.
# ******************************************************************************
# Add files here
if (NGRAPH_ATEN_TEST_ENABLE)
add_subdirectory(operators/test)
endif()
# ******************************************************************************
# Copyright 2017-2020 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_ATEN_TEST_ENABLE)
message(STATUS "ATen tests disabled")
return()
endif()
if(NOT NGRAPH_CPU_ENABLE)
message(STATUS "ATen tests needs CPU enabled")
return()
endif()
if(NOT NGRAPH_TEST_UTIL_ENABLE)
message(WARNING "ATen test: Turning on test util!")
set(NGRAPH_TEST_UTIL_ENABLE ON)
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
dummy.cpp
)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../../../../../test)
add_executable(ATen-test ${SRC})
target_include_directories(ATen-test PRIVATE "../../../../../../test")
target_link_libraries(ATen-test PRIVATE ngraph_test_util)
target_link_libraries(ATen-test PRIVATE ngraph libgtest)
if(NOT WIN32)
target_link_libraries(ATen-test PRIVATE pthread)
endif()
target_link_libraries(ATen-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(ATen-test PRIVATE "/bigobj")
endif()
# The INTERPRETER backend is required for convolution, and backwards unit tests
target_link_libraries(ATen-test PRIVATE cpu_backend)
target_link_libraries(ATen-test PRIVATE libmkldnn)
target_compile_definitions(ATen-test PRIVATE NGRAPH_CPU_ENABLE)
if (NGRAPH_TBB_ENABLE)
target_compile_definitions(ATen-test PRIVATE "NGRAPH_TBB_ENABLE")
endif()
//*****************************************************************************
// Copyright 2017-2020 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 <algorithm>
#include <cinttypes>
#include <cmath>
#include <cstdlib>
#include <random>
#include <string>
#undef IN_NGRAPH_LIBRARY
#include "gtest/gtest.h"
#include "ngraph/ngraph.hpp"
#include "util/all_close.hpp"
#include "util/all_close_f.hpp"
#include "util/ndarray.hpp"
#include "util/random.hpp"
#include "util/test_control.hpp"
#include "util/test_tools.hpp"
static std::mt19937_64 random_generator;
using namespace std;
using namespace ngraph;
static string s_manifest = "test.manifest";
NGRAPH_TEST(CPU, dummy)
{
ASSERT_TRUE(true);
}
//*****************************************************************************
// Copyright 2017-2020 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;
}
# Add test names to disable
# This does not work for now
......@@ -28,3 +28,14 @@ if (NGRAPH_FLUID_ENABLE)
message(STATUS "NGRAPH_FLUID_TEST_ENABLE: ${NGRAPH_FLUID_TEST_ENABLE}")
add_subdirectory(fluid)
endif()
option(NGRAPH_ATEN_ENABLE "Enable build for PyTorch ATen support" OFF)
NORMALIZE_BOOL(NGRAPH_ATEN_ENABLE)
message(STATUS "NGRAPH_ATEN_ENABLE: ${NGRAPH_ATEN_ENABLE}")
if (NGRAPH_ATEN_ENABLE)
option(NGRAPH_ATEN_TEST_ENABLE "Enable PaddlePaddle Fluid operator tests" OFF)
NORMALIZE_BOOL(NGRAPH_ATEN_TEST_ENABLE)
message(STATUS "NGRAPH_ATEN_TEST_ENABLE: ${NGRAPH_ATEN_TEST_ENABLE}")
add_subdirectory(ATen)
endif()
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