Skip to content

Commit 89572e1

Browse files
authored
Merge pull request #456 from drnikolaev/caffe-0.16
0.16.5 Release
2 parents cdb3d9a + 4202cb1 commit 89572e1

File tree

210 files changed

+11371
-5338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+11371
-5338
lines changed

3rdparty/half_float/half.hpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,13 @@ namespace half_float
10581058
CAFFE_UTIL_HD
10591059
half& operator=(detail::expr rhs) { return *this = static_cast<float>(rhs); }
10601060

1061-
/// Arithmetic assignment.
1061+
CAFFE_UTIL_HD
1062+
half& operator=(const half& rhs) {
1063+
data_ = rhs.data_;
1064+
return *this;
1065+
}
1066+
1067+
/// Arithmetic assignment.
10621068
/// \tparam T type of concrete half expression
10631069
/// \param rhs half expression to add
10641070
/// \return reference to this half
@@ -1172,6 +1178,12 @@ namespace half_float
11721178
detail::uint16 data_;
11731179
};
11741180

1181+
template <>
1182+
CAFFE_UTIL_IHD half& half::operator= <half>(const half& rhs) {
1183+
data_ = rhs.data_;
1184+
return *this;
1185+
}
1186+
11751187
#if HALF_ENABLE_CPP11_USER_LITERALS
11761188
/// Library-defined half-precision literals.
11771189
/// Import this namespace to enable half-precision floating point literals:
@@ -3086,6 +3098,10 @@ namespace std
30863098

30873099
inline bool signbit(const half_float::half& arg) { return half_float::detail::signbit(arg); }
30883100

3101+
inline half_float::half fabs(half_float::half x) {
3102+
return abs(x);
3103+
}
3104+
30893105

30903106
#if HALF_ENABLE_CPP11_HASH
30913107
/// Hash function for half-precision floats.

CMakeLists.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8.7)
1+
cmake_minimum_required(VERSION 3.4.0)
22
if(POLICY CMP0046)
33
cmake_policy(SET CMP0046 NEW)
44
endif()
@@ -52,7 +52,6 @@ set(python_version "2" CACHE STRING "Specify which Python version to use")
5252
caffe_option(BUILD_matlab "Build Matlab wrapper" OFF IF UNIX OR APPLE)
5353
caffe_option(BUILD_docs "Build documentation" ON IF UNIX OR APPLE)
5454
caffe_option(BUILD_python_layer "Build the Caffe Python layer" ON)
55-
caffe_option(USE_OPENCV "Build with OpenCV support" ON)
5655
caffe_option(USE_LEVELDB "Build with levelDB" ON)
5756
caffe_option(USE_LMDB "Build with lmdb" ON)
5857
caffe_option(ALLOW_LMDB_NOLOCK "Allow MDB_NOLOCK when reading LMDB files (only if necessary)" OFF)

Makefile

+11-7
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ EMPTY_LINT_REPORT := $(BUILD_DIR)/.$(LINT_EXT)
9090
NONEMPTY_LINT_REPORT := $(BUILD_DIR)/$(LINT_EXT)
9191
# PY$(PROJECT)_SRC is the python wrapper for $(PROJECT)
9292
PY$(PROJECT)_SRC := python/$(PROJECT)/_$(PROJECT).cpp
93+
PY$(PROJECT)_OBJ := $(BUILD_DIR)/src/$(PROJECT)/layers/python_layer.o
9394
PY$(PROJECT)_SO := python/$(PROJECT)/_$(PROJECT).so
9495
PY$(PROJECT)_HXX := include/$(PROJECT)/layers/python_layer.hpp
9596
# MAT$(PROJECT)_SRC is the mex entrance point of matlab package for $(PROJECT)
@@ -192,7 +193,10 @@ ifneq ($(NO_NVML), 1)
192193
endif
193194
endif
194195

