Commit 93a5cf92 authored by Robert Kimball's avatar Robert Kimball Committed by Scott Cyphers

Move backend specific unit tests to test/backend directory (#1775)

* move backend specific test files to test/backend directory

* remove unit_test_control

* move tests back to test root

* fix comment

* wip

* fix manifest
parent c579e245
......@@ -196,25 +196,8 @@ if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
endif()
include(unit_test_control)
set(UNIT_TEST_CONFIG_LIST "" CACHE INTERNAL "")
if (NGRAPH_INTERPRETER_ENABLE)
unit_test_control(BACKEND INTERPRETER MANIFEST src/ngraph/runtime/interpreter/unit_test.manifest)
endif()
# Set true if CPU backend is built by default
if (NGRAPH_CPU_ENABLE)
unit_test_control(BACKEND CPU MANIFEST src/ngraph/runtime/cpu/unit_test.manifest)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNGRAPH_CPU_ENABLE")
endif()
if (NGRAPH_INTELGPU_ENABLE)
unit_test_control(BACKEND INTELGPU MANIFEST src/ngraph/runtime/intelgpu/unit_test.manifest)
endif()
if (NGRAPH_GPU_ENABLE)
unit_test_control(BACKEND GPU MANIFEST src/ngraph/runtime/gpu/unit_test.manifest)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNGRAPH_CPU_ENABLE")
endif()
if (NOT DEFINED NGRAPH_TBB_ENABLE)
......
# ******************************************************************************
# Copyright 2017-2018 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.
# ******************************************************************************
function(UNIT_TEST_CONTROL)
set(options)
set(oneValueArgs BACKEND MANIFEST)
set(multiValueArgs)
cmake_parse_arguments(UNIT_TEST_CONTROL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (UNIT_TEST_CONTROL_MANIFEST)
get_filename_component(UNIT_TEST_CONTROL_MANIFEST ${UNIT_TEST_CONTROL_MANIFEST} ABSOLUTE)
set(CONFIG_STRING "${UNIT_TEST_CONTROL_BACKEND}@${UNIT_TEST_CONTROL_MANIFEST}")
else()
set(CONFIG_STRING "${UNIT_TEST_CONTROL_BACKEND}@")
endif()
set(UNIT_TEST_CONFIG_LIST "${UNIT_TEST_CONFIG_LIST};${CONFIG_STRING}" CACHE INTERNAL "")
endfunction()
......@@ -62,39 +62,44 @@ endif()
if (NGRAPH_INTERPRETER_ENABLE)
set(SRC ${SRC} backend_debug_api.cpp builder.cpp backend_api.cpp)
set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} INTERPRETER)
endif()
if (NGRAPH_CPU_ENABLE)
set(SRC ${SRC} core_fusion.cpp quantize_cpu.cpp)
endif()
add_subdirectory(models)
add_subdirectory(files)
add_subdirectory(util)
if(NGRAPH_CPU_ENABLE)
set(SRC ${SRC} backend_performance.cpp cpu_fusion.cpp cpu_test.cpp cpu_reshape_sinking.cpp)
set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} CPU)
endif()
if(NGRAPH_GPU_ENABLE)
set(SRC ${SRC} cudnn.cpp gpu_test.cpp gpu_fusion.cpp)
set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} GPU)
endif()
foreach(TEST_CONFIG ${UNIT_TEST_CONFIG_LIST})
string(FIND ${TEST_CONFIG} "@" OFFSET)
string(SUBSTRING ${TEST_CONFIG} 0 ${OFFSET} BACKEND_NAME)
math(EXPR OFFSET ${OFFSET}+1)
string(SUBSTRING ${TEST_CONFIG} ${OFFSET} -1 MANIFEST)
configure_file(backend_test.in.cpp backend_test_${BACKEND_NAME}.cpp)
configure_file(convolution_test.in.cpp convolution_test_${BACKEND_NAME}.cpp)
set(SRC ${CMAKE_CURRENT_BINARY_DIR}/backend_test_${BACKEND_NAME}.cpp ${SRC})
set(SRC ${CMAKE_CURRENT_BINARY_DIR}/convolution_test_${BACKEND_NAME}.cpp ${SRC})
if(NGRAPH_DISTRIBUTED_ENABLE)
configure_file(distributed.cpp distributed_${BACKEND_NAME}.cpp)
set(SRC ${CMAKE_CURRENT_BINARY_DIR}/distributed_${BACKEND_NAME}.cpp ${SRC})
endif()
# if (NGRAPH_INTELGPU_ENABLE)
# set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} INTELGPU)
# endif()
add_subdirectory(models)
add_subdirectory(files)
add_subdirectory(util)
# backend specific test files must meet the following requirements:
# 1) The must be named <name>.in.cpp
# 2) They must be in the test directory
# 3) add the line `static string s_manifest = "${MANIFEST}";` to your cpp file
# All such files are configured via cmake which replaces all instances of cmake variables
# such as ${BACKEND_NAME} with their values, such as CPU, GPU, or INTERPRETER.
set(MULTI_TEST_SRC
autodiff.in.cpp
backend_test.in.cpp
convolution_test.in.cpp
)
if(NGRAPH_DISTRIBUTED_ENABLE)
set(MULTI_TEST_SRC ${MULTI_TEST_SRC} distributed.in.cpp)
endif()
foreach(BACKEND_NAME ${ACTIVE_BACKEND_LIST})
# Some---but not all---autodiff tests go through multiple iterations with
# different random seeds. On the CPU backend this is currently very slow
# because the autodiff tests recompile with each iteration. That behavior
......@@ -106,8 +111,14 @@ foreach(TEST_CONFIG ${UNIT_TEST_CONFIG_LIST})
set(TEST_LOOPS 2)
endif()
configure_file(autodiff.in.cpp autodiff_${BACKEND_NAME}.cpp)
set(SRC ${CMAKE_CURRENT_BINARY_DIR}/autodiff_${BACKEND_NAME}.cpp ${SRC})
string(TOLOWER ${BACKEND_NAME} BACKEND_DIR)
set(MANIFEST ${PROJECT_SOURCE_DIR}/src/ngraph/runtime/${BACKEND_DIR}/unit_test.manifest)
foreach(TEST_SRC ${MULTI_TEST_SRC})
string(REPLACE ".in." "_${BACKEND_NAME}." TARGET_NAME ${TEST_SRC})
configure_file(${TEST_SRC} ${TARGET_NAME})
set(SRC ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME} ${SRC})
endforeach()
message(STATUS "Adding unit test for backend ${BACKEND_NAME}")
endforeach()
......
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