Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit c0408ba

Browse files
committed
Merge remote-tracking branch 'internal/release_1.1.3'
2 parents e94b3ff + 9d10d6f commit c0408ba

33 files changed

+69290
-109381
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ endif()
1010
project(Caffe C CXX)
1111

1212
# ---[ Caffe version
13-
set(CAFFE_TARGET_VERSION "1.1.2" CACHE STRING "Caffe logical version")
14-
set(CAFFE_TARGET_SOVERSION "1.1.2" CACHE STRING "Caffe soname version")
13+
set(CAFFE_TARGET_VERSION "1.1.3" CACHE STRING "Caffe logical version")
14+
set(CAFFE_TARGET_SOVERSION "1.1.3" CACHE STRING "Caffe soname version")
1515
add_definitions(-DCAFFE_VERSION=${CAFFE_TARGET_VERSION})
1616

1717
# ---[ Using cmake scripts and modules

INSTALL.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# Installation
1+
#### Installation
2+
23

34
See http://caffe.berkeleyvision.org/installation.html for the latest
45
installation instructions.
56

7+
68
Check the users group in case you need help:
79
https://groups.google.com/forum/#!forum/caffe-users

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ LIB_BUILD_DIR := $(BUILD_DIR)/lib
102102
STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a
103103
DYNAMIC_VERSION_MAJOR := 1
104104
DYNAMIC_VERSION_MINOR := 1
105-
DYNAMIC_VERSION_REVISION := 2
105+
DYNAMIC_VERSION_REVISION := 3
106106
DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so
107107
#DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR)
108108
DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)

docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ docker run -ti caffe:cpu caffe --version
1717
```
1818
which should show a message like:
1919
```
20-
caffe version 1.1.2
20+
caffe version 1.1.3
2121
```
2222

2323
One can also build and run the Caffe tests in the image using:

examples/faster-rcnn/license.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The MIT License
2+
Copyright (c) <year> <copyright holders>
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

examples/pycaffe/tune_model.py

Lines changed: 17 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import os
22
import sys
33
import argparse
4+
5+
sys.path.insert(0, "python")
6+
import caffe
47
from caffe.proto import caffe_pb2
58
import google.protobuf.text_format as txtf
69
import copy
710
import utils
811

9-
1012
def genOptimalModel(net, mkldnn_direct_time_map, mkldnn_winograd_time_map, optimal_model):
1113
for index in range(0, len(net.layer)):
1214
l = net.layer[index]
@@ -17,37 +19,21 @@ def genOptimalModel(net, mkldnn_direct_time_map, mkldnn_winograd_time_map, optim
1719
stride = 1
1820
if len(l.convolution_param.stride) != 0:
1921
stride = l.convolution_param.stride[0]
20-
if mkldnn_winograd_time_map[l.name] < mkldnn_direct_time_map[l.name] and kernel_size == 3 and stride == 1 and l.convolution_param.num_output % 16 == 0:
22+
if kernel_size == 3 and stride == 1 and l.convolution_param.num_output % 16 ==0:
2123
l.convolution_param.conv_algorithm = "winograd"
2224
else:
2325
l.convolution_param.conv_algorithm = "direct"
24-
26+
2527
with open(optimal_model, "w") as f:
2628
f.write(txtf.MessageToString(net, float_format=".17g"))
2729

28-
29-
def tuneModelDefinition(model_path, iteration, is_test_phase, core_num, socket_num):
30-
working_dir = sys.path[0]
31-
caffe_path = os.path.join(working_dir, "..", "..",
32-
"build", "tools", "caffe")
30+
def tuneModelDefinition(model_path, iteration):
31+
working_dir = sys.argv[0]
32+
33+
caffe_path = os.path.join(os.path.dirname(os.path.abspath(working_dir)), "../..", "build", "tools", "caffe")
3334
if not os.path.exists(caffe_path):
3435
print "Caffe binary does not exist; please build Caffe binary first."
3536
sys.exit(1)
36-
core_num_per_socket = int([i for i in os.popen('lscpu').readlines(
37-
) if i.startswith('Core(s) per socket:')][0].strip().split(':')[-1].strip())
38-
core_num_per_socket *= socket_num
39-
if is_test_phase:
40-
caffe_path += ' time -phase TEST -forward_only'
41-
if core_num != 0:
42-
core_num = core_num_per_socket if core_num > core_num_per_socket else core_num
43-
env_prefix = 'OMP_NUM_THREADS={} KMP_HW_SUBSET=1t KMP_AFFINITY=compact,granularity=fine numactl -C 0-{} -m 0 '.format(
44-
core_num, core_num)
45-
elif socket_num == 1:
46-
env_prefix = 'OMP_NUM_THREADS={} KMP_HW_SUBSET=1t KMP_AFFINITY=compact,granularity=fine numactl -C 0-{} -m 0 '.format(
47-
core_num_per_socket, core_num_per_socket)
48-
else:
49-
env_prefix = 'numactl -l '
50-
caffe_path = env_prefix + caffe_path
5137

5238
base_model_name = os.path.basename(model_path)
5339
model_dir = os.path.dirname(model_path)
@@ -83,30 +69,21 @@ def tuneModelDefinition(model_path, iteration, is_test_phase, core_num, socket_n
8369
mkldnn_winograd_log = "mkldnn_winograd.log"
8470
mkldnn_direct_log_path = os.path.join(model_dir, mkldnn_direct_log)
8571
mkldnn_winograd_log_path = os.path.join(model_dir, mkldnn_winograd_log)
86-
mkldnn_direct_command = caffe_path + " -model " + direct_model_path + \
87-
" -engine MKLDNN -iterations " + \
88-
str(iteration) + " >& " + mkldnn_direct_log_path
72+
mkldnn_direct_command = caffe_path + " time -model " + direct_model_path + " -engine MKLDNN -iterations " + str(iteration) + " >& " + mkldnn_direct_log_path
8973
os.system(mkldnn_direct_command)
90-
mkldnn_winograd_command = caffe_path + " -model " + winograd_model_path + \
91-
" -engine MKLDNN -iterations " + \
92-
str(iteration) + " >& " + mkldnn_winograd_log_path
74+
mkldnn_winograd_command = caffe_path + " time -model " + winograd_model_path + " -engine MKLDNN -iterations " + str(iteration) + " >& " + mkldnn_winograd_log_path
9375
os.system(mkldnn_winograd_command)
9476

9577
(model_str, mkldnn_direct_time_lines) = utils.parseLog(mkldnn_direct_log_path)
96-
mkldnn_direct_layer_time_map = utils.parseTimeLines(
97-
mkldnn_direct_time_lines)
98-
(model_str, mkldnn_winograd_time_lines) = utils.parseLog(
99-
mkldnn_winograd_log_path)
100-
mkldnn_winograd_layer_time_map = utils.parseTimeLines(
101-
mkldnn_winograd_time_lines)
78+
mkldnn_direct_layer_time_map = utils.parseTimeLines(mkldnn_direct_time_lines)
79+
(model_str, mkldnn_winograd_time_lines) = utils.parseLog(mkldnn_winograd_log_path)
80+
mkldnn_winograd_layer_time_map = utils.parseTimeLines(mkldnn_winograd_time_lines)
10281

10382
hybrid_model_name = base_model_name.split(".")[0] + "_hybrid.prototxt"
10483
hybrid_model_path = os.path.join(model_dir, hybrid_model_name)
105-
genOptimalModel(base_net, mkldnn_direct_layer_time_map,
106-
mkldnn_winograd_layer_time_map, hybrid_model_path)
84+
genOptimalModel(base_net, mkldnn_direct_layer_time_map, mkldnn_winograd_layer_time_map, hybrid_model_path)
10785
print '{} has been generated.'.format(hybrid_model_path)
10886

109-
11087
if __name__ == '__main__':
11188
parser = argparse.ArgumentParser()
11289

@@ -116,17 +93,7 @@ def tuneModelDefinition(model_path, iteration, is_test_phase, core_num, socket_n
11693
parser.add_argument('-i', '--iteration', action='store', dest='iterations', type=int, default=10,
11794
help='require iterations number to run the model')
11895

119-
parser.add_argument('-t', '--phase', action='store', dest='is_test_phase', type=bool, default=False,
120-
help='Train or Test phase')
121-
122-
parser.add_argument('-c', '--core_num', action='store', dest='core_num', type=int, default=0,
123-
help='core number for inference')
124-
125-
parser.add_argument('-s', '--socket', action='store', dest='socket_num', type=int, default=2,
126-
help='socket number for inference')
127-
128-
parser.add_argument('-v', '--version', action='version',
129-
version='%(prog)s 1.0')
96+
parser.add_argument('-v', '--version', action='version', version='%(prog)s 1.0')
13097

13198
params = parser.parse_args()
13299

@@ -135,5 +102,4 @@ def tuneModelDefinition(model_path, iteration, is_test_phase, core_num, socket_n
135102
print "[ERROR] Please specify the model definition file with -m"
136103
exit(1)
137104

138-
tuneModelDefinition(params.model, params.iterations,
139-
params.is_test_phase, params.core_num, params.socket_num)
105+
tuneModelDefinition(params.model, params.iterations)

examples/pycaffe/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import os
22
import sys
3+
sys.path.insert(0,"python")
4+
import caffe
35
from caffe.proto import caffe_pb2
46
import google.protobuf.text_format as txtf
57

examples/rfcn/license.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The MIT License
2+
Copyright (c) <year> <copyright holders>
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

external/mkl/prepare_mkl.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
3535
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3636
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38-
#
37+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38+
#
3939
FindLibrary()
4040
{
4141
# Find all the instances of the MKL libraries present in Caffe
@@ -74,11 +74,11 @@ echo $VERSION_LINE # Return Version Line
7474
# MKL
7575
DST=`dirname $0`
7676
OMP=0
77-
VERSION_MATCH=20180710
78-
ARCHIVE_BASENAME=mklml_lnx_2019.0.20180710.tgz
77+
VERSION_MATCH=20180928
78+
ARCHIVE_BASENAME=mklml_lnx_2019.0.1.20180928.tgz
7979
MKL_CONTENT_DIR=`echo $ARCHIVE_BASENAME | rev | cut -d "." -f 2- | rev`
8080

81-
MKLURL="https://github.com/intel/mkl-dnn/releases/download/v0.16/$ARCHIVE_BASENAME"
81+
MKLURL="https://github.com/intel/mkl-dnn/releases/download/v0.17-rc/$ARCHIVE_BASENAME"
8282
# there are diffrent MKL lib to be used for GCC and for ICC
8383
reg='^[0-9]+$'
8484
VERSION_LINE=`GetVersionName $MKLROOT`

include/caffe/mkldnn_memory.hpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ class MKLDNNMemoryDescriptorBase : public PrvMemDescr
6464
, std::vector<float>scale=std::vector<float>(1,1.)
6565
, int mask=0
6666
, bool is_sum=false
67-
, bool is_wino=false);
67+
, bool is_wino=false
68+
, bool is_weight=false);
6869

6970

7071
~MKLDNNMemoryDescriptorBase() {}
@@ -142,12 +143,12 @@ class MKLDNNMemoryDescriptorBase : public PrvMemDescr
142143
// TODO: may need initialize memory by 0
143144
}
144145
}
145-
void set_prv_memory_pd(shared_ptr<memory::primitive_desc> memory_pd, std::vector<float> scale, int mask, bool is_wino) {
146+
void set_prv_memory_pd(shared_ptr<memory::primitive_desc> memory_pd, std::vector<float> scale, int mask, bool is_wino, bool is_weight) {
146147
_prv_memory_pd = memory_pd;
147148
if (_prv_memory_pd && _usr_memory_pd) {
148149
check_usr_with_prv_descriptors();
149150
std::vector<float>scale_ext = std::vector<float>(1,1.);
150-
this->create_reorder_descriptors(scale, mask, scale_ext, false, is_wino);
151+
this->create_reorder_descriptors(scale, mask, scale_ext, false, is_wino, is_weight);
151152
}
152153
}
153154

@@ -163,7 +164,7 @@ class MKLDNNMemoryDescriptorBase : public PrvMemDescr
163164
_usr_memory_pd = memory_pd;
164165
}
165166

166-
void create_reorder_descriptors(std::vector<float> scale, int mask=0, std::vector<float>scale_ext=std::vector<float>(1,1.), bool is_sum=false, bool is_wino=false);
167+
void create_reorder_descriptors(std::vector<float> scale, int mask=0, std::vector<float>scale_ext=std::vector<float>(1,1.), bool is_sum=false, bool is_wino=false, bool is_weight=false);
167168

168169
shared_ptr<memory::primitive_desc> _usr_memory_pd;
169170
shared_ptr<memory::primitive_desc> _prv_memory_pd;
@@ -205,7 +206,8 @@ class MKLDNNMemoryDescriptor : public MKLDNNMemoryDescriptorBase<Dtype> {
205206
, std::vector<float> scale=std::vector<float>(1,1.)
206207
, int mask=0
207208
, bool is_sum=false
208-
, bool is_wino=false);
209+
, bool is_wino=false
210+
, bool is_weight=false);
209211

210212
virtual void convert_from_prv(void* cpu_ptr);
211213
virtual void convert_to_prv(void* cpu_ptr);
@@ -253,8 +255,9 @@ class MKLDNNData : public MKLDNNMemoryDescriptor<Dtype, false>
253255
, std::vector<float> scale=std::vector<float>(1,1.)
254256
, int mask=0
255257
, bool is_sum=false
256-
, bool is_wino=false)
257-
: MKLDNNMemoryDescriptor<Dtype, false>(usr_memory_pd, prv_memory_pd, blob, mkldnn_layer, scale, mask, is_sum, is_wino) {}
258+
, bool is_wino=false
259+
, bool is_weight=false)
260+
: MKLDNNMemoryDescriptor<Dtype, false>(usr_memory_pd, prv_memory_pd, blob, mkldnn_layer, scale, mask, is_sum, is_wino, is_weight) {}
258261
};
259262

260263
template <typename Dtype>

0 commit comments

Comments
 (0)