195-
LIBRARIES += boost_system glog gflags protobuf boost_filesystem m
196+
# Note: libturbojpeg has a packaging bug. Workaround:
197+
# $ sudo ln -s /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0 /usr/lib/x86_64-linux-gnu/libturbojpeg.so
198+
199+
LIBRARIES += boost_system glog gflags protobuf boost_filesystem m turbojpeg
196200
ifeq ($(TEGRA), 1)
197201
LIBRARIES += hdf5_serial_hl hdf5_serial
198202
else
@@ -211,14 +215,14 @@ ifeq ($(USE_LMDB), 1)
211215
LIBRARIES += lmdb
212216
endif
213217
ifeq ($(USE_OPENCV), 1)
214-
LIBRARIES += opencv_core opencv_highgui opencv_imgproc
218+
LIBRARIES += opencv_core opencv_highgui opencv_imgproc
215219

216220
ifeq ($(OPENCV_VERSION), 3)
217221
LIBRARIES += opencv_imgcodecs
218222
endif
219223

220224
endif
221-
PYTHON_LIBRARIES ?= boost_python python2.7
225+
PYTHON_LIBRARIES ?= boost_python python2.7 boost_regex
222226
WARNINGS := -Wall -Wno-sign-compare
223227

224228
##############################
@@ -532,10 +536,10 @@ py$(PROJECT): py
532536

533537
py: $(PY$(PROJECT)_SO) $(PROTO_GEN_PY)
534538

535-
$(PY$(PROJECT)_SO): $(PY$(PROJECT)_SRC) $(PY$(PROJECT)_HXX) | $(DYNAMIC_NAME)
539+
$(PY$(PROJECT)_SO): $(PY$(PROJECT)_OBJ) $(PY$(PROJECT)_SRC) $(PY$(PROJECT)_HXX) | $(DYNAMIC_NAME)
536540
@ echo CXX/LD -o $@ $<
537-
$(Q)$(CXX) -shared -o $@ $(PY$(PROJECT)_SRC) \
538-
-o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(PYTHON_LDFLAGS) \
541+
$(Q)$(CXX) -shared -o $@ $(PY$(PROJECT)_SRC) $(PY$(PROJECT)_OBJ) \
542+
$(LINKFLAGS) -l$(LIBRARY_NAME) $(PYTHON_LDFLAGS) \
539543
-Wl,-rpath,$(ORIGIN)/../../build/lib
540544

541545
mat$(PROJECT): mat
@@ -562,7 +566,7 @@ runtest: $(TEST_ALL_BIN)
562566
$(TEST_ALL_BIN) $(TEST_GPUID) --gtest_shuffle $(TEST_FILTER)
563567

564568
pytest: py
565-
cd python; python -m unittest discover -s caffe/test
569+
cd python; python -u -m unittest discover -s caffe/test
566570

567571
mattest: mat
568572
cd matlab; $(MATLAB_DIR)/bin/matlab -nodisplay -r 'caffe.run_tests(), exit()'

classification/example.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def forward_pass(images, net, transformer, batch_size=None):
147147
scores = np.copy(output)
148148
else:
149149
scores = np.vstack((scores, output))
150-
print 'Processed %s/%s images in %f seconds ...' % (len(scores), len(caffe_images), (end - start))
150+
print('Processed %s/%s images in %f seconds ...' % (len(scores), len(caffe_images), (end - start)))
151151

152152
return scores
153153

