Commit 4dac3a18 authored by Robert Kimball's avatar Robert Kimball Committed by GitHub

Merge pull request #17 from NervanaSystems/12_useful_dev_env

Fixes #12.  Adds useful development environment.
parents 2942a32a b95bf86d
......@@ -11,83 +11,35 @@
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required (VERSION 2.8.11)
# cmake_policy(SET CMP0037 OLD)
# cmake_policy(SET CMP0042 OLD)
# We require version 2.8.12 only because that's the lowest version of CMake on which
# we've validate this repository.
cmake_minimum_required (VERSION 2.8.12)
cmake_policy(VERSION 2.8.12)
# Set this flag before project definition to avoid using other compiler by gtest
set(CMAKE_CXX_COMPILER "clang++")
project (ngraph
LANGUAGES CXX
)
project (ngraph)
set(NGRAPH_VERSION 1.0.0)
set(NGRAPH_VERSION 0.1)
# These variables are undocumented but useful.
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
# set directory where the custom finders live
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_CXX_FLAGS "-O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=inconsistent-missing-override")
# whitelist errors here
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat-pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-padded")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-global-constructors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch-enum")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-zero-variadic-macro-arguments")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undef")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-exit-time-destructors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-prototypes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-disabled-macro-expansion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-documentation")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-covered-switch-default")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-old-style-cast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option")
# should remove these
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-float-equal")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-duplicate-enum") # from numpy
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-used-but-marked-unused") # from sox
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++11-compat-deprecated-writable-strings")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-double-promotion")
set(Python_ADDITIONAL_VERSIONS 3.6 3.5 3.4)
find_package(PythonLibs)
find_package(PythonInterp)
if (PYTHONLIBS_FOUND)
find_package(NumPy)
if(NUMPY_FOUND)
set(PYTHON_FOUND true)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPYTHON_FOUND")
include_directories(SYSTEM ${PYTHON_INCLUDE_DIR})
include_directories(SYSTEM ${NUMPY_INCLUDE_DIRS})
else()
message("Numpy not found, Python interface not included")
endif(NUMPY_FOUND)
else()
message("Python not found, Python interface not included")
set(PYTHON_LIBRARIES "")
endif (PYTHONLIBS_FOUND)
set(TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test/test_data)
# The following 'add_subdirectory' call:
# - defines the 'libgtest' target.
# - defines the 'GTEST_INCLUDE_DIR' cmake variable.
add_subdirectory(third-party)
# The following 'add_subdirectory' call:
# - defines the 'ngraph' library target.
# - defines the 'NGRAPH_INCLUDE_DIR' cmake variable.
# - defines the 'NGRAPH_VERSION' cmake variable.
# - install-related targets.
add_subdirectory(src)
include_directories(src src/transformers)
add_subdirectory(test)
# Overview
TODO
# Building `libngraph`
## Build Environments
| Operating System | Compiler | Status | Additional packages required |
| --------------------------- | -------- | --------- | --------------------------------- |
| Ubuntu 14.04.5 (LTS) 64-bit | CLang 3.9 | supported | `build-essential cmake clang-3.9` |
## Steps
`libngraph` is build in the customary manner for a CMake-based project:
1. Create a build directory outside of source directory tree.
2. `cd` to the build directory.
3. Run CMake. For example, `cmake ../private-ngraph-cpp -DCMAKE_CXX_COMPILER=clang++-3.9`
4. Run `make`.
# Testing `libngraph`
`libngraph` uses the GTest framework for unit tests. CMake automatically downloads a
copy of the required GTest files when configuring the build directory.
To perform the unit tests
1. Configure the build directory as described above.
2. Change directory to the build directory.
3. Run `make check`
# Using `libngraph`
## System Requirements
TBD
## External library requirements
TBD
# Maintaining `libngraph`
## Code formatting
All C/C++ source code in the `libngraph` repository, including the test code when practical,
should adhere to the project's source-code formatting guidelines.
The script `maint/apply-code-format.sh` enforces that formatting at the C/C++ syntactic level.
The script `maint/check-code-format.sh` verifies that the formatting rules are met by all C/C++
code (again, at the syntax level.) The script has an exit code of 0 when this all code meets
the standard, and non-zero otherwise. This script does _not_ modify the source code.
find_program(BREATHE_EXECUTABLE
NAMES breathe-apidoc
DOC "Path to breathe executable")
# Handle REQUIRED and QUIET arguments
# this will also set SPHINX_FOUND to true if SPHINX_EXECUTABLE exists
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Breathe
"Failed to locate breathe executable"
BREATHE_EXECUTABLE)
if(NOT PYTHON_EXECUTABLE)
if(NumPy_FIND_QUIETLY)
find_package(PythonInterp QUIET)
else()
find_package(PythonInterp)
endif()
endif()
if(PYTHON_EXECUTABLE)
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
"import numpy as n; print(n.get_include());"
RESULT_VARIABLE NUMPY_RESULT
OUTPUT_VARIABLE NUMPY_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NUMPY_RESULT MATCHES 0)
set(NUMPY_FOUND true)
set(NUMPY_LIBRARIES "")
set(NUMPY_DEFINITIONS "")
endif(NUMPY_RESULT MATCHES 0)
endif(PYTHON_EXECUTABLE)
# CMake find_package() Module for Sphinx documentation generator
# http://sphinx-doc.org/
#
# Example usage:
#
# find_package(Sphinx)
#
# If successful the following variables will be defined
# SPHINX_FOUND
# SPHINX_EXECUTABLE
find_program(SPHINX_EXECUTABLE
NAMES sphinx-build sphinx-build2
DOC "Path to sphinx-build executable")
# Handle REQUIRED and QUIET arguments
# this will also set SPHINX_FOUND to true if SPHINX_EXECUTABLE exists
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sphinx
"Failed to locate sphinx-build executable"
SPHINX_EXECUTABLE)
# Provide options for controlling different types of output
option(SPHINX_OUTPUT_HTML "Output standalone HTML files" ON)
option(SPHINX_OUTPUT_MAN "Output man pages" ON)
option(SPHINX_WARNINGS_AS_ERRORS "When building documentation treat warnings as errors" ON)
\ No newline at end of file
# Copyright 2017 Nervana Systems Inc.
# 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.
SET(NGRAPH_CXX_WARNING_FLAGS
"-Werror=return-type"
"-Werror=inconsistent-missing-override"
"-Weverything"
"-Wno-c++98-compat"
"-Wno-c++98-compat-pedantic"
"-Wno-padded"
"-Wno-weak-vtables"
"-Wno-global-constructors"
"-Wno-switch-enum"
"-Wno-gnu-zero-variadic-macro-arguments"
"-Wno-undef"
"-Wno-exit-time-destructors"
"-Wno-missing-prototypes"
"-Wno-disabled-macro-expansion"
"-Wno-pedantic"
"-Wno-documentation"
"-Wno-covered-switch-default"
"-Wno-old-style-cast"
"-Wno-unknown-warning-option"
"-Wno-sign-conversion"
"-Wno-sign-compare"
"-Wno-unused-parameter"
"-Wno-conversion"
"-Wno-float-equal"
"-Wno-duplicate-enum"
"-Wno-used-but-marked-unused"
"-Wno-c++11-compat-deprecated-writable-strings"
"-Wno-deprecated"
"-Wno-double-promotion"
)
# Copyright 2017 Nervana Systems Inc.
# 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.
# Enable ExternalProject CMake module
include(ExternalProject)
# Download and install GoogleTest
ExternalProject_Add(
gtest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.8.0
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest-build/googlemock/gtest/libgtest.a"
)
# Get GTest source and binary directories from CMake project
ExternalProject_Get_Property(gtest source_dir binary_dir)
get_filename_component(
GTEST_INCLUDE_DIR
"${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest/googletest/include"
ABSOLUTE)
set(GTEST_INCLUDE_DIR "${GTEST_INCLUDE_DIR}" PARENT_SCOPE)
# Create a libgtest target to be used as a dependency by test programs
add_library(libgtest IMPORTED STATIC GLOBAL)
add_dependencies(libgtest gtest)
# Set libgtest properties
set_target_properties(libgtest PROPERTIES
"IMPORTED_LOCATION" "${binary_dir}/googlemock/gtest/libgtest.a"
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
)
#!/bin/bash
set -e
set -u
# Copyright 2017 Nervana Systems Inc.
# 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.
# NOTE: The results of `clang-format` depend _both_ of the following factors:
# - The `.clang-format` file, and
# - The particular version of the `clang-format` program being used.
#
# For this reason, this script specifies the exact version of clang-format to be used.
declare CLANG_FORMAT_BASENAME="clang-format-3.9"
declare THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
declare CLANG_FORMAT_PROG
if ! CLANG_FORMAT_PROG="$(which "${CLANG_FORMAT_BASENAME}")"; then
echo "Unable to find program ${CLANG_FORMAT_BASENAME}" >&2
exit 1
fi
pushd "${THIS_SCRIPT_DIR}/.."
declare ROOT_SUBDIR
for ROOT_SUBDIR in src test; do
if ! [[ -d "${ROOT_SUBDIR}" ]]; then
echo "In directory '$(pwd)', no subdirectory named '${ROOT_SUBDIR}' was found." >&2
exit 1
fi
echo "About to format C/C++ code in directory tree '$(pwd)/${ROOT_SUBDIR}' ..."
find "${ROOT_SUBDIR}" -name '*.cpp' -or -name '*.hpp' | xargs "${CLANG_FORMAT_PROG}" -i -style=file
echo "Done."
done
popd
#!/bin/bash
set -e
set -u
# Copyright 2017 Nervana Systems Inc.
# 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.
# NOTE: The results of `clang-format` depend _both_ of the following factors:
# - The `.clang-format` file, and
# - The particular version of the `clang-format` program being used.
#
# For this reason, this script specifies the exact version of clang-format to be used.
declare CLANG_FORMAT_BASENAME="clang-format-3.9"
declare THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
declare CLANG_FORMAT_PROG
if ! CLANG_FORMAT_PROG="$(which "${CLANG_FORMAT_BASENAME}")"; then
echo "Unable to find program ${CLANG_FORMAT_BASENAME}" >&2
exit 1
fi
declare -a FAILED_FILES=()
declare NUM_FILES_CHECKED=0
pushd "${THIS_SCRIPT_DIR}/.."
declare ROOT_SUBDIR
for ROOT_SUBDIR in src test; do
if ! [[ -d "${ROOT_SUBDIR}" ]]; then
echo "In directory '$(pwd)', no subdirectory named '${ROOT_SUBDIR}' was found." >&2
exit 1
fi
echo "About to format C/C++ code in directory tree '$(pwd)/${ROOT_SUBDIR}' ..."
declare SRC_FILE
for SRC_FILE in $(find "${ROOT_SUBDIR}" -name '*.cpp' -or -name '*.hpp'); do
if "${CLANG_FORMAT_PROG}" -style=file -output-replacements-xml "${SRC_FILE}" | grep -c "<replacement " >/dev/null; then
FAILED_FILES+=( "${SRC_FILE}" )
fi
NUM_FILES_CHECKED=$((NUM_FILES_CHECKED+1))
done
done
popd
if [[ ${#FAILED_FILES[@]} -eq 0 ]]; then
echo "All ${NUM_FILES_CHECKED} C/C++ files pass the code-format check."
exit 0
else
echo "${#FAILED_FILES[@]} of ${NUM_FILES_CHECKED} source files failed the code-format check:"
declare FAILED_SRC_FILE
for FAILED_SRC_FILE in ${FAILED_FILES[@]}; do
echo " ${FAILED_SRC_FILE}"
done
exit 1
fi
# Copyright 2017 Nervana Systems Inc.
# 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.
#-----------------------------------------------------------------------------------------------
# Compiler-specific logic...
#-----------------------------------------------------------------------------------------------
# Default values...
set(NGRAPH_CXX_WARNING_FLAGS "")
# Compiler-specific logic...
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
include( ../cmake/clang_4_0_flags.cmake )
else()
message(WARNING "CMAKE_CXX_COMPILER_ID='${CMAKE_CXX_COMPILER_ID}'. CMAKE_CXX_COMPILER='${CMAKE_CXX_COMPILER}'. The only supported compiler is 'clang', but the selected compiler is '${CMAKE_CXX_COMPILER}'.")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
FOREACH(F IN LISTS NGRAPH_CXX_WARNING_FLAGS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${F}")
ENDFOREACH()
#-----------------------------------------------------------------------------------------------
get_filename_component( NGRAPH_INCLUDE_DIR . ABSOLUTE)
set(NGRAPH_INCLUDE_DIR "${NGRAPH_INCLUDE_DIR}" PARENT_SCOPE)
set (SRC
util.cpp
transformers/exop.cpp
transformers/op_graph.cpp
transformers/axes.cpp
transformers/mock_transformer.cpp
element_type.cpp
names.cpp
transformers/ndarray.cpp
strides.cpp
tree.cpp
util.cpp
transformers/axes.cpp
transformers/exop.cpp
transformers/mock_transformer.cpp
transformers/ndarray.cpp
transformers/op_graph.cpp
)
# file(GLOB DEPLOY_HEADERS_ABS *.hpp)
# foreach(DEPLOY_HEADER ${DEPLOY_HEADERS_ABS})
# get_filename_component(FNAME ${DEPLOY_HEADER} NAME)
# set(DEPLOY_HEADERS ${DEPLOY_HEADERS} ${FNAME})
# endforeach()
# NOTE: We'd prefer to only have the .cpp files *in* the 'transformers' directory be compiled
# with the 'transformers' directory in the include-path. But it's hard to do that with
# CMake versions lower than 3.1: see
# https://stackoverflow.com/questions/9339851/can-one-add-further-source-files-to-an-executable-once-defined
include_directories(
"${NGRAPH_INCLUDE_DIR}"
"${NGRAPH_INCLUDE_DIR}/transformers"
)
add_library(ngraph SHARED ${SRC})
# if (PYTHON_FOUND)
# set(SRC ${SRC} api.cpp)
# endif(PYTHON_FOUND)
#-----------------------------------------------------------------------------------------------
# Installation logic...
#-----------------------------------------------------------------------------------------------
# set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in")
# set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/../setup.py")
# configure_file(${SETUP_PY_IN} ${SETUP_PY})
set(DEPLOY_SRC_HEADERS
element_type.hpp
names.hpp
strides.hpp
tree.hpp
util.hpp
uuid.hpp
)
include_directories(.)
add_library(ngraph SHARED ${SRC})
set(DEPLOY_SRC_TRANSFORMERS_HEADERS
transformers/axes.hpp
transformers/exop.hpp
transformers/mock.hpp
transformers/mock_transformer.hpp
transformers/ndarray.hpp
transformers/op_graph.hpp
)
install(TARGETS ngraph DESTINATION lib)
install(FILES ${DEPLOY_SRC_HEADERS} DESTINATION include/ngraph)
install(FILES ${DEPLOY_SRC_TRANSFORMERS_HEADERS} DESTINATION include/ngraph/transformers)
# install(TARGETS aeon DESTINATION lib)
# install(FILES ${DEPLOY_HEADERS} DESTINATION include/aeon)
\ No newline at end of file
import ngraph as ng
C, H, N = ng.make_axis(5), ng.make_axis(3), ng.make_axis(7)
a = ng.Axes(axes=[C, H, N])
b = ng.Axes(axes=[[C, H], N])
print('a={}'.format(a))
print('b={}'.format(b))
print('a[0]={}'.format(a[0]))
print('a[1]={}'.format(a[1]))
print('a[2]={}'.format(a[2]))
print('b[0]={}'.format(b[0]))
print('b[1]={}'.format(b[1]))
print('as_nested_list(a)={}'.format(ng.Axes.as_nested_list(a)))
print('as_flattened_list(a)={}'.format(ng.Axes.as_flattened_list(a)))
print('as_nested_list(b)={}'.format(ng.Axes.as_nested_list(b)))
print('as_flattened_list(b)={}'.format(ng.Axes.as_flattened_list(b)))
......@@ -1254,7 +1254,9 @@ axes_key_t TensorDescription::axes_key() const
// hash_list.push_back(hash_combine(shape));
hash_list.push_back(dtype.hash());
hash_list.push_back(offset_hash(offset));
#warning("add strides and layout to hash")
// TODO: add strides and layout to hash
// def axes_key(self):
// return (self.axes, self.shape, self.dtype, self.offset, self.strides, self.layout)
......
......@@ -11,35 +11,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Enable ExternalProject CMake module
include(ExternalProject)
include_directories(
SYSTEM
"${GTEST_INCLUDE_DIR}"
)
# Download and install GoogleTest
ExternalProject_Add(
gtest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.8.0
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
)
# Get GTest source and binary directories from CMake project
ExternalProject_Get_Property(gtest source_dir binary_dir)
# Create a libgtest target to be used as a dependency by test programs
add_library(libgtest IMPORTED STATIC GLOBAL)
add_dependencies(libgtest gtest)
include_directories(
"${NGRAPH_INCLUDE_DIR}"
)
# Set libgtest properties
set_target_properties(libgtest PROPERTIES
"IMPORTED_LOCATION" "${binary_dir}/googlemock/gtest/libgtest.a"
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
)
# I couldn't make it work with INTERFACE_INCLUDE_DIRECTORIES
include_directories(SYSTEM "${source_dir}/googletest/include")
set (SRC
main.cpp
util.cpp
......@@ -53,12 +33,14 @@ set (SRC
strides.cpp
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCURDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\"")
add_executable(test ${SRC})
target_link_libraries(test ngraph pthread libgtest)
add_dependencies(test ngraph libgtest)
add_executable(unit-test ${SRC})
target_link_libraries(unit-test ngraph pthread libgtest)
add_dependencies(unit-test ngraph libgtest)
add_custom_target(check
COMMAND ${PROJECT_BINARY_DIR}/test/unit-test
DEPENDS unit-test)
add_custom_target(runtest
COMMAND ${PROJECT_BINARY_DIR}/test/test
DEPENDS test)
......@@ -19,8 +19,8 @@
#include "gtest/gtest.h"
#include "axes.hpp"
#include "ndarray.hpp"
#include "transformers/axes.hpp"
#include "transformers/ndarray.hpp"
using namespace std;
......
......@@ -18,9 +18,9 @@
#include "gtest/gtest.h"
#include "exop.hpp"
#include "mock.hpp"
#include "mock_transformer.hpp"
#include "transformers/exop.hpp"
#include "transformers/mock.hpp"
#include "transformers/mock_transformer.hpp"
TEST(exop, create)
{
......
......@@ -18,7 +18,7 @@
#include "gtest/gtest.h"
#include "op_graph.hpp"
#include "transformers/op_graph.hpp"
TEST(op, constant)
{
......
......@@ -18,7 +18,7 @@
#include "gtest/gtest.h"
#include "op_graph.hpp"
#include "transformers/op_graph.hpp"
TEST(op_graph, constant)
{
......
# Copyright 2017 Nervana Systems Inc.
# 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( ../cmake/external_gtest.cmake )
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