-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Refactor operators & MKLDNN #8302
Changes from all commits
3a90190
4ecf3a1
709ec84
d625b31
3cb6606
197fff2
785fa5f
09eca97
8af167e
5752525
853a28f
c76d3ed
8ba9736
6c7f2de
d3dac5f
e015f11
386dc55
cb1d630
399ff52
62995b6
4c3f112
1078898
c5de4ed
fce31ed
7e8537c
4723054
8cb1970
2f8028a
682cec6
619fe85
d2181d4
4b84308
46a7209
26ecfb8
839441a
b9cc3d9
4d781a1
10619fe
2ac3918
7caa0db
5a037bd
9560775
06e0ab6
e4b4fc5
6668727
b5e210d
7c8456e
050b95c
5b3f647
e22b2e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,11 +42,11 @@ endif | |
# use customized config file | ||
include $(config) | ||
|
||
ifeq ($(USE_MKL2017), 1) | ||
# must run ./prepare_mkl before including mshadow.mk | ||
RETURN_STRING := $(shell ./prepare_mkl.sh $(MKLML_ROOT)) | ||
MKLROOT := $(firstword $(RETURN_STRING)) | ||
export USE_MKLML = $(lastword $(RETURN_STRING)) | ||
ifeq ($(USE_MKLDNN), 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is cmake also adjusted for this type of build? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not yet. I'll update. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have changed cmake to compile with MKLDNN. |
||
RETURN_STRING := $(shell ./prepare_mkldnn.sh $(MKLDNN_ROOT)) | ||
MKLDNNROOT := $(firstword $(RETURN_STRING)) | ||
MKLROOT := $(lastword $(RETURN_STRING)) | ||
export USE_MKLML = 1 | ||
endif | ||
|
||
include mshadow/make/mshadow.mk | ||
|
@@ -114,23 +114,16 @@ ifeq ($(USE_NNPACK), 1) | |
LDFLAGS += -lnnpack | ||
endif | ||
|
||
ifeq ($(USE_MKL2017), 1) | ||
CFLAGS += -DMXNET_USE_MKL2017=1 | ||
ifeq ($(USE_MKLDNN), 1) | ||
CFLAGS += -DMXNET_USE_MKLDNN=1 | ||
CFLAGS += -DUSE_MKL=1 | ||
CFLAGS += -I$(ROOTDIR)/src/operator/mkl/ | ||
CFLAGS += -I$(MKLML_ROOT)/include | ||
LDFLAGS += -L$(MKLML_ROOT)/lib | ||
ifeq ($(USE_MKL2017_EXPERIMENTAL), 1) | ||
CFLAGS += -DMKL_EXPERIMENTAL=1 | ||
else | ||
CFLAGS += -DMKL_EXPERIMENTAL=0 | ||
endif | ||
ifeq ($(UNAME_S), Darwin) | ||
LDFLAGS += -lmklml | ||
else | ||
LDFLAGS += -Wl,--as-needed -lmklml_intel -lmklml_gnu | ||
CFLAGS += -I$(ROOTDIR)/src/operator/nn/mkldnn/ | ||
ifneq ($(MKLDNNROOT), $(MKLROOT)) | ||
CFLAGS += -I$(MKLROOT)/include | ||
LDFLAGS += -L$(MKLROOT)/lib | ||
endif | ||
LDFLAGS += -liomp5 | ||
CFLAGS += -I$(MKLDNNROOT)/include | ||
LDFLAGS += -L$(MKLDNNROOT)/lib -lmkldnn -Wl,-rpath,'$${ORIGIN}' | ||
endif | ||
|
||
ifeq ($(USE_OPERATOR_TUNING), 1) | ||
|
@@ -144,7 +137,7 @@ endif | |
# - for Ubuntu, installing atlas will not automatically install the atlas provided lapack library | ||
# silently switching lapack off instead of letting the build fail because of backward compatibility | ||
ifeq ($(USE_LAPACK), 1) | ||
ifeq ($(USE_BLAS),$(filter $(USE_BLAS),blas openblas atlas)) | ||
ifeq ($(USE_BLAS),$(filter $(USE_BLAS),blas openblas atlas mkl)) | ||
ifeq (,$(wildcard /lib/liblapack.a)) | ||
ifeq (,$(wildcard /usr/lib/liblapack.a)) | ||
ifeq (,$(wildcard /usr/lib64/liblapack.a)) | ||
|
@@ -162,7 +155,7 @@ ifeq ($(USE_LAPACK), 1) | |
ifneq ($(USE_LAPACK_PATH), ) | ||
LDFLAGS += -L$(USE_LAPACK_PATH) | ||
endif | ||
ifeq ($(USE_BLAS),$(filter $(USE_BLAS),blas openblas atlas)) | ||
ifeq ($(USE_BLAS),$(filter $(USE_BLAS),blas openblas atlas mkl)) | ||
LDFLAGS += -llapack | ||
endif | ||
CFLAGS += -DMXNET_USE_LAPACK | ||
|
@@ -552,7 +545,8 @@ clean: cyclean $(EXTRA_PACKAGES_CLEAN) | |
else | ||
clean: cyclean testclean $(EXTRA_PACKAGES_CLEAN) | ||
$(RM) -r build lib bin *~ */*~ */*/*~ */*/*/*~ R-package/NAMESPACE R-package/man R-package/R/mxnet_generated.R \ | ||
R-package/inst R-package/src/image_recordio.h R-package/src/*.o R-package/src/*.so mxnet_*.tar.gz | ||
R-package/inst R-package/src/image_recordio.h R-package/src/*.o R-package/src/*.so mxnet_*.tar.gz \ | ||
external/mkldnn/install/* | ||
cd $(DMLC_CORE); $(MAKE) clean; cd - | ||
cd $(PS_PATH); $(MAKE) clean; cd - | ||
cd $(NNVM_PATH); $(MAKE) clean; cd - | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,7 +112,8 @@ def get_rec_iter(args, kv=None): | |
image_shape = tuple([int(l) for l in args.image_shape.split(',')]) | ||
if 'benchmark' in args and args.benchmark: | ||
data_shape = (args.batch_size,) + image_shape | ||
train = SyntheticDataIter(args.num_classes, data_shape, 500, np.float32) | ||
train = SyntheticDataIter(args.num_classes, data_shape, | ||
args.num_examples / args.batch_size, np.float32) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change related to this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really. It seems to me this is a bug, so I fixed it. |
||
return (train, None) | ||
if kv: | ||
(rank, nworker) = (kv.rank, kv.num_workers) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So have you been able to use MKLDNN without the need of a separate dockerfile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it works fine. except that using MKLDNN and GPU in Jenkins still fails. It's not a linking problem. It's most likely caused by the conflict of MKLDNN and GPU in Jenkins.