@@ -159,7 +159,7 @@ def read_labels(labels_file):
159159
labels_file -- path to a .txt file
160160
"""
161161
if not labels_file:
162-
print 'WARNING: No labels file provided. Results will be difficult to interpret.'
162+
print('WARNING: No labels file provided. Results will be difficult to interpret.')
163163
return None
164164

165165
labels = []
@@ -252,5 +252,5 @@ def classify(caffemodel, deploy_file, image_files,
252252
classify(args['caffemodel'], args['deploy_file'], args['image_file'],
253253
args['mean'], args['labels'], args['batch_size'], not args['nogpu'])
254254

255-
print 'Script took %f seconds.' % (time.time() - script_start_time,)
255+
print('Script took %f seconds.' % (time.time() - script_start_time,))
256256

classification/use_archive.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ def unzip_archive(archive):
3333
pass
3434
else:
3535
if tarfile.is_tarfile(archive):
36-
print 'Extracting tarfile ...'
36+
print('Extracting tarfile ...')
3737
with tarfile.open(archive) as tf:
3838
tf.extractall(path=tmpdir)
3939
elif zipfile.is_zipfile(archive):
40-
print 'Extracting zipfile ...'
40+
print('Extracting zipfile ...')
4141
with zipfile.ZipFile(archive) as zf:
4242
zf.extractall(path=tmpdir)
4343
else:
@@ -64,7 +64,7 @@ def classify_with_archive(archive, image_files, batch_size=None, use_gpu=True):
6464
elif filename == 'labels.txt':
6565
labels_file = full_path
6666
else:
67-
print 'Unknown file:', filename
67+
print('Unknown file:', filename)
6868

6969
assert caffemodel is not None, 'Caffe model file not found'
7070
assert deploy_file is not None, 'Deploy file not found'
@@ -101,5 +101,5 @@ def classify_with_archive(archive, image_files, batch_size=None, use_gpu=True):
101101
use_gpu=(not args['nogpu']),
102102
)
103103

104-
print 'Script took %f seconds.' % (time.time() - script_start_time,)
104+
print('Script took %f seconds.' % (time.time() - script_start_time,))
105105

cmake/ConfigGen.cmake

-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ function(caffe_generate_export_configs)
5656
list(APPEND Caffe_DEFINITIONS -DCPU_ONLY)
5757
endif()
5858

59-
if(USE_OPENCV)
60-
list(APPEND Caffe_DEFINITIONS -DUSE_OPENCV)
61-
endif()
62-
6359
if(USE_LMDB)
6460
list(APPEND Caffe_DEFINITIONS -DUSE_LMDB)
6561
if (ALLOW_LMDB_NOLOCK)

cmake/Dependencies.cmake

+22-50
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# This list is required for static linking and exported to CaffeConfig.cmake
22
set(Caffe_LINKER_LIBS "")
33

4+
find_package(PythonInterp ${python_version})
5+
46
# ---[ Boost
5-
find_package(Boost 1.46 REQUIRED COMPONENTS system thread filesystem)
7+
find_package(Boost 1.54 REQUIRED COMPONENTS system thread filesystem regex python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
8+
set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_FOUND})
69
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
710
list(APPEND Caffe_LINKER_LIBS ${Boost_LIBRARIES})
811

@@ -54,6 +57,10 @@ if(USE_LEVELDB)
5457
list(APPEND Caffe_LINKER_LIBS ${Snappy_LIBRARIES})
5558
endif()
5659

60+
find_package(JPEGTurbo REQUIRED)
61+
include_directories(SYSTEM ${JPEGTurbo_INCLUDE_DIR})
62+
list(APPEND Caffe_LINKER_LIBS ${JPEGTurbo_LIBRARIES})
63+
5764
# ---[ CUDA
5865
include(cmake/Cuda.cmake)
5966
if(NOT HAVE_CUDA)
@@ -68,23 +75,20 @@ if(NOT HAVE_CUDA)
6875
endif()
6976

7077
# ---[ OpenCV
71-
if(USE_OPENCV)
72-
find_package(OpenCV QUIET COMPONENTS imgcodecs)
73-
if(OPENCV_IMGCODECS_FOUND)
74-
find_package(OpenCV REQUIRED COMPONENTS core imgcodecs imgproc)
75-
message(STATUS "Found OpenCV 3.x: ${OpenCV_CONFIG_PATH}")
76-
else()
77-
find_package(OpenCV REQUIRED COMPONENTS core highgui imgproc)
78-
message(STATUS "Found OpenCV 2.x: ${OpenCV_CONFIG_PATH}")
79-
endif()
80-
include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS})
81-
list(APPEND Caffe_LINKER_LIBS ${OpenCV_LIBS})
82-
add_definitions(-DUSE_OPENCV)
78+
find_package(OpenCV QUIET COMPONENTS imgcodecs)
79+
if(OPENCV_IMGCODECS_FOUND)
80+
find_package(OpenCV REQUIRED COMPONENTS core imgcodecs imgproc)
81+
message(STATUS "Found OpenCV 3.x: ${OpenCV_CONFIG_PATH}")
82+
else()
83+
find_package(OpenCV REQUIRED COMPONENTS core highgui imgproc)
84+
message(STATUS "Found OpenCV 2.x: ${OpenCV_CONFIG_PATH}")
8385
endif()
86+
include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS})
87+
list(APPEND Caffe_LINKER_LIBS ${OpenCV_LIBS})
8488

8589
# ---[ BLAS
8690
if(NOT APPLE)
87-
set(BLAS "Atlas" CACHE STRING "Selected BLAS library")
91+
set(BLAS "Open" CACHE STRING "Selected BLAS library")
8892
set_property(CACHE BLAS PROPERTY STRINGS "Atlas;Open;MKL")
8993

9094
if(BLAS STREQUAL "Atlas" OR BLAS STREQUAL "atlas")
@@ -109,46 +113,14 @@ endif()
109113

110114
# ---[ Python
111115
if(BUILD_python)
112-
if(NOT "${python_version}" VERSION_LESS "3.0.0")
113-
# use python3
114-
find_package(PythonInterp 3.0)
115-
find_package(PythonLibs 3.0)
116-
find_package(NumPy 1.7.1)
117-
# Find the matching boost python implementation
118-
set(version ${PYTHONLIBS_VERSION_STRING})
119-
120-
STRING( REGEX REPLACE "[^0-9]" "" boost_py_version ${version} )
121-
find_package(Boost 1.46 COMPONENTS "python-py${boost_py_version}")
122-
set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND})
123-
124-
while(NOT "${version}" STREQUAL "" AND NOT Boost_PYTHON_FOUND)
125-
STRING( REGEX REPLACE "([0-9.]+).[0-9]+" "\\1" version ${version} )
126-
127-
STRING( REGEX REPLACE "[^0-9]" "" boost_py_version ${version} )
128-
find_package(Boost 1.46 COMPONENTS "python-py${boost_py_version}")
129-
set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND})
130-
131-
STRING( REGEX MATCHALL "([0-9.]+).[0-9]+" has_more_version ${version} )
132-
if("${has_more_version}" STREQUAL "")
133-
break()
134-
endif()
135-
endwhile()
136-
if(NOT Boost_PYTHON_FOUND)
137-
find_package(Boost 1.46 COMPONENTS python)
138-
endif()
139-
else()
140-
# disable Python 3 search
141-
find_package(PythonInterp 2.7)
142-
find_package(PythonLibs 2.7)
143-
find_package(NumPy 1.7.1)
144-
find_package(Boost 1.46 COMPONENTS python)
145-
endif()
116+
find_package(PythonLibs ${python_version})
117+
find_package(NumPy 1.7.1)
146118
if(PYTHONLIBS_FOUND AND NUMPY_FOUND AND Boost_PYTHON_FOUND)
147119
set(HAVE_PYTHON TRUE)
148120
if(BUILD_python_layer)
149121
add_definitions(-DWITH_PYTHON_LAYER)
150122
include_directories(SYSTEM ${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
151-
list(APPEND Caffe_LINKER_LIBS ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
123+
list(APPEND Caffe_LINKER_LIBS ${PYTHON_LIBRARIES})
152124
endif()
153125
endif()
154126
endif()
@@ -186,7 +158,7 @@ else()
186158
endif()
187159
if(NCCL_FOUND)
188160
add_definitions(-DUSE_NCCL)
189-
include_directories(SYSTEM ${NCCL_INCLUDE})
161+
include_directories(SYSTEM ${NCCL_INCLUDE_DIR})
190162
list(APPEND Caffe_LINKER_LIBS ${NCCL_LIBRARY})
191163
endif()
192164

cmake/Modules/FindJPEGTurbo.cmake

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Find the JPEGTurbo libraries
2+
#
3+
# The following variables are optionally searched for defaults
4+
# JPEGTurbo_ROOT_DIR: Base directory where all JPEGTurbo components are found
5+
#
6+
# The following are set after configuration is done:
7+
# JPEGTurbo_FOUND
8+
# JPEGTurbo_INCLUDE_DIR
9+
# JPEGTurbo_LIBRARIES
10+
11+
find_path(JPEGTurbo_INCLUDE_DIR NAMES turbojpeg.h
12+
PATHS /usr/include ${JPEGTurbo_ROOT_DIR} ${JPEGTurbo_ROOT_DIR}/include)
13+
14+
find_library(JPEGTurbo_LIBRARIES SHARED NAMES libturbojpeg.so.0
15+
PATHS ${JPEGTurbo_ROOT_DIR} ${JPEGTurbo_ROOT_DIR}/lib)
16+
17+
include(FindPackageHandleStandardArgs)
18+
find_package_handle_standard_args(JPEGTurbo DEFAULT_MSG JPEGTurbo_INCLUDE_DIR JPEGTurbo_LIBRARIES)
19+
20+
if(JPEGTurbo_FOUND)
21+
message(STATUS "Found JPEGTurbo (include: ${JPEGTurbo_INCLUDE_DIR}, library: ${JPEGTurbo_LIBRARIES})")
22+
mark_as_advanced(JPEGTurbo_INCLUDE_DIR JPEGTurbo_LIBRARIES)
23+
endif()
24+

cmake/Modules/FindNCCL.cmake

+4
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@ find_package_handle_standard_args(NCCL DEFAULT_MSG NCCL_INCLUDE_DIR NCCL_LIBRARY
2121
if(NCCL_FOUND)
2222
message(STATUS "Found NCCL (include: ${NCCL_INCLUDE_DIR}, library: ${NCCL_LIBRARY})")
2323
mark_as_advanced(NCCL_INCLUDE_DIR NCCL_LIBRARY)
24+
caffe_parse_header(${NCCL_INCLUDE_DIR}/nccl.h
25+
NCCL_VERION_LINES NCCL_MAJOR NCCL_MINOR NCCL_PATCH)
26+
set(NCCL_VERSION "${NCCL_MAJOR}.${NCCL_MINOR}.${NCCL_PATCH}")
27+
2428
endif()
2529

cmake/Summary.cmake

+5-6
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ function(caffe_print_configuration_summary)
114114
caffe_status(" BUILD_matlab : ${BUILD_matlab}")
115115
caffe_status(" BUILD_docs : ${BUILD_docs}")
116116
caffe_status(" CPU_ONLY : ${CPU_ONLY}")
117-
caffe_status(" USE_OPENCV : ${USE_OPENCV}")
118117
caffe_status(" USE_LEVELDB : ${USE_LEVELDB}")
119118
caffe_status(" USE_LMDB : ${USE_LMDB}")
120119
caffe_status(" ALLOW_LMDB_NOLOCK : ${ALLOW_LMDB_NOLOCK}")
@@ -133,9 +132,8 @@ function(caffe_print_configuration_summary)
133132
caffe_status(" LevelDB : " LEVELDB_FOUND THEN "Yes (ver. ${LEVELDB_VERSION})" ELSE "No")
134133
caffe_status(" Snappy : " SNAPPY_FOUND THEN "Yes (ver. ${Snappy_VERSION})" ELSE "No" )
135134
endif()
136-
if(USE_OPENCV)
137-
caffe_status(" OpenCV : Yes (ver. ${OpenCV_VERSION})")
138-
endif()
135+
caffe_status(" OpenCV : Yes (ver. ${OpenCV_VERSION})")
136+
caffe_status(" JPEGTurbo : " JPEGTurbo_FOUND THEN "Yes" ELSE "No" )
139137
caffe_status(" CUDA : " HAVE_CUDA THEN "Yes (ver. ${CUDA_VERSION})" ELSE "No" )
140138
caffe_status("")
141139
if(HAVE_CUDA)
@@ -148,9 +146,10 @@ function(caffe_print_configuration_summary)
148146
caffe_status(" cuDNN : Disabled")
149147
endif()
150148
if(NOT DEFINED USE_NCCL)
151-
caffe_status(" NCCL : " NCCL_FOUND THEN "Yes" ELSE "Not found")
149+
caffe_status(" NCCL : " NCCL_FOUND THEN "Yes (ver. ${NCCL_VERSION})" ELSE "Not
150+
found")
152151
elseif(USE_NCCL)
153-
caffe_status(" NCCL : " NCCL_FOUND THEN "Yes" ELSE "Not found")
152+
caffe_status(" NCCL : " NCCL_FOUND THEN "Yes (ver. ${NCCL_VERSION})" ELSE "Not found")
154153
else()
155154
caffe_status(" NCCL : Disabled")
156155
endif()

0 commit comments

Comments
 (0)