<commit_before>cmake_minimum_required(VERSION 2.8.7)

project(mxnet C CXX)

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)

include(cmake/Utils.cmake)
mxnet_option(USE_OPENCV  "Build with OpenCV support" ON)
mxnet_option(USE_OPENMP  "Build with Openmp support" ON)
mxnet_option(USE_CUDNN   "Build with cudnn support"  ON) # one could set CUDNN_ROOT for search path
mxnet_option(USE_CUDA    "Build with CUDA support"   ON)
mxnet_option(USE_DIST_KVSTORE    "Build with DIST_KVSTORE support"   OFF)

SET(EXTRA_OPERATORS "" CACHE PATH "EXTRA OPERATORS PATH")


include(mshadow/cmake/mshadow.cmake)
include(mshadow/cmake/Utils.cmake)
include(mshadow/cmake/Cuda.cmake)

include_directories("include")
include_directories("mshadow")
include_directories("dmlc-core/include")

if(MSVC)
  add_definitions(-DDMLC_USE_CXX11)
  add_definitions(-DMSHADOW_IN_CXX11)
  add_definitions(-D_SCL_SECURE_NO_WARNINGS)
  add_definitions(-D_CRT_SECURE_NO_WARNINGS)
  add_definitions(-DMXNET_EXPORTS)
  set(CMAKE_C_FLAGS "/MP")
  set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
else(MSVC)
  include(CheckCXXCompilerFlag)
  check_cxx_compiler_flag("-std=c++11"   SUPPORT_CXX11)
  check_cxx_compiler_flag("-msse2"       SUPPORT_MSSE2)
  set(CMAKE_C_FLAGS "-O3 -Wall -msse2 -Wno-unknown-pragmas -fPIC")
  set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
endif(MSVC)

if(USE_OPENCV)
  find_package(OpenCV QUIET COMPONENTS core highgui imgproc imgcodecs)
  if(NOT OpenCV_FOUND) # if not OpenCV 3.x, then imgcodecs are not found
    find_package(OpenCV REQUIRED COMPONENTS core highgui imgproc)
  endif()
  include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS})
  list(APPEND mshadow_LINKER_LIBS ${OpenCV_LIBS})
  message(STATUS "OpenCV found (${OpenCV_CONFIG_PATH})")
  add_definitions(-DMXNET_USE_OPENCV=1)
else(USE_OPENCV)
  message(STATUS "OpenCV Disabled")
  add_definitions(-DMXNET_USE_OPENCV=0)
endif()

if(USE_OPENMP)
 FIND_PACKAGE( OpenMP REQUIRED)
 if(OPENMP_FOUND)
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
 endif()
endif()

# cudnn detection
if(USE_CUDNN)
  detect_cuDNN()
  if(HAVE_CUDNN)
    add_definitions(-DUSE_CUDNN)
    include_directories(SYSTEM ${CUDNN_INCLUDE})
    list(APPEND mshadow_LINKER_LIBS ${CUDNN_LIBRARY})
	add_definitions(-DMSHADOW_USE_CUDNN=1)
  endif()
endif()

add_subdirectory("dmlc-core")
if(USE_DIST_KVSTORE)
	add_subdirectory("ps-lite")
endif()

mxnet_source_group("Source"   GLOB_RECURSE "src/*.cc")
mxnet_source_group("Source\\Cuda" GLOB_RECURSE "src/*.cu")

FILE(GLOB_RECURSE SOURCE "src/*.cc")
FILE(GLOB_RECURSE cuda "src/*.cu")

if (NOT (EXTRA_OPERATORS STREQUAL ""))
	mxnet_source_group("Extra"   GLOB_RECURSE "${EXTRA_OPERATORS}/*.cc")
	mxnet_source_group("Extra\\Cuda"   GLOB_RECURSE "${EXTRA_OPERATORS}/*.cu")
	FILE(GLOB_RECURSE EXTRA_SRC "${EXTRA_OPERATORS}/*.cc")
	FILE(GLOB_RECURSE EXTRA_CUSRC "${EXTRA_OPERATORS}/*.cu")
	list(APPEND SOURCE ${EXTRA_SRC} ${EXTRA_CUSRC})
endif()

if(MSVC)
  foreach(flag_var
        CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
        CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
    if(${flag_var} MATCHES "/MD")
      string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
    endif(${flag_var} MATCHES "/MD")
  endforeach(flag_var)
endif()

if(USE_CUDA)
  # define preprocessor macro so that we will not include the generated forcelink header
  mshadow_cuda_compile(cuda_objs ${cuda})
  if(MSVC)
    FIND_LIBRARY(CUDA_nvrtc_LIBRARY nvrtc "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64"  "${CUDA_TOOLKIT_ROOT_DIR}/lib/win32")
    list(APPEND mshadow_LINKER_LIBS ${CUDA_nvrtc_LIBRARY})
    set(CUDA_cuda_LIBRARY "${CUDA_nvrtc_LIBRARY}/../cuda.lib")
    list(APPEND mshadow_LINKER_LIBS ${CUDA_cuda_LIBRARY})
  else(MSVC)<commit_msg>update file group in cmake<commit_after>cmake_minimum_required(VERSION 2.8.7)

project(mxnet C CXX)

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)

include(cmake/Utils.cmake)
mxnet_option(USE_OPENCV  "Build with OpenCV support" ON)
mxnet_option(USE_OPENMP  "Build with Openmp support" ON)
mxnet_option(USE_CUDNN   "Build with cudnn support"  ON) # one could set CUDNN_ROOT for search path
mxnet_option(USE_CUDA    "Build with CUDA support"   ON)
mxnet_option(USE_DIST_KVSTORE    "Build with DIST_KVSTORE support"   OFF)

SET(EXTRA_OPERATORS "" CACHE PATH "EXTRA OPERATORS PATH")


include(mshadow/cmake/mshadow.cmake)
include(mshadow/cmake/Utils.cmake)
include(mshadow/cmake/Cuda.cmake)

include_directories("include")
include_directories("mshadow")
include_directories("dmlc-core/include")

if(MSVC)
  add_definitions(-DDMLC_USE_CXX11)
  add_definitions(-DMSHADOW_IN_CXX11)
  add_definitions(-D_SCL_SECURE_NO_WARNINGS)
  add_definitions(-D_CRT_SECURE_NO_WARNINGS)
  add_definitions(-DMXNET_EXPORTS)
  set(CMAKE_C_FLAGS "/MP")
  set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
else(MSVC)
  include(CheckCXXCompilerFlag)
  check_cxx_compiler_flag("-std=c++11"   SUPPORT_CXX11)
  check_cxx_compiler_flag("-msse2"       SUPPORT_MSSE2)
  set(CMAKE_C_FLAGS "-O3 -Wall -msse2 -Wno-unknown-pragmas -fPIC")
  set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
endif(MSVC)

if(USE_OPENCV)
  find_package(OpenCV QUIET COMPONENTS core highgui imgproc imgcodecs)
  if(NOT OpenCV_FOUND) # if not OpenCV 3.x, then imgcodecs are not found
    find_package(OpenCV REQUIRED COMPONENTS core highgui imgproc)
  endif()
  include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS})
  list(APPEND mshadow_LINKER_LIBS ${OpenCV_LIBS})
  message(STATUS "OpenCV found (${OpenCV_CONFIG_PATH})")
  add_definitions(-DMXNET_USE_OPENCV=1)
else(USE_OPENCV)
  message(STATUS "OpenCV Disabled")
  add_definitions(-DMXNET_USE_OPENCV=0)
endif()

if(USE_OPENMP)
 FIND_PACKAGE( OpenMP REQUIRED)
 if(OPENMP_FOUND)
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
 endif()
endif()

# cudnn detection
if(USE_CUDNN)
  detect_cuDNN()
  if(HAVE_CUDNN)
    add_definitions(-DUSE_CUDNN)
    include_directories(SYSTEM ${CUDNN_INCLUDE})
    list(APPEND mshadow_LINKER_LIBS ${CUDNN_LIBRARY})
	add_definitions(-DMSHADOW_USE_CUDNN=1)
  endif()
endif()

add_subdirectory("dmlc-core")
if(USE_DIST_KVSTORE)
	add_subdirectory("ps-lite")
endif()

mxnet_source_group("Include\\common"   GLOB "src/common/*.h")
mxnet_source_group("Include\\c_api"   GLOB "src/c_api/*.h")
mxnet_source_group("Include\\engine"   GLOB "src/engine/*.h")
mxnet_source_group("Include\\io"   GLOB "src/io/*.h")
mxnet_source_group("Include\\kvstore"   GLOB "src/kvstore/*.h")
mxnet_source_group("Include\\ndarray"   GLOB "src/ndarray/*.h")
mxnet_source_group("Include\\operator"   GLOB "src/operator/*.h")
mxnet_source_group("Include\\optimizer"   GLOB "src/optimizer/*.h")
mxnet_source_group("Include\\resource.cc"   GLOB "src/resource.cc/*.h")
mxnet_source_group("Include\\storage"   GLOB "src/storage/*.h")
mxnet_source_group("Include\\symbol"   GLOB "src/symbol/*.h")

mxnet_source_group("Cuda\\common"   GLOB "src/common/*.cu")
mxnet_source_group("Cuda\\c_api"   GLOB "src/c_api/*.cu")
mxnet_source_group("Cuda\\engine"   GLOB "src/engine/*.cu")
mxnet_source_group("Cuda\\io"   GLOB "src/io/*.cu")
mxnet_source_group("Cuda\\kvstore"   GLOB "src/kvstore/*.cu")
mxnet_source_group("Cuda\\ndarray"   GLOB "src/ndarray/*.cu")
mxnet_source_group("Cuda\\operator"   GLOB "src/operator/*.cu")
mxnet_source_group("Cuda\\optimizer"   GLOB "src/optimizer/*.cu")
mxnet_source_group("Cuda\\resource.cc"   GLOB "src/resource.cc/*.cu")
mxnet_source_group("Cuda\\storage"   GLOB "src/storage/*.cu")
mxnet_source_group("Cuda\\symbol"   GLOB "src/symbol/*.cu")

mxnet_source_group("Source"   GLOB "src/*.cc")
mxnet_source_group("Source\\common"   GLOB "src/common/*.cc")
mxnet_source_group("Source\\c_api"   GLOB "src/c_api/*.cc")
mxnet_source_group("Source\\engine"   GLOB "src/engine/*.cc")
mxnet_source_group("Source\\io"   GLOB "src/io/*.cc")
mxnet_source_group("Source\\kvstore"   GLOB "src/kvstore/*.cc")
mxnet_source_group("Source\\ndarray"   GLOB "src/ndarray/*.cc")
mxnet_source_group("Source\\operator"   GLOB "src/operator/*.cc")
mxnet_source_group("Source\\optimizer"   GLOB "src/optimizer/*.cc")
mxnet_source_group("Source\\resource.cc"   GLOB "src/resource.cc/*.cc")
mxnet_source_group("Source\\storage"   GLOB "src/storage/*.cc")
mxnet_source_group("Source\\symbol"   GLOB "src/symbol/*.cc")





FILE(GLOB_RECURSE SOURCE "src/*.cc" "src/*.h")
FILE(GLOB_RECURSE cuda "src/*.cu")

if (NOT (EXTRA_OPERATORS STREQUAL ""))
	mxnet_source_group("Extra"   GLOB_RECURSE "${EXTRA_OPERATORS}/*.cc")
	mxnet_source_group("Extra\\Cuda"   GLOB_RECURSE "${EXTRA_OPERATORS}/*.cu")
	FILE(GLOB_RECURSE EXTRA_SRC "${EXTRA_OPERATORS}/*.cc")
	FILE(GLOB_RECURSE EXTRA_CUSRC "${EXTRA_OPERATORS}/*.cu")
	list(APPEND SOURCE ${EXTRA_SRC} ${EXTRA_CUSRC})
endif()

if(MSVC)
  foreach(flag_var
        CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
        CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
    if(${flag_var} MATCHES "/MD")
      string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
    endif(${flag_var} MATCHES "/MD")
  endforeach(flag_var)
endif()

if(USE_CUDA)
  # define preprocessor macro so that we will not include the generated forcelink header
  mshadow_cuda_compile(cuda_objs ${cuda})
  if(MSVC)
    FIND_LIBRARY(CUDA_nvrtc_LIBRARY nvrtc "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64"  "${CUDA_TOOLKIT_ROOT_DIR}/lib/win32")
    list(APPEND mshadow_LINKER_LIBS ${CUDA_nvrtc_LIBRARY})
    set(CUDA_cuda_LIBRARY "${CUDA_nvrtc_LIBRARY}/../cuda.lib")
    list(APPEND mshadow_LINKER_LIBS ${CUDA_cuda_LIBRARY})
  else(MSVC)
{'fraction_non_alphanumeric': 0.13422953451043337, 'fraction_numerical': 0.004614767255216694, 'mean_word_length': 6.314013206162876, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7098289', 'n_tokens_mistral': 4215, 'n_tokens_neox': 4023, 'n_words': 592}