From 1141d7f8c1c733fa5b83ab76828e3766a5453caf Mon Sep 17 00:00:00 2001 From: Daisy Deng Date: Mon, 13 May 2019 21:43:39 +0800 Subject: [PATCH] Caffe 1.1.6 prerelease, cont. --- CMakeLists.txt | 38 +- Makefile | 7 +- Makefile.config.example | 3 + Makefile.mkldnn | 6 +- README.md | 77 +- cmake/ConfigGen.cmake | 2 +- cmake/Dependencies.cmake | 158 +- cmake/MKLDNN.cmake | 25 +- cmake/Misc.cmake | 6 + cmake/Modules/FindGFlags.cmake | 22 +- cmake/Modules/FindGlog.cmake | 16 +- cmake/Targets.cmake | 2 + docker/README.md | 2 +- examples/VNet/DataManager.py | 208 - examples/VNet/LICENSE | 674 ---- examples/VNet/README.md | 2 - examples/VNet/VNet.py | 197 - examples/VNet/main.py | 43 - examples/VNet/pyLayer.py | 66 - examples/VNet/utilities.py | 140 - examples/faster-rcnn/lib/setup.py | 4 +- examples/rfcn/lib/setup.py | 4 +- external/mkl/prepare_mkl.sh | 6 +- include/caffe/mkldnn_memory.hpp | 28 +- include/caffe/net.hpp | 12 +- include/caffe/syncedmem.hpp | 14 +- include/caffe/util/compareToolUtilities.h | 1 - include/caffe/util/cpu_info.hpp | 43 +- mkldnn.commit | 2 +- .../int8/ssd_int8.prototxt | 1955 ---------- .../mobilenet_v2/mobilenet_v2_deploy.prototxt | 3442 ----------------- .../default_resnet50_16nodes/solver.prototxt | 6 +- .../default_resnet50_64nodes/solver.prototxt | 2 +- python/CMakeLists.txt | 15 +- python/caffe/_caffe.cpp | 4 +- python/caffe/test/test_net_spec.py | 4 +- run.sh | 10 +- run_accuracy.sh | 1 - scripts/calibrator.py | 186 +- scripts/conv_param.csv | 36 - scripts/fullyconnected0_bias.txt | 50 - scripts/fullyconnected0_weight.txt | 50 - scripts/fullyconnected1_bias.txt | 100 - scripts/fullyconnected1_weight.txt | 100 - scripts/fullyconnected2_bias.txt | 2 - scripts/fullyconnected2_weight.txt | 2 - scripts/gen_header.py | 59 - scripts/optimze_input_u8.diff | 117 - scripts/output.csv | 525 --- scripts/result.txt | 75 - scripts/sampling.py | 60 +- src/caffe/CMakeLists.txt | 25 +- src/caffe/common.cpp | 5 + src/caffe/data_transformer.cpp | 38 +- src/caffe/internal_thread.cpp | 9 + src/caffe/layers/annotated_data_layer.cpp | 7 +- src/caffe/layers/batch_norm_layer.cpp | 22 +- src/caffe/layers/data_layer.cpp | 2 + src/caffe/layers/image_data_layer.cpp | 2 + src/caffe/layers/lrn_layer.cpp | 6 +- src/caffe/layers/mkldnn_convolution_layer.cpp | 48 +- .../layers/mkldnn_inner_product_layer.cpp | 57 +- src/caffe/layers/mkldnn_relu_layer.cpp | 4 +- src/caffe/layers/pooling_layer.cpp | 36 +- src/caffe/layers/prelu_layer.cpp | 2 +- src/caffe/layers/reshape_layer.cpp | 12 +- .../layers/smooth_L1_loss_ohem_layer.cpp | 6 +- src/caffe/layers/softmax_layer.cpp | 7 +- src/caffe/layers/spatial_dropout_layer.cpp | 8 + src/caffe/mkldnn_memory.cpp | 16 +- src/caffe/net.cpp | 98 +- src/caffe/proto/caffe.proto | 6 + src/caffe/solvers/sgd_solver.cpp | 16 +- src/caffe/test/test_engine_selection.cpp | 6 - src/caffe/util/bbox_util.cpp | 32 +- src/caffe/util/cpu_info.cpp | 335 +- src/caffe/util/db_lmdb.cpp | 5 + src/caffe/util/hdf5.cpp | 13 +- src/caffe/util/io.cpp | 28 +- src/caffe/util/math_functions.cpp | 4 +- src/caffe/util/signal_handler.cpp | 26 +- tools/CMakeLists.txt | 11 +- 82 files changed, 1251 insertions(+), 8250 deletions(-) delete mode 100644 examples/VNet/DataManager.py delete mode 100644 examples/VNet/LICENSE delete mode 100644 examples/VNet/README.md delete mode 100644 examples/VNet/VNet.py delete mode 100644 examples/VNet/main.py delete mode 100644 examples/VNet/pyLayer.py delete mode 100644 examples/VNet/utilities.py delete mode 100644 models/intel_optimized_models/int8/ssd_int8.prototxt delete mode 100644 models/intel_optimized_models/mobilenet_v2/mobilenet_v2_deploy.prototxt delete mode 100644 scripts/conv_param.csv delete mode 100755 scripts/fullyconnected0_bias.txt delete mode 100755 scripts/fullyconnected0_weight.txt delete mode 100755 scripts/fullyconnected1_bias.txt delete mode 100755 scripts/fullyconnected1_weight.txt delete mode 100755 scripts/fullyconnected2_bias.txt delete mode 100755 scripts/fullyconnected2_weight.txt delete mode 100644 scripts/gen_header.py delete mode 100644 scripts/optimze_input_u8.diff delete mode 100644 scripts/output.csv delete mode 100644 scripts/result.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 127ac1dbe..3f1477c8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,23 +1,38 @@ -cmake_minimum_required(VERSION 2.8.7) +if(MSVC) + # CMake 3.4 introduced a WINDOWS_EXPORT_ALL_SYMBOLS target property that makes it possible to + # build shared libraries without using the usual declspec() decoration. + # See: https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/ + # and https://cmake.org/cmake/help/v3.5/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.html + # for details. + cmake_minimum_required(VERSION 3.4) +else() + cmake_minimum_required(VERSION 2.8.7) +endif() if(POLICY CMP0046) cmake_policy(SET CMP0046 NEW) endif() if(POLICY CMP0054) cmake_policy(SET CMP0054 NEW) endif() +if(POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) +endif() # ---[ Caffe project project(Caffe C CXX) # ---[ Caffe version -set(CAFFE_TARGET_VERSION "1.1.5" CACHE STRING "Caffe logical version") -set(CAFFE_TARGET_SOVERSION "1.1.5" CACHE STRING "Caffe soname version") +set(CAFFE_TARGET_VERSION "1.1.6" CACHE STRING "Caffe logical version") +set(CAFFE_TARGET_SOVERSION "1.1.6" CACHE STRING "Caffe soname version") add_definitions(-DCAFFE_VERSION=${CAFFE_TARGET_VERSION}) # ---[ Using cmake scripts and modules list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules) include(ExternalProject) +if(MSVC) +include(GNUInstallDirs) +endif() include(cmake/Utils.cmake) include(cmake/Targets.cmake) @@ -62,8 +77,15 @@ endif() #end code coverage # ---[ Flags -if(UNIX OR APPLE) - +if(MSVC) + set(USERCONFIG_PLATFORM "x64") + if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP -D_USE_MATH_DEFINES /DNO_STRICT /wd4800 /wd4996 /wd4068 /wd4305 /wd4244 /wd4551 /wd4267 /wd4661 /wd4146") + endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP -D_USE_MATH_DEFINES /DNO_STRICT -Qdiag-disable:15552 -Qdiag-disable:3180") + endif() +elseif(UNIX OR APPLE) # Linker flags. if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel") # GCC specific flags. ICC is compatible with them. @@ -130,12 +152,16 @@ configure_file(cmake/Templates/caffe_config.h.in "${PROJECT_BINARY_DIR}/caffe_co # ---[ Includes set(Caffe_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include) include_directories(${Caffe_INCLUDE_DIR} ${PROJECT_BINARY_DIR}) -include_directories(BEFORE src/gtest/include src/gmock/include) # This is needed for gtest. +if(NOT MSVC) +include_directories(BEFORE src/gtest/include src/gmock/include) # This is needed for gtest. +endif() # ---[ Subdirectories #add_subdirectory(src/gtest) set(BUILD_SHARED_LIBS off) +if(NOT MSVC) add_subdirectory(src/gmock) +endif() set(BUILD_SHARED_LIBS on) add_subdirectory(src/caffe) add_subdirectory(tools) diff --git a/Makefile b/Makefile index 4adfb98c0..c8125402b 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ LIB_BUILD_DIR := $(BUILD_DIR)/lib STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a DYNAMIC_VERSION_MAJOR := 1 DYNAMIC_VERSION_MINOR := 1 -DYNAMIC_VERSION_REVISION := 5 +DYNAMIC_VERSION_REVISION := 6 DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so #DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR) DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION) @@ -517,6 +517,11 @@ ifeq ($(DISABLE_SPARSE), 1) COMMON_FLAGS += -DDISABLE_SPARSE endif +# Disable FC + ReLU fusion +ifeq ($(DISABLE_FC_RELU_FUSION), 1) + COMMON_FLAGS += -DDISABLE_FC_RELU_FUSION +endif + # Performance monitoring ifeq ($(PERFORMANCE_MONITORING), 1) CXXFLAGS += -DPERFORMANCE_MONITORING diff --git a/Makefile.config.example b/Makefile.config.example index fdbfc6754..0164f44a7 100644 --- a/Makefile.config.example +++ b/Makefile.config.example @@ -96,6 +96,9 @@ DISABLE_CONV_SUM_FUSION := 0 # Use sparse to boost inference. DISABLE_SPARSE := 0 +# Use fc/relu fusion to boost inference. +DISABLE_FC_RELU_FUSION := 0 + # Intel(R) Math Kernel Library for Deep Neural Networks (Intel(R) MKL-DNN) # Uncomment to disable MKLDNN download by customized setting # DISABLE_MKLDNN_DOWNLOAD := 1 diff --git a/Makefile.mkldnn b/Makefile.mkldnn index 8a0c48b6b..9f32abd7d 100644 --- a/Makefile.mkldnn +++ b/Makefile.mkldnn @@ -63,15 +63,15 @@ mkldnn_clean: mkldnnroot_set: $(eval CXXFLAGS += -DMKLDNN_SUPPORTED) \ $(eval INCLUDE_DIRS += $(MKLDNNROOT)/include) - $(eval MKLDNN_LDFLAGS += -lmkldnn -L$(MKLDNNROOT)/lib) \ - $(eval MKLDNN_LDFLAGS += -Wl,-rpath,$(MKLDNNROOT)/lib) \ + $(eval MKLDNN_LDFLAGS += -lmkldnn -L$(MKLDNNROOT)/lib64) \ + $(eval MKLDNN_LDFLAGS += -Wl,-rpath,$(MKLDNNROOT)/lib64) \ mkldnnroot_notset: mkldnn_build $(eval CXXFLAGS += -DMKLDNN_SUPPORTED) \ $(eval INCLUDE_DIRS += $(MKLDNN_INSTALLDIR)/include) \ $(eval MKLDNN_LDFLAGS += -lmkldnn) \ - $(eval MKLDNN_LDFLAGS += -L$(MKLDNN_INSTALLDIR)/lib -Wl,-rpath,${MKLDNN_INSTALLDIR}/lib) + $(eval MKLDNN_LDFLAGS += -L$(MKLDNN_INSTALLDIR)/lib64 -Wl,-rpath,${MKLDNN_INSTALLDIR}/lib64) diff --git a/README.md b/README.md index f2a818f56..07c0126e7 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,39 @@ +# Caffe +[![Build Status](https://travis-ci.org/BVLC/caffe.svg?branch=master)](https://travis-ci.org/BVLC/caffe) +[![License](https://img.shields.io/badge/license-BSD-blue.svg)](LICENSE) + +Caffe is a deep learning framework made with expression, speed, and modularity in mind. +It is developed by the Berkeley Vision and Learning Center ([BVLC](http://bvlc.eecs.berkeley.edu)) and community contributors. + +Check out the [project site](http://caffe.berkeleyvision.org) for all the details like +- [DIY Deep Learning for Vision with Caffe](https://docs.google.com/presentation/d/1UeKXVgRvvxg9OUdh_UiC5G71UMscNPlvArsWER41PsU/edit#slide=id.p) +- [Tutorial Documentation](http://caffe.berkeleyvision.org/tutorial/) +- [BVLC reference models](http://caffe.berkeleyvision.org/model_zoo.html) and the [community model zoo](https://github.com/BVLC/caffe/wiki/Model-Zoo) +- [Installation instructions](https://github.com/intel/caffe/wiki/Installation) + +and step-by-step examples. + +[![Join the chat at https://gitter.im/BVLC/caffe](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/BVLC/caffe?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +Please join the [caffe-users group](https://groups.google.com/forum/#!forum/caffe-users) or [gitter chat](https://gitter.im/BVLC/caffe) to ask questions and talk about methods and models. +Framework development discussions and thorough bug reports are collected on [Issues](https://github.com/BVLC/caffe/issues). + +Happy brewing! + + +# SSD: Single Shot MultiBox Detector +This repository contains merged code issued as pull request to BVLC caffe written by: +[Wei Liu](http://www.cs.unc.edu/~wliu/), [Dragomir Anguelov](https://www.linkedin.com/in/dragomiranguelov), [Dumitru Erhan](http://research.google.com/pubs/DumitruErhan.html), [Christian Szegedy](http://research.google.com/pubs/ChristianSzegedy.html), [Scott Reed](http://www-personal.umich.edu/~reedscot/), [Cheng-Yang Fu](http://www.cs.unc.edu/~cyfu/), [Alexander C. Berg](http://acberg.com). + +Original branch can be found at https://github.com/weiliu89/caffe/tree/ssd. + +Read our [wiki page](https://github.com/intel/caffe/wiki/SSD:-Single-Shot-MultiBox-Detector) for more details. + # Intel® Distribution of Caffe* This fork is dedicated to improving Caffe performance when running on CPU, in particular Intel® Xeon processors. ## Building -Build procedure is the same as on bvlc-caffe-master branch, see section "Caffe". Both Make and CMake can be used. +Build procedure is the same as on bvlc-caffe-master branch. Both Make and CMake can be used. When OpenMP is available will be used automatically. ## Running @@ -17,23 +48,9 @@ If some system tool like numactl is used to control CPU affinity, by default caf to use more than one thread per core. When less than required cores are specified, caffe will limit execution of OpenMP threads to specified cores only. -To collect performance on full INT8 model of ResNet-50 v1.0, please update the variables NUM_CORE, the batch size range s_BS and e_BS, and INSTANCES according to your test requirements, then run: - - . run.sh - -To verify the accuracy, please run - - . run_accuracy.sh - ## Best performance solution Please read [our Wiki](https://github.com/intel/caffe/wiki/Recommendations-to-achieve-best-performance) for our recommendations and configuration to achieve best performance on Intel CPUs. -Results: - -Performance and convergence test result: https://github.com/intel/caffe/wiki/INTEL%C2%AE-OPTIMIZED-CAFFE-PERFORMANCE-AND-CONVERGENCE. - -Scaling test result on AWS: https://github.com/intel/caffe/wiki/Intel%C2%AE-Optimization-for-Caffe-AWS-EC2-C5-(SKX)-Multi-node-Scaling. - ## Multinode Training Intel® Distribution of Caffe* multi-node allows you to execute deep neural network training on multiple machines. @@ -56,34 +73,4 @@ Please cite Caffe in your publications if it helps your research: *Other names and brands may be claimed as the property of others -# SSD: Single Shot MultiBox Detector -This repository contains merged code issued as pull request to BVLC caffe written by: -[Wei Liu](http://www.cs.unc.edu/~wliu/), [Dragomir Anguelov](https://www.linkedin.com/in/dragomiranguelov), [Dumitru Erhan](http://research.google.com/pubs/DumitruErhan.html), [Christian Szegedy](http://research.google.com/pubs/ChristianSzegedy.html), [Scott Reed](http://www-personal.umich.edu/~reedscot/), [Cheng-Yang Fu](http://www.cs.unc.edu/~cyfu/), [Alexander C. Berg](http://acberg.com). - -Original branch can be found at https://github.com/weiliu89/caffe/tree/ssd. - -Read our [wiki page](https://github.com/intel/caffe/wiki/SSD:-Single-Shot-MultiBox-Detector) for more details. - -# Caffe -[![Build Status](https://travis-ci.org/BVLC/caffe.svg?branch=master)](https://travis-ci.org/BVLC/caffe) -[![License](https://img.shields.io/badge/license-BSD-blue.svg)](LICENSE) -Caffe is a deep learning framework made with expression, speed, and modularity in mind. -It is developed by the Berkeley Vision and Learning Center ([BVLC](http://bvlc.eecs.berkeley.edu)) and community contributors. - - -Check out the [project site](http://caffe.berkeleyvision.org) for all the details like -- [DIY Deep Learning for Vision with Caffe](https://docs.google.com/presentation/d/1UeKXVgRvvxg9OUdh_UiC5G71UMscNPlvArsWER41PsU/edit#slide=id.p) -- [Tutorial Documentation](http://caffe.berkeleyvision.org/tutorial/) -- [BVLC reference models](http://caffe.berkeleyvision.org/model_zoo.html) and the [community model zoo](https://github.com/BVLC/caffe/wiki/Model-Zoo) -- [Installation instructions](https://github.com/intel/caffe/wiki/Installation) - -and step-by-step examples. - -[![Join the chat at https://gitter.im/BVLC/caffe](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/BVLC/caffe?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -Please join the [caffe-users group](https://groups.google.com/forum/#!forum/caffe-users) or [gitter chat](https://gitter.im/BVLC/caffe) to ask questions and talk about methods and models. -Framework development discussions and thorough bug reports are collected on [Issues](https://github.com/BVLC/caffe/issues). - -Happy brewing! - diff --git a/cmake/ConfigGen.cmake b/cmake/ConfigGen.cmake index 5bfda8c1a..a335fee4d 100644 --- a/cmake/ConfigGen.cmake +++ b/cmake/ConfigGen.cmake @@ -120,7 +120,7 @@ function(caffe_generate_export_configs) configure_file("cmake/Templates/CaffeConfig.cmake.in" "${PROJECT_BINARY_DIR}/CaffeConfig.cmake" @ONLY) # Add targets to the build-tree export set - export(TARGETS caffe proto FILE "${PROJECT_BINARY_DIR}/CaffeTargets.cmake") + export(TARGETS caffe caffeproto FILE "${PROJECT_BINARY_DIR}/CaffeTargets.cmake") export(PACKAGE Caffe) # ---[ Configure install-tree CaffeConfig.cmake file ]--- diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index dc6668ca4..3e3eae4aa 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -1,6 +1,10 @@ # This list is required for static linking and exported to CaffeConfig.cmake set(Caffe_LINKER_LIBS "") +if(MSVC) + set(BOOST_ROOT "c:/local/boost_1_69_0" CACHE STRING "Default BOOST Library Path") +endif() + # ---[ Boost find_package(Boost 1.46 REQUIRED COMPONENTS system thread filesystem regex) include_directories(SYSTEM ${Boost_INCLUDE_DIR}) @@ -186,32 +190,46 @@ if(NOT APPLE) include_directories(SYSTEM ${OpenBLAS_INCLUDE_DIR}) list(APPEND Caffe_LINKER_LIBS ${OpenBLAS_LIB}) elseif(BLAS STREQUAL "MKL" OR BLAS STREQUAL "mkl") - #--find mkl in external/mkl - set(script_cmd "./external/mkl/prepare_mkl.sh" ) - execute_process(COMMAND ${script_cmd} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE script_result - OUTPUT_VARIABLE RETURN_STRING) - separate_arguments(RETURN_STRING) - list(GET RETURN_STRING 0 MKL_ROOT_DIR) - list(GET RETURN_STRING 1 MKL_LIBRARIES) - list(GET RETURN_STRING 2 MKL_EXTERNAL) - set(MKL_INCLUDE_DIR "${MKL_ROOT_DIR}/include/") - if( ${MKL_EXTERNAL} EQUAL 1 ) - set(MKL_LIBRARIES "${MKL_ROOT_DIR}/lib/lib${MKL_LIBRARIES}.so") + #--find mkl in external/mkl + if(MSVC) + set(script_cmd "external\\mkl\\prepare_mkl.bat" ) + else() + set(script_cmd "./external/mkl/prepare_mkl.sh" ) + endif() + execute_process(COMMAND ${script_cmd} + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + RESULT_VARIABLE script_result + OUTPUT_VARIABLE RETURN_STRING) + separate_arguments(RETURN_STRING) + list(GET RETURN_STRING 0 MKL_ROOT_DIR) + list(GET RETURN_STRING 1 MKL_LIBRARIES) + list(GET RETURN_STRING 2 MKL_EXTERNAL) + set(MKL_INCLUDE_DIR "${MKL_ROOT_DIR}/include/") + if(MSVC) + set(MKL_LIBRARIES_NAME "${MKL_LIBRARIES}.lib") + else() + set(MKL_LIBRARIES_NAME "lib${MKL_LIBRARIES}.so") + endif() + if( ${MKL_EXTERNAL} EQUAL 1 ) + set(MKL_LIBRARIES "${MKL_ROOT_DIR}/lib/${MKL_LIBRARIES_NAME}") set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MKL_ROOT_DIR}/lib/) - else() - set(MKL_LIBRARIES "${MKL_ROOT_DIR}/lib/intel64/lib${MKL_LIBRARIES}.so") + else() + set(MKL_LIBRARIES "${MKL_ROOT_DIR}/lib/intel64/${MKL_LIBRARIES_NAME}") set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MKL_ROOT_DIR}/lib/intel64/) - endif() - message(STATUS "Found MKL: ${MKL_INCLUDE_DIR}") - message(STATUS "Found MKL (include: ${MKL_INCLUDE_DIR}, lib: ${MKL_LIBRARIES}") - include_directories(SYSTEM ${MKL_INCLUDE_DIR}) + endif() + message(STATUS "Found MKL: ${MKL_INCLUDE_DIR}") + message(STATUS "Found MKL (include: ${MKL_INCLUDE_DIR}, lib: ${MKL_LIBRARIES}") + include_directories(SYSTEM ${MKL_INCLUDE_DIR}) list(APPEND Caffe_LINKER_LIBS ${MKL_LIBRARIES}) add_definitions(-DUSE_MKL) # If MKL and OpenMP is to be used then use Intel OpenMP - if(OPENMP_FOUND) - list(APPEND Caffe_LINKER_LIBS -Wl,--as-needed iomp5) + if(OPENMP_FOUND) + if(MSVC) + set(IOMP_NAME "${MKL_ROOT_DIR}/lib/libiomp5md.lib") + else() + set(IOMP_NAME -Wl,--as-needed iomp5) + endif() + list(APPEND Caffe_LINKER_LIBS ${IOMP_NAME}) endif() endif() elseif(APPLE) @@ -228,23 +246,42 @@ endif() # ---[ MKL2017 if(BLAS STREQUAL "MKL" OR BLAS STREQUAL "mkl") - if(EXISTS ${MKL_INCLUDE_DIR}/mkl_dnn.h) - message(STATUS "Found MKL2017") - set(MKL2017_SUPPORTED ON) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMKL2017_SUPPORTED") + if(MSVC) + set(MKL2017_SUPPORTED OFF) if(USE_MKL2017_AS_DEFAULT_ENGINE) - message(STATUS "MKL2017 engine will be used as a default engine") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_MKL2017_AS_DEFAULT_ENGINE") + message(WARNING "Flag USE_MKL2017_AS_DEFAULT_ENGINE was set, but MKL2017 has been deprecated and not supported at windows!") endif() else() - message(STATUS "MKL2017 not found") - set(MKL2017_SUPPORTED OFF) - if(USE_MKL2017_AS_DEFAULT_ENGINE) - message(WARNING "Flag USE_MKL2017_AS_DEFAULT_ENGINE was set, but MKL2017 not found") + if(EXISTS ${MKL_INCLUDE_DIR}/mkl_dnn.h) + message(STATUS "Found MKL2017") + set(MKL2017_SUPPORTED ON) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMKL2017_SUPPORTED") + if(USE_MKL2017_AS_DEFAULT_ENGINE) + message(STATUS "MKL2017 engine will be used as a default engine") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_MKL2017_AS_DEFAULT_ENGINE") + endif() + else() + message(STATUS "MKL2017 not found") + set(MKL2017_SUPPORTED OFF) + if(USE_MKL2017_AS_DEFAULT_ENGINE) + message(WARNING "Flag USE_MKL2017_AS_DEFAULT_ENGINE was set, but MKL2017 not found") + endif() endif() endif() endif() +if(MSVC) + set(MKLDNN_LIBRARIES_NAME "mkldnn.lib") +else() + set(MKLDNN_LIBRARIES_NAME "libmkldnn.so") +endif() + +if(APPLE OR WIN32) + set(LIBDIR lib) +else() + set(LIBDIR lib64) +endif() + # ---[ MKLDNN if(DEFINED ENV{MKLDNNROOT}) if(DISABLE_MKLDNN_DOWNLOAD) @@ -266,9 +303,9 @@ if(DEFINED ENV{MKLDNNROOT}) message(STATUS "MKLDNN engine will be used as a default engine") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_MKLDNN_AS_DEFAULT_ENGINE") endif() - list(APPEND Caffe_LINKER_LIBS "${MKLDNNROOT_DIR}/lib/libmkldnn.so") - set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MKLDNNROOT_DIR}/lib/) - include_directories(SYSTEM ${MKLDNNROOT_INCLUDE_DIR}) + list(APPEND Caffe_LINKER_LIBS "${MKLDNNROOT_DIR}/${LIBDIR}/${MKLDNN_LIBRARIES_NAME}") + set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MKLDNNROOT_DIR}/${LIBDIR}/) + include_directories(SYSTEM ${MKLDNNROOT_INCLUDE_DIR}) else() message(STATUS "MKLDNN not found. MKLDNN_INCLUDE_DIR = ${MKLDNNROOT_INCLUDE_DIR}") set(MKLDNN_SUPPORTED OFF) @@ -295,8 +332,8 @@ else() message(STATUS "MKLDNN engine will be used as a default engine") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_MKLDNN_AS_DEFAULT_ENGINE") endif() - list(APPEND Caffe_LINKER_LIBS "${MKLDNN_INSTALL_DIR}/lib/libmkldnn.so") - set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MKLDNN_INSTALL_DIR}/lib/) + list(APPEND Caffe_LINKER_LIBS "${MKLDNN_INSTALL_DIR}/${LIBDIR}/${MKLDNN_LIBRARIES_NAME}") + set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MKLDNN_INSTALL_DIR}/${LIBDIR}/) include_directories(${MKLDNN_INCLUDE_DIR}) endif() endif() @@ -308,35 +345,42 @@ if(BUILD_python) find_package(PythonInterp 3.0) find_package(PythonLibs 3.0) find_package(NumPy 1.7.1) - # Find the matching boost python implementation - set(version ${PYTHONLIBS_VERSION_STRING}) + else() + # disable Python 3 search + find_package(PythonInterp 2.7) + find_package(PythonLibs 2.7) + find_package(NumPy 1.7.1) + endif() + + # Find the matching boost python implementation + set(version ${PYTHONLIBS_VERSION_STRING}) + STRING( REGEX REPLACE "[^0-9]" "" boost_py_version ${version} ) + find_package(Boost 1.46 COMPONENTS "python-py${boost_py_version}") + set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND}) + if(NOT Boost_PYTHON_FOUND) + find_package(Boost 1.46 COMPONENTS "python${boost_py_version}") + set(Boost_PYTHON_FOUND ${Boost_PYTHON${boost_py_version}_FOUND}) + endif() + while(NOT "${version}" STREQUAL "" AND NOT Boost_PYTHON_FOUND) + STRING( REGEX REPLACE "([0-9.]+).[0-9]+" "\\1" version ${version} ) + STRING( REGEX REPLACE "[^0-9]" "" boost_py_version ${version} ) find_package(Boost 1.46 COMPONENTS "python-py${boost_py_version}") set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND}) - - while(NOT "${version}" STREQUAL "" AND NOT Boost_PYTHON_FOUND) - STRING( REGEX REPLACE "([0-9.]+).[0-9]+" "\\1" version ${version} ) - - STRING( REGEX REPLACE "[^0-9]" "" boost_py_version ${version} ) - find_package(Boost 1.46 COMPONENTS "python-py${boost_py_version}") - set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND}) - - STRING( REGEX MATCHALL "([0-9.]+).[0-9]+" has_more_version ${version} ) - if("${has_more_version}" STREQUAL "") - break() - endif() - endwhile() if(NOT Boost_PYTHON_FOUND) - find_package(Boost 1.46 COMPONENTS python) + find_package(Boost 1.46 COMPONENTS "python${boost_py_version}") + set(Boost_PYTHON_FOUND ${Boost_PYTHON${boost_py_version}_FOUND}) endif() - else() - # disable Python 3 search - find_package(PythonInterp 2.7) - find_package(PythonLibs 2.7) - find_package(NumPy 1.7.1) + STRING( REGEX MATCHALL "([0-9.]+).[0-9]+" has_more_version ${version} ) + if("${has_more_version}" STREQUAL "") + break() + endif() + endwhile() + if(NOT Boost_PYTHON_FOUND) find_package(Boost 1.46 COMPONENTS python) endif() + if(PYTHONLIBS_FOUND AND NUMPY_FOUND AND Boost_PYTHON_FOUND) set(HAVE_PYTHON TRUE) if(BUILD_python_layer) diff --git a/cmake/MKLDNN.cmake b/cmake/MKLDNN.cmake index 733d4992b..24d3d81be 100644 --- a/cmake/MKLDNN.cmake +++ b/cmake/MKLDNN.cmake @@ -11,9 +11,8 @@ function(Download_MKLDNN) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel") endif() endif() - execute_process(COMMAND cat mkldnn.commit - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE MKLDNN_COMMIT) + + file(READ mkldnn.commit MKLDNN_COMMIT) include(ProcessorCount) ProcessorCount(NCORE) @@ -21,27 +20,35 @@ function(Download_MKLDNN) set(CTEST_BUILD_FLAGS -j${NCORE}) set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${NCORE}) endif() - + + if(MSVC) + set(MKLDNN_CMAKE_GENERATOR "Visual Studio 15 2017 Win64") + set(MKLDNN_INSTALL_CMD msbuild /p:Configuration=Release /m INSTALL.vcxproj) + else() + set(MKLDNN_INSTALL_CMD make install -j${NCORE}) + endif() + ExternalProject_add(MKLDNN_Build SOURCE_DIR ${MKLDNN_SOURCE_DIR} + CMAKE_GENERATOR ${MKLDNN_CMAKE_GENERATOR} CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${MKLDNN_INSTALL_DIR} -DMKLROOT=${MKL_ROOT_DIR} -DCMAKE_SHARED_LINKER_FLAGS=${CMAKE_SHARED_LINKER_FLAGS} #--Download step - GIT_REPOSITORY https://github.com/01org/mkl-dnn.git + GIT_REPOSITORY https://github.com/intel/mkl-dnn.git GIT_TAG ${MKLDNN_COMMIT} #--Build step BINARY_DIR ${MKLDNN_BUILD_DIR} - BUILD_COMMAND cmake ${MKLDNN_SOURCE_DIR} + BUILD_COMMAND cmake ${MKLDNN_SOURCE_DIR} #--Install step INSTALL_DIR ${MKLDNN_INSTALL_DIR} - INSTALL_COMMAND make install -j${NCORE} + INSTALL_COMMAND ${MKLDNN_INSTALL_CMD} LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) set(MKLDNN_INCLUDE_DIR ${MKLDNN_INSTALL_DIR}/include CACHE PATH "Include files for MKLDNN") - set(MKLDNN_LIB_DIR ${MKLDNN_INSTALL_DIR}/lib64) + set(MKLDNN_LIB_DIR ${MKLDNN_INSTALL_DIR}/${LIBDIR}) add_library(mkldnn SHARED IMPORTED ${MKLDNN_INSTALL_DIR}) - set_property(TARGET mkldnn PROPERTY IMPORTED_LOCATION ${MKLDNN_LIB_DIR}/libmkldnn.so) + set_property(TARGET mkldnn PROPERTY IMPORTED_LOCATION ${MKLDNN_LIB_DIR}/${MKLDNN_LIBRARIES_NAME}) add_dependencies(mkldnn MKLDNN_Build) endfunction(Download_MKLDNN) diff --git a/cmake/Misc.cmake b/cmake/Misc.cmake index 799d35fa9..dbf8512a8 100644 --- a/cmake/Misc.cmake +++ b/cmake/Misc.cmake @@ -35,6 +35,12 @@ if(DISABLE_SPARSE) message(STATUS "sparse is disabled!") add_definitions("-DDISABLE_SPARSE") endif() + +if(DISABLE_FC_RELU_FUSION) + message(STATUS "fc/relu fusion is disabled!") + add_definitions("-DDISABLE_FC_RELU_FUSION") +endif() + # --[ If user doesn't specify build type then assume release if("${CMAKE_BUILD_TYPE}" STREQUAL "") set(CMAKE_BUILD_TYPE Release) diff --git a/cmake/Modules/FindGFlags.cmake b/cmake/Modules/FindGFlags.cmake index 29b60f050..c24583e26 100644 --- a/cmake/Modules/FindGFlags.cmake +++ b/cmake/Modules/FindGFlags.cmake @@ -16,27 +16,18 @@ set(GFLAGS_ROOT_DIR "" CACHE PATH "Folder contains Gflags") # We are testing only a couple of files in the include directories if(WIN32) find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h - PATHS ${GFLAGS_ROOT_DIR}/src/windows) + PATHS ${GFLAGS_ROOT_DIR}/include) else() find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h PATHS ${GFLAGS_ROOT_DIR}) endif() -if(MSVC) - find_library(GFLAGS_LIBRARY_RELEASE - NAMES libgflags - PATHS ${GFLAGS_ROOT_DIR} - PATH_SUFFIXES Release) - - find_library(GFLAGS_LIBRARY_DEBUG - NAMES libgflags-debug - PATHS ${GFLAGS_ROOT_DIR} - PATH_SUFFIXES Debug) - - set(GFLAGS_LIBRARY optimized ${GFLAGS_LIBRARY_RELEASE} debug ${GFLAGS_LIBRARY_DEBUG}) +if(MSVC AND NOT BUILD_SHARED_LIBS) + set(GFLAGS_LIB_NAME gflags_static) else() - find_library(GFLAGS_LIBRARY gflags) + set(GFLAGS_LIB_NAME gflags) endif() +find_library(GFLAGS_LIBRARY ${GFLAGS_LIB_NAME}) find_package_handle_standard_args(GFlags DEFAULT_MSG GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY) @@ -45,6 +36,5 @@ if(GFLAGS_FOUND) set(GFLAGS_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIR}) set(GFLAGS_LIBRARIES ${GFLAGS_LIBRARY}) message(STATUS "Found gflags (include: ${GFLAGS_INCLUDE_DIR}, library: ${GFLAGS_LIBRARY})") - mark_as_advanced(GFLAGS_LIBRARY_DEBUG GFLAGS_LIBRARY_RELEASE - GFLAGS_LIBRARY GFLAGS_INCLUDE_DIR GFLAGS_ROOT_DIR) + mark_as_advanced(GFLAGS_LIBRARY GFLAGS_INCLUDE_DIR GFLAGS_ROOT_DIR) endif() diff --git a/cmake/Modules/FindGlog.cmake b/cmake/Modules/FindGlog.cmake index 99abbe478..2f83f3feb 100644 --- a/cmake/Modules/FindGlog.cmake +++ b/cmake/Modules/FindGlog.cmake @@ -15,22 +15,17 @@ set(GLOG_ROOT_DIR "" CACHE PATH "Folder contains Google glog") if(WIN32) find_path(GLOG_INCLUDE_DIR glog/logging.h - PATHS ${GLOG_ROOT_DIR}/src/windows) + PATHS ${GLOG_ROOT_DIR}/include) else() find_path(GLOG_INCLUDE_DIR glog/logging.h PATHS ${GLOG_ROOT_DIR}) endif() if(MSVC) - find_library(GLOG_LIBRARY_RELEASE libglog_static + find_library(GLOG_LIBRARY + NAMES glog PATHS ${GLOG_ROOT_DIR} - PATH_SUFFIXES Release) - - find_library(GLOG_LIBRARY_DEBUG libglog_static - PATHS ${GLOG_ROOT_DIR} - PATH_SUFFIXES Debug) - - set(GLOG_LIBRARY optimized ${GLOG_LIBRARY_RELEASE} debug ${GLOG_LIBRARY_DEBUG}) + PATH_SUFFIXES lib) else() find_library(GLOG_LIBRARY glog PATHS ${GLOG_ROOT_DIR} @@ -43,6 +38,5 @@ if(GLOG_FOUND) set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR}) set(GLOG_LIBRARIES ${GLOG_LIBRARY}) message(STATUS "Found glog (include: ${GLOG_INCLUDE_DIR}, library: ${GLOG_LIBRARY})") - mark_as_advanced(GLOG_ROOT_DIR GLOG_LIBRARY_RELEASE GLOG_LIBRARY_DEBUG - GLOG_LIBRARY GLOG_INCLUDE_DIR) + mark_as_advanced(GLOG_ROOT_DIR GLOG_LIBRARY GLOG_INCLUDE_DIR) endif() diff --git a/cmake/Targets.cmake b/cmake/Targets.cmake index d05043c9b..1b3805ba3 100644 --- a/cmake/Targets.cmake +++ b/cmake/Targets.cmake @@ -9,6 +9,8 @@ macro(caffe_set_caffe_link) set(Caffe_LINK -Wl,-force_load caffe) elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(Caffe_LINK -Wl,--whole-archive caffe -Wl,--no-whole-archive) + elseif(MSVC) + set(Caffe_LINK caffe) endif() endif() endmacro() diff --git a/docker/README.md b/docker/README.md index 8a01484aa..dc47a7620 100644 --- a/docker/README.md +++ b/docker/README.md @@ -17,7 +17,7 @@ docker run -ti caffe:cpu caffe --version ``` which should show a message like: ``` -caffe version 1.1.5 +caffe version 1.1.4 ``` One can also build and run the Caffe tests in the image using: diff --git a/examples/VNet/DataManager.py b/examples/VNet/DataManager.py deleted file mode 100644 index 526eb9c34..000000000 --- a/examples/VNet/DataManager.py +++ /dev/null @@ -1,208 +0,0 @@ -import numpy as np -import SimpleITK as sitk -from os import listdir -from os.path import isfile, join, splitext - -class DataManager(object): - params=None - srcFolder=None - resultsDir=None - - fileList=None - gtList=None - - sitkImages=None - sitkGT=None - meanIntensityTrain = None - - def __init__(self,srcFolder,resultsDir,parameters): - self.params=parameters - self.srcFolder=srcFolder - self.resultsDir=resultsDir - - def createImageFileList(self): - self.fileList = [f for f in listdir(self.srcFolder) if isfile(join(self.srcFolder, f)) and 'segmentation' not in f and 'raw' not in f] - print 'FILE LIST: ' + str(self.fileList) - - - def createGTFileList(self): - self.gtList=list() - for f in self.fileList: - filename, ext = splitext(f) - self.gtList.append(join(filename + '_segmentation' + ext)) - - - def loadImages(self): - self.sitkImages=dict() - rescalFilt=sitk.RescaleIntensityImageFilter() - rescalFilt.SetOutputMaximum(1) - rescalFilt.SetOutputMinimum(0) - - stats = sitk.StatisticsImageFilter() - m = 0. - for f in self.fileList: - self.sitkImages[f]=rescalFilt.Execute(sitk.Cast(sitk.ReadImage(join(self.srcFolder, f)),sitk.sitkFloat32)) - stats.Execute(self.sitkImages[f]) - m += stats.GetMean() - - self.meanIntensityTrain=m/len(self.sitkImages) - - - def loadGT(self): - self.sitkGT=dict() - - for f in self.gtList: - self.sitkGT[f]=sitk.Cast(sitk.ReadImage(join(self.srcFolder, f))>0.5,sitk.sitkFloat32) - - - - def loadTrainingData(self): - self.createImageFileList() - self.createGTFileList() - self.loadImages() - self.loadGT() - - - def loadTestData(self): - self.createImageFileList() - self.loadImages() - - def getNumpyImages(self): - dat = self.getNumpyData(self.sitkImages,sitk.sitkLinear) - return dat - - - def getNumpyGT(self): - dat = self.getNumpyData(self.sitkGT,sitk.sitkLinear) - - for key in dat: - dat[key] = (dat[key]>0.5).astype(dtype=np.float32) - - return dat - - - def getNumpyData(self,dat,method): - ret=dict() - for key in dat: - ret[key] = np.zeros([self.params['VolSize'][0], self.params['VolSize'][1], self.params['VolSize'][2]], dtype=np.float32) - - img=dat[key] - - #we rotate the image according to its transformation using the direction and according to the final spacing we want - factor = np.asarray(img.GetSpacing()) / [self.params['dstRes'][0], self.params['dstRes'][1], - self.params['dstRes'][2]] - - factorSize = np.asarray(img.GetSize() * factor, dtype=float) - - newSize = np.max([factorSize, self.params['VolSize']], axis=0) - - newSize = newSize.astype(dtype=int) - - T=sitk.AffineTransform(3) - T.SetMatrix(img.GetDirection()) - - resampler = sitk.ResampleImageFilter() - resampler.SetReferenceImage(img) - resampler.SetOutputSpacing([self.params['dstRes'][0], self.params['dstRes'][1], self.params['dstRes'][2]]) - resampler.SetSize(newSize) - resampler.SetInterpolator(method) - if self.params['normDir']: - resampler.SetTransform(T.GetInverse()) - - imgResampled = resampler.Execute(img) - - - imgCentroid = np.asarray(newSize, dtype=float) / 2.0 - - imgStartPx = (imgCentroid - self.params['VolSize'] / 2.0).astype(dtype=int) - - regionExtractor = sitk.RegionOfInterestImageFilter() - regionExtractor.SetSize(list(self.params['VolSize'].astype(dtype=int))) - regionExtractor.SetIndex(list(imgStartPx)) - - imgResampledCropped = regionExtractor.Execute(imgResampled) - - ret[key] = np.transpose(sitk.GetArrayFromImage(imgResampledCropped).astype(dtype=float), [2, 1, 0]) - - return ret - - - def writeResultsFromNumpyLabel(self,result,key): - img = self.sitkImages[key] - - toWrite=sitk.Image(img.GetSize()[0],img.GetSize()[1],img.GetSize()[2],sitk.sitkFloat32) - - factor = np.asarray(img.GetSpacing()) / [self.params['dstRes'][0], self.params['dstRes'][1], - self.params['dstRes'][2]] - - factorSize = np.asarray(img.GetSize() * factor, dtype=float) - - newSize = np.max([factorSize, self.params['VolSize']], axis=0) - - newSize = newSize.astype(dtype=int) - - T = sitk.AffineTransform(3) - T.SetMatrix(img.GetDirection()) - - resampler = sitk.ResampleImageFilter() - resampler.SetReferenceImage(img) - resampler.SetOutputSpacing([self.params['dstRes'][0], self.params['dstRes'][1], self.params['dstRes'][2]]) - resampler.SetSize(newSize) - resampler.SetInterpolator(sitk.sitkNearestNeighbor) - - if self.params['normDir']: - resampler.SetTransform(T.GetInverse()) - - toWrite = resampler.Execute(toWrite) - - imgCentroid = np.asarray(newSize, dtype=float) / 2.0 - - imgStartPx = (imgCentroid - self.params['VolSize'] / 2.0).astype(dtype=int) - - for dstX, srcX in zip(range(0, result.shape[0]), range(imgStartPx[0],int(imgStartPx[0]+self.params['VolSize'][0]))): - for dstY, srcY in zip(range(0, result.shape[1]), range(imgStartPx[1], int(imgStartPx[1]+self.params['VolSize'][1]))): - for dstZ, srcZ in zip(range(0, result.shape[2]), range(imgStartPx[2], int(imgStartPx[2]+self.params['VolSize'][2]))): - try: - toWrite.SetPixel(int(srcX),int(srcY),int(srcZ),float(result[dstX,dstY,dstZ])) - except: - pass - - - resampler.SetOutputSpacing([img.GetSpacing()[0], img.GetSpacing()[1], img.GetSpacing()[2]]) - resampler.SetSize(img.GetSize()) - - if self.params['normDir']: - resampler.SetTransform(T) - - toWrite = resampler.Execute(toWrite) - - thfilter=sitk.BinaryThresholdImageFilter() - thfilter.SetInsideValue(1) - thfilter.SetOutsideValue(0) - thfilter.SetLowerThreshold(0.5) - toWrite = thfilter.Execute(toWrite) - - #connected component analysis (better safe than sorry) - - cc = sitk.ConnectedComponentImageFilter() - toWritecc = cc.Execute(sitk.Cast(toWrite,sitk.sitkUInt8)) - - arrCC=np.transpose(sitk.GetArrayFromImage(toWritecc).astype(dtype=float), [2, 1, 0]) - - lab=np.zeros(int(np.max(arrCC)+1),dtype=float) - - for i in range(1,int(np.max(arrCC)+1)): - lab[i]=np.sum(arrCC==i) - - activeLab=np.argmax(lab) - - toWrite = (toWritecc==activeLab) - - toWrite = sitk.Cast(toWrite,sitk.sitkUInt8) - - writer = sitk.ImageFileWriter() - filename, ext = splitext(key) - #print join(self.resultsDir, filename + '_result' + ext) - writer.SetFileName(join(self.resultsDir, filename + '_result' + ext)) - writer.Execute(toWrite) - diff --git a/examples/VNet/LICENSE b/examples/VNet/LICENSE deleted file mode 100644 index 9cecc1d46..000000000 --- a/examples/VNet/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {one line to give the program's name and a brief idea of what it does.} - Copyright (C) {year} {name of author} - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - {project} Copyright (C) {year} {fullname} - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/examples/VNet/README.md b/examples/VNet/README.md deleted file mode 100644 index 3fe227608..000000000 --- a/examples/VNet/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# VNet -https://sagarhukkire.github.io/Vnet-Cafffe_Guide/ diff --git a/examples/VNet/VNet.py b/examples/VNet/VNet.py deleted file mode 100644 index 40a6a4a16..000000000 --- a/examples/VNet/VNet.py +++ /dev/null @@ -1,197 +0,0 @@ -import caffe -import numpy as np -import matplotlib.pyplot as plt -import matplotlib -import os -import DataManager as DM -import utilities -from os.path import splitext -from multiprocessing import Process, Queue - -class VNet(object): - params=None - dataManagerTrain=None - dataManagerTest=None - - def __init__(self,params): - self.params=params - caffe.set_mode_cpu() - - def prepareDataThread(self, dataQueue, numpyImages, numpyGT): - - nr_iter = self.params['ModelParams']['numIterations'] - batchsize = self.params['ModelParams']['batchsize'] - - keysIMG = numpyImages.keys() - - nr_iter_dataAug = nr_iter*batchsize - np.random.seed() - whichDataList = np.random.randint(len(keysIMG), size=int(nr_iter_dataAug/self.params['ModelParams']['nProc'])) - whichDataForMatchingList = np.random.randint(len(keysIMG), size=int(nr_iter_dataAug/self.params['ModelParams']['nProc'])) - - for whichData,whichDataForMatching in zip(whichDataList,whichDataForMatchingList): - filename, ext = splitext(keysIMG[whichData]) - - currGtKey = filename + '_segmentation' + ext - currImgKey = filename + ext - - # data agugumentation through hist matching across different examples... - ImgKeyMatching = keysIMG[whichDataForMatching] - - defImg = numpyImages[currImgKey] - defLab = numpyGT[currGtKey] - - defImg = utilities.hist_match(defImg, numpyImages[ImgKeyMatching]) - - if(np.random.rand(1)[0]>0.5): #do not apply deformations always, just sometimes - defImg, defLab = utilities.produceRandomlyDeformedImage(defImg, defLab, - self.params['ModelParams']['numcontrolpoints'], - self.params['ModelParams']['sigma']) - - weightData = np.zeros_like(defLab,dtype=float) - weightData[defLab == 1] = np.prod(defLab.shape) / np.sum((defLab==1).astype(dtype=np.float32)) - weightData[defLab == 0] = np.prod(defLab.shape) / np.sum((defLab == 0).astype(dtype=np.float32)) - - dataQueue.put(tuple((defImg,defLab, weightData))) - - def trainThread(self,dataQueue,solver): - - nr_iter = self.params['ModelParams']['numIterations'] - batchsize = self.params['ModelParams']['batchsize'] - - batchData = np.zeros((batchsize, 1, self.params['DataManagerParams']['VolSize'][0], self.params['DataManagerParams']['VolSize'][1], self.params['DataManagerParams']['VolSize'][2]), dtype=float) - batchLabel = np.zeros((batchsize, 1, self.params['DataManagerParams']['VolSize'][0], self.params['DataManagerParams']['VolSize'][1], self.params['DataManagerParams']['VolSize'][2]), dtype=float) - - #only used if you do weighted multinomial logistic regression - batchWeight = np.zeros((batchsize, 1, self.params['DataManagerParams']['VolSize'][0], - self.params['DataManagerParams']['VolSize'][1], - self.params['DataManagerParams']['VolSize'][2]), dtype=float) - - train_loss = np.zeros(nr_iter) - for it in range(nr_iter): - for i in range(batchsize): - [defImg, defLab, defWeight] = dataQueue.get() - - batchData[i, 0, :, :, :] = defImg.astype(dtype=np.float32) - batchLabel[i, 0, :, :, :] = (defLab > 0.5).astype(dtype=np.float32) - batchWeight[i, 0, :, :, :] = defWeight.astype(dtype=np.float32) - - solver.net.blobs['data'].data[...] = batchData.astype(dtype=np.float32) - solver.net.blobs['label'].data[...] = batchLabel.astype(dtype=np.float32) - #solver.net.blobs['labelWeight'].data[...] = batchWeight.astype(dtype=np.float32) - #use only if you do softmax with loss - - - solver.step(1) # this does the training - train_loss[it] = solver.net.blobs['loss'].data - - #if (np.mod(it, 10) == 0): - # plt.clf() - # plt.plot(range(0, it), train_loss[0:it]) - # plt.pause(0.00000001) - - - #matplotlib.pyplot.show() - - - def train(self): - print self.params['ModelParams']['dirTrain'] - - #we define here a data manage object - self.dataManagerTrain = DM.DataManager(self.params['ModelParams']['dirTrain'], - self.params['ModelParams']['dirResult'], - self.params['DataManagerParams']) - - self.dataManagerTrain.loadTrainingData() #loads in sitk format - - howManyImages = len(self.dataManagerTrain.sitkImages) - howManyGT = len(self.dataManagerTrain.sitkGT) - - assert howManyGT == howManyImages - - print "The dataset has shape: data - " + str(howManyImages) + ". labels - " + str(howManyGT) - - test_interval = 50000 - # Write a temporary solver text file because pycaffe is stupid - with open("solver.prototxt", 'w') as f: - f.write("net: \"" + self.params['ModelParams']['prototxtTrain'] + "\" \n") - f.write("base_lr: " + str(self.params['ModelParams']['baseLR']) + " \n") - f.write("momentum: 0.99 \n") - f.write("weight_decay: 0.0005 \n") - f.write("lr_policy: \"step\" \n") - f.write("stepsize: 20000 \n") - f.write("gamma: 0.1 \n") - f.write("display: 1 \n") - f.write("snapshot: 500 \n") - f.write("snapshot_prefix: \"" + self.params['ModelParams']['dirSnapshots'] + "\" \n") - #f.write("test_iter: 3 \n") - #f.write("test_interval: " + str(test_interval) + "\n") - - f.close() - solver = caffe.SGDSolver("solver.prototxt") - os.remove("solver.prototxt") - - if (self.params['ModelParams']['snapshot'] > 0): - solver.restore(self.params['ModelParams']['dirSnapshots'] + "_iter_" + str( - self.params['ModelParams']['snapshot']) + ".solverstate") - - #plt.ion() - - numpyImages = self.dataManagerTrain.getNumpyImages() - numpyGT = self.dataManagerTrain.getNumpyGT() - - #numpyImages['Case00.mhd'] - #numpy images is a dictionary that you index in this way (with filenames) - - for key in numpyImages: - mean = np.mean(numpyImages[key][numpyImages[key]>0]) - std = np.std(numpyImages[key][numpyImages[key]>0]) - - numpyImages[key]-=mean - numpyImages[key]/=std - - dataQueue = Queue(30) #max 50 images in queue - dataPreparation = [None] * self.params['ModelParams']['nProc'] - - #thread creation - for proc in range(0,self.params['ModelParams']['nProc']): - dataPreparation[proc] = Process(target=self.prepareDataThread, args=(dataQueue, numpyImages, numpyGT)) - dataPreparation[proc].daemon = True - dataPreparation[proc].start() - - self.trainThread(dataQueue, solver) - - - def test(self): - self.dataManagerTest = DM.DataManager(self.params['ModelParams']['dirTest'], self.params['ModelParams']['dirResult'], self.params['DataManagerParams']) - self.dataManagerTest.loadTestData() - - net = caffe.Net(self.params['ModelParams']['prototxtTest'], - os.path.join(self.params['ModelParams']['dirSnapshots'],"_iter_" + str(self.params['ModelParams']['snapshot']) + ".caffemodel"), - caffe.TEST) - - numpyImages = self.dataManagerTest.getNumpyImages() - - for key in numpyImages: - mean = np.mean(numpyImages[key][numpyImages[key]>0]) - std = np.std(numpyImages[key][numpyImages[key]>0]) - - numpyImages[key] -= mean - numpyImages[key] /= std - - results = dict() - - for key in numpyImages: - - btch = np.reshape(numpyImages[key],[1,1,numpyImages[key].shape[0],numpyImages[key].shape[1],numpyImages[key].shape[2]]) - - net.blobs['data'].data[...] = btch - - out = net.forward() - l = out["labelmap"] - labelmap = np.squeeze(l[0,1,:,:,:]) - - results[key] = np.squeeze(labelmap) - - self.dataManagerTest.writeResultsFromNumpyLabel(np.squeeze(labelmap),key) - diff --git a/examples/VNet/main.py b/examples/VNet/main.py deleted file mode 100644 index 6283e23e5..000000000 --- a/examples/VNet/main.py +++ /dev/null @@ -1,43 +0,0 @@ -import sys -import os -import numpy as np -import VNet as VN - -basePath=os.getcwd() - -params = dict() -params['DataManagerParams']=dict() -params['ModelParams']=dict() - -#params of the algorithm -params['ModelParams']['numcontrolpoints']=2 -params['ModelParams']['sigma']=15 -params['ModelParams']['device']=0 -params['ModelParams']['prototxtTrain']=os.path.join(basePath,'../../models/intel_optimized_models/VNet/train_noPooling_ResNet_cinque.prototxt') -params['ModelParams']['prototxtTest']=os.path.join(basePath,'../../models/intel_optimized_models/VNet/test_noPooling_ResNet_cinque.prototxt') -params['ModelParams']['snapshot']=0 -params['ModelParams']['dirTrain']=os.path.join(basePath,'Dataset/Train') -params['ModelParams']['dirTest']=os.path.join(basePath,'Dataset/Test') -params['ModelParams']['dirResult']=os.path.join(basePath,'Results') #where we need to save the results (relative to the base path) -params['ModelParams']['dirSnapshots']=os.path.join(basePath,'Models/MRI_cinque_snapshots/') #where to save the models while training -params['ModelParams']['batchsize'] = 2 #the batchsize -params['ModelParams']['numIterations'] = 100000 #the number of iterations -params['ModelParams']['baseLR'] = 0.0001 #the learning rate, initial one -params['ModelParams']['nProc'] = 1 #the number of threads to do data augmentation - - -#params of the DataManager -params['DataManagerParams']['dstRes'] = np.asarray([1,1,1.5],dtype=float) -params['DataManagerParams']['VolSize'] = np.asarray([128,128,64],dtype=int) -params['DataManagerParams']['normDir'] = False #if rotates the volume according to its transformation in the mhd file. Not reccommended. - -model=VN.VNet(params) -train = [i for i, j in enumerate(sys.argv) if j == '-train'] -if len(train)>0: - model.train() - -test = [i for i, j in enumerate(sys.argv) if j == '-test'] -if len(test) > 0: - model.test() - - diff --git a/examples/VNet/pyLayer.py b/examples/VNet/pyLayer.py deleted file mode 100644 index 20c9740c2..000000000 --- a/examples/VNet/pyLayer.py +++ /dev/null @@ -1,66 +0,0 @@ -import caffe -import numpy as np - -class DiceLoss(caffe.Layer): - """ - Compute energy based on dice coefficient. - """ - union = None - intersection = None - result = None - gt = None - - def setup(self, bottom, top): - # check input pair - if len(bottom) != 2: - raise Exception("Need two inputs to compute the dice. the result of the softmax and the ground truth.") - - - - def reshape(self, bottom, top): - # check input dimensions match - if bottom[0].count != 2*bottom[1].count: - print bottom[0].data.shape - print bottom[1].data.shape - raise Exception("the dimension of inputs should match") - - # loss output is two scalars (mean and std) - top[0].reshape(1) - - def forward(self, bottom, top): - - dice = np.zeros(bottom[0].data.shape[0],dtype=np.float32) - self.union = np.zeros(bottom[0].data.shape[0],dtype=np.float32) - self.intersection = np.zeros(bottom[0].data.shape[0],dtype=np.float32) - - self.result = np.reshape(np.squeeze(np.argmax(bottom[0].data[...],axis=1)),[bottom[0].data.shape[0],bottom[0].data.shape[2]]) - self.gt = np.reshape(np.squeeze(bottom[1].data[...]),[bottom[1].data.shape[0],bottom[1].data.shape[2]]) - - self.gt = (self.gt > 0.5).astype(dtype=np.float32) - self.result = self.result.astype(dtype=np.float32) - - for i in range(0,bottom[0].data.shape[0]): - # compute dice - CurrResult = (self.result[i,:]).astype(dtype=np.float32) - CurrGT = (self.gt[i,:]).astype(dtype=np.float32) - - self.union[i]=(np.sum(CurrResult) + np.sum(CurrGT)) - self.intersection[i]=(np.sum(CurrResult * CurrGT)) - - dice[i] = 2 * self.intersection[i] / (self.union[i]+0.00001) - print dice[i] - - top[0].data[0]=np.sum(dice) - - def backward(self, top, propagate_down, bottom): - for btm in [0]: - prob = bottom[0].data[...] - bottom[btm].diff[...] = np.zeros(bottom[btm].diff.shape, dtype=np.float32) - for i in range(0, bottom[btm].diff.shape[0]): - - bottom[btm].diff[i, 0, :] += 2.0 * ( - (self.gt[i, :] * self.union[i]) / ((self.union[i]) ** 2) - 2.0*prob[i,1,:]*(self.intersection[i]) / ( - (self.union[i]) ** 2)) - bottom[btm].diff[i, 1, :] -= 2.0 * ( - (self.gt[i, :] * self.union[i]) / ((self.union[i]) ** 2) - 2.0*prob[i,1,:]*(self.intersection[i]) / ( - (self.union[i]) ** 2)) diff --git a/examples/VNet/utilities.py b/examples/VNet/utilities.py deleted file mode 100644 index 57a2c62b6..000000000 --- a/examples/VNet/utilities.py +++ /dev/null @@ -1,140 +0,0 @@ -import numpy as np -import SimpleITK as sitk -import matplotlib.pyplot as plt - -def hist_match(source, template): - """ - Adjust the pixel values of a grayscale image such that its histogram - matches that of a target image - - Arguments: - ----------- - source: np.ndarray - Image to transform; the histogram is computed over the flattened - array - template: np.ndarray - Template image; can have different dimensions to source - Returns: - ----------- - matched: np.ndarray - The transformed output image - """ - - oldshape = source.shape - source = source.ravel() - template = template.ravel() - - # get the set of unique pixel values and their corresponding indices and - # counts - s_values, bin_idx, s_counts = np.unique(source, return_inverse=True, - return_counts=True) - t_values, t_counts = np.unique(template, return_counts=True) - - # take the cumsum of the counts and normalize by the number of pixels to - # get the empirical cumulative distribution functions for the source and - # template images (maps pixel value --> quantile) - s_quantiles = np.cumsum(s_counts).astype(np.float64) - s_quantiles /= s_quantiles[-1] - t_quantiles = np.cumsum(t_counts).astype(np.float64) - t_quantiles /= t_quantiles[-1] - - # interpolate linearly to find the pixel values in the template image - # that correspond most closely to the quantiles in the source image - #interp_t_values = np.zeros_like(source,dtype=float) - interp_t_values = np.interp(s_quantiles, t_quantiles, t_values) - - return interp_t_values[bin_idx].reshape(oldshape) - -def sitk_show(nda, title=None, margin=0.0, dpi=40): - figsize = (1 + margin) * nda.shape[0] / dpi, (1 + margin) * nda.shape[1] / dpi - - extent = (0, nda.shape[1], nda.shape[0], 0) - fig = plt.figure(figsize=figsize, dpi=dpi) - ax = fig.add_axes([margin, margin, 1 - 2*margin, 1 - 2*margin]) - - plt.set_cmap("gray") - for k in range(0,nda.shape[2]): - print "printing slice "+str(k) - ax.imshow(np.squeeze(nda[:,:,k]),extent=extent,interpolation=None) - plt.draw() - plt.pause(0.1) - #plt.waitforbuttonpress() - -def computeQualityMeasures(lP,lT): - quality=dict() - labelPred=sitk.GetImageFromArray(lP, isVector=False) - labelTrue=sitk.GetImageFromArray(lT, isVector=False) - hausdorffcomputer=sitk.HausdorffDistanceImageFilter() - hausdorffcomputer.Execute(labelTrue>0.5,labelPred>0.5) - quality["avgHausdorff"]=hausdorffcomputer.GetAverageHausdorffDistance() - quality["Hausdorff"]=hausdorffcomputer.GetHausdorffDistance() - - dicecomputer=sitk.LabelOverlapMeasuresImageFilter() - dicecomputer.Execute(labelTrue>0.5,labelPred>0.5) - quality["dice"]=dicecomputer.GetDiceCoefficient() - - return quality - - -def produceRandomlyDeformedImage(image, label, numcontrolpoints, stdDef): - sitkImage=sitk.GetImageFromArray(image, isVector=False) - sitklabel=sitk.GetImageFromArray(label, isVector=False) - - transfromDomainMeshSize=[numcontrolpoints]*sitkImage.GetDimension() - - tx = sitk.BSplineTransformInitializer(sitkImage,transfromDomainMeshSize) - - - params = tx.GetParameters() - - paramsNp=np.asarray(params,dtype=float) - paramsNp = paramsNp + np.random.randn(paramsNp.shape[0])*stdDef - - paramsNp[0:int(len(params)/3)]=0 #remove z deformations! The resolution in z is too bad - - params=tuple(paramsNp) - tx.SetParameters(params) - - resampler = sitk.ResampleImageFilter() - resampler.SetReferenceImage(sitkImage) - resampler.SetInterpolator(sitk.sitkLinear) - resampler.SetDefaultPixelValue(0) - resampler.SetTransform(tx) - - resampler.SetDefaultPixelValue(0) - outimgsitk = resampler.Execute(sitkImage) - outlabsitk = resampler.Execute(sitklabel) - - outimg = sitk.GetArrayFromImage(outimgsitk) - outimg = outimg.astype(dtype=np.float32) - - outlbl = sitk.GetArrayFromImage(outlabsitk) - outlbl = (outlbl>0.5).astype(dtype=np.float32) - - return outimg,outlbl - - -def produceRandomlyTranslatedImage(image, label): - sitkImage = sitk.GetImageFromArray(image, isVector=False) - sitklabel = sitk.GetImageFromArray(label, isVector=False) - - itemindex = np.where(label > 0) - randTrans = (0,np.random.randint(-np.min(itemindex[1])/2,(image.shape[1]-np.max(itemindex[1]))/2),np.random.randint(-np.min(itemindex[0])/2,(image.shape[0]-np.max(itemindex[0]))/2)) - translation = sitk.TranslationTransform(3, randTrans) - - resampler = sitk.ResampleImageFilter() - resampler.SetReferenceImage(sitkImage) - resampler.SetInterpolator(sitk.sitkLinear) - resampler.SetDefaultPixelValue(0) - resampler.SetTransform(translation) - - outimgsitk = resampler.Execute(sitkImage) - outlabsitk = resampler.Execute(sitklabel) - - outimg = sitk.GetArrayFromImage(outimgsitk) - outimg = outimg.astype(dtype=float) - - outlbl = sitk.GetArrayFromImage(outlabsitk) > 0 - outlbl = outlbl.astype(dtype=float) - - return outimg, outlbl diff --git a/examples/faster-rcnn/lib/setup.py b/examples/faster-rcnn/lib/setup.py index df9a0db76..3f06f6020 100644 --- a/examples/faster-rcnn/lib/setup.py +++ b/examples/faster-rcnn/lib/setup.py @@ -78,7 +78,7 @@ def customize_compiler_for_nvcc(self): self.src_extensions.append('.cu') # save references to the default compiler_so and _comple methods - default_compiler_so = self.compiler_so + #default_compiler_so = self.compiler_so super = self._compile # now redefine the _compile method. This gets executed for each @@ -96,7 +96,7 @@ def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts): super(obj, src, ext, cc_args, postargs, pp_opts) # reset the default compiler_so, which we might have changed for cuda - self.compiler_so = default_compiler_so + #self.compiler_so = default_compiler_so # inject our redefined _compile method into the class self._compile = _compile diff --git a/examples/rfcn/lib/setup.py b/examples/rfcn/lib/setup.py index df9a0db76..3f06f6020 100644 --- a/examples/rfcn/lib/setup.py +++ b/examples/rfcn/lib/setup.py @@ -78,7 +78,7 @@ def customize_compiler_for_nvcc(self): self.src_extensions.append('.cu') # save references to the default compiler_so and _comple methods - default_compiler_so = self.compiler_so + #default_compiler_so = self.compiler_so super = self._compile # now redefine the _compile method. This gets executed for each @@ -96,7 +96,7 @@ def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts): super(obj, src, ext, cc_args, postargs, pp_opts) # reset the default compiler_so, which we might have changed for cuda - self.compiler_so = default_compiler_so + #self.compiler_so = default_compiler_so # inject our redefined _compile method into the class self._compile = _compile diff --git a/external/mkl/prepare_mkl.sh b/external/mkl/prepare_mkl.sh index 5fcb13e8e..5022263b4 100755 --- a/external/mkl/prepare_mkl.sh +++ b/external/mkl/prepare_mkl.sh @@ -74,11 +74,11 @@ echo $VERSION_LINE # Return Version Line # MKL DST=`dirname $0` OMP=0 -VERSION_MATCH=20180928 -ARCHIVE_BASENAME=mklml_lnx_2019.0.1.20180928.tgz +VERSION_MATCH=20190220 +ARCHIVE_BASENAME=mklml_lnx_2019.0.3.20190220.tgz MKL_CONTENT_DIR=`echo $ARCHIVE_BASENAME | rev | cut -d "." -f 2- | rev` -MKLURL="https://github.com/intel/mkl-dnn/releases/download/v0.17-rc/$ARCHIVE_BASENAME" +MKLURL="https://github.com/intel/mkl-dnn/releases/download/v0.18/$ARCHIVE_BASENAME" # there are diffrent MKL lib to be used for GCC and for ICC reg='^[0-9]+$' VERSION_LINE=`GetVersionName $MKLROOT` diff --git a/include/caffe/mkldnn_memory.hpp b/include/caffe/mkldnn_memory.hpp index 0204f017d..07cf5dd88 100644 --- a/include/caffe/mkldnn_memory.hpp +++ b/include/caffe/mkldnn_memory.hpp @@ -41,6 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include +#include #include "boost/enable_shared_from_this.hpp" #include "caffe/blob.hpp" #include "caffe/common.hpp" @@ -51,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "caffe/net.hpp" using namespace mkldnn; +using namespace boost::interprocess; namespace caffe { @@ -67,7 +70,8 @@ class MKLDNNMemoryDescriptorBase : public PrvMemDescr , int mask=0 , bool is_sum=false , bool is_wino=false - , bool is_weight=false); + , bool is_weight=false + , std::string _name=""); ~MKLDNNMemoryDescriptorBase() {} @@ -118,6 +122,8 @@ class MKLDNNMemoryDescriptorBase : public PrvMemDescr MKLDNNLayer* mkldnn_layer() const { return _mkldnn_layer; } std::string name; // for debugging purposes + shared_memory_object *shm; + mapped_region *region; protected: void check_usr_with_prv_descriptors(); void set_prv_memory(shared_ptr memory) @@ -144,8 +150,16 @@ class MKLDNNMemoryDescriptorBase : public PrvMemDescr // find out a free buf in the circleBuf queue _m_memory = CircleBuf::Instance()->GetFreeBuf(); } else { - bool cuda; - CaffeMallocHost(&_m_memory, _prv_memory_pd->get_size(), &cuda); + if (getenv("CAFFE_INFERENCE_WEIGHT_SHARING")) { + shm = new shared_memory_object(open_or_create, name.c_str(), read_write); + //Set size + shm->truncate(_prv_memory_pd->get_size()); + region = new mapped_region(*shm, read_write); + _m_memory = region->get_address(); + } else { + bool cuda; + CaffeMallocHost(&_m_memory, _prv_memory_pd->get_size(), &cuda); + } } _prv_memory = shared_ptr(new memory(*_prv_memory_pd, _m_memory)); } else @@ -223,7 +237,8 @@ class MKLDNNMemoryDescriptor : public MKLDNNMemoryDescriptorBase { , int mask=0 , bool is_sum=false , bool is_wino=false - , bool is_weight=false); + , bool is_weight=false + , std::string name=""); virtual void convert_from_prv(void* cpu_ptr); virtual void convert_to_prv(void* cpu_ptr); @@ -272,8 +287,9 @@ class MKLDNNData : public MKLDNNMemoryDescriptor , int mask=0 , bool is_sum=false , bool is_wino=false - , bool is_weight=false) - : MKLDNNMemoryDescriptor(usr_memory_pd, prv_memory_pd, blob, mkldnn_layer, scale, mask, is_sum, is_wino, is_weight) {} + , bool is_weight=false + , std::string name="") + : MKLDNNMemoryDescriptor(usr_memory_pd, prv_memory_pd, blob, mkldnn_layer, scale, mask, is_sum, is_wino, is_weight, name) {} }; template diff --git a/include/caffe/net.hpp b/include/caffe/net.hpp index 4a0a3cdff..4d95b1f47 100644 --- a/include/caffe/net.hpp +++ b/include/caffe/net.hpp @@ -124,7 +124,7 @@ class Net { virtual ~Net() {} /// @brief Buffer Queue for reducing cache missing and saving memory footprint of MKLDNN layer. - static vector circleBuf; + static vector circleBuf; /// @brief Initialize a network with a NetParameter. void Init(const NetParameter& param); @@ -385,6 +385,14 @@ class Net { NetParameter* param_compiled); + /** + * @brief This is rule that analyze layer if it is of type MKLDNNReLU and if that is the case + * and previous layer which serves as input layer to MKLDNNReLU Layer is MKLDNNFC + * then MKLDNNReLU layer can be dropped + */ + static void CompilationRuleFuseFCRelu(const NetParameter& param, + NetParameter* param_compiled); + /** * @brief If find "Conv--BN--Scale" in current network, merge BN and Scale layer into Convolution * layers, this optimization only works in caffe TEST phase now. @@ -588,7 +596,7 @@ class Net { DISABLE_COPY_AND_ASSIGN(Net); }; -template vector Net::circleBuf; +template vector Net::circleBuf; } // namespace caffe diff --git a/include/caffe/syncedmem.hpp b/include/caffe/syncedmem.hpp index 0ea0f13f7..6e42554d1 100644 --- a/include/caffe/syncedmem.hpp +++ b/include/caffe/syncedmem.hpp @@ -75,9 +75,12 @@ inline void CaffeMallocHost(void** ptr, size_t size, bool* use_cuda) { #ifdef USE_MKL *ptr = mkl_malloc(size ? size : 1, 64); #else - //*ptr = malloc(size); - int rc = ::posix_memalign(ptr, 64, size); - assert(rc == 0); + #if defined(_MSC_EXTENSIONS) + *ptr = _aligned_malloc(size, 64); + #else + int rc = ::posix_memalign(ptr, 64, size); + assert(rc == 0); + #endif #endif #ifdef USE_MLSL @@ -105,8 +108,11 @@ inline void CaffeFreeHost(void* ptr, bool use_cuda) { #ifdef USE_MKL mkl_free(ptr); #else - //free(ptr); + #if defined(_MSC_EXTENSIONS) + _aligned_free(ptr); + #else ::free(ptr); + #endif #endif #ifdef USE_MLSL diff --git a/include/caffe/util/compareToolUtilities.h b/include/caffe/util/compareToolUtilities.h index 754890b0d..7e6e37a26 100644 --- a/include/caffe/util/compareToolUtilities.h +++ b/include/caffe/util/compareToolUtilities.h @@ -38,7 +38,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef INCLUDE_CAFFE_UTIL_COMPARETOOLUTILITIES_H_ #define INCLUDE_CAFFE_UTIL_COMPARETOOLUTILITIES_H_ -#include #include #include #include diff --git a/include/caffe/util/cpu_info.hpp b/include/caffe/util/cpu_info.hpp index 5db9e3bff..d2e314756 100644 --- a/include/caffe/util/cpu_info.hpp +++ b/include/caffe/util/cpu_info.hpp @@ -39,7 +39,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define CAFFE_UTIL_CPU_INFO_HPP #include -#include +#if defined(_MSC_EXTENSIONS) + #define NOMINMAX + #include + #include + #include +#else + #include +#endif #include #include #include @@ -57,10 +64,18 @@ struct Processor { unsigned coreId; unsigned cpuCores; unsigned speedMHz; - + size_t mask; Processor(); }; +#if defined(_MSC_EXTENSIONS) +// 2 processor group should be enough for current h/w. +// But here we reserve 4 processor group for future extension. +struct cpu_set_t { + size_t Mask[4]; +}; +#endif + class CpuInfoInterface { public: virtual ~CpuInfoInterface() {} @@ -108,26 +123,29 @@ class Collection : public CollectionInterface { virtual const Processor &getProcessor(unsigned processorId); private: - CpuInfoInterface &cpuInfo; - unsigned totalNumberOfSockets; - unsigned totalNumberOfCpuCores; - std::vector processors; - Processor *currentProcessor; - - Collection(const Collection &collection); - Collection &operator =(const Collection &collection); - - void parseCpuInfo(); +#if !defined(_MSC_EXTENSIONS) void parseCpuInfoLine(const char *cpuInfoLine); void parseValue(const char *fieldName, const char *valueString); void appendNewProcessor(); bool beginsWith(const char *lineBuffer, const char *text) const; unsigned parseInteger(const char *text) const; unsigned extractSpeedFromModelName(const char *text) const; +#endif void collectBasicCpuInformation(); void updateCpuInformation(const Processor &processor, unsigned numberOfUniquePhysicalId); + + CpuInfoInterface &cpuInfo; + unsigned totalNumberOfSockets; + unsigned totalNumberOfCpuCores; + std::vector processors; + Processor *currentProcessor; + + Collection(const Collection &collection); + Collection &operator =(const Collection &collection); + + void parseCpuInfo(); }; #ifdef _OPENMP @@ -144,6 +162,7 @@ class OpenMpManager { static bool isMajorThread(boost::thread::id currentThread); static unsigned getProcessorSpeedMHz(); + static unsigned getNumaNode(); private: boost::thread::id mainThreadId; diff --git a/mkldnn.commit b/mkldnn.commit index a6ef2b9e7..2c7230abb 100644 --- a/mkldnn.commit +++ b/mkldnn.commit @@ -1 +1 @@ -830a10059a018cd2634d94195140cf2d8790a75a +9a865c2b935e611f4ea451a26bebe45ec5ef4160 diff --git a/models/intel_optimized_models/int8/ssd_int8.prototxt b/models/intel_optimized_models/int8/ssd_int8.prototxt deleted file mode 100644 index 4a0ed0332..000000000 --- a/models/intel_optimized_models/int8/ssd_int8.prototxt +++ /dev/null @@ -1,1955 +0,0 @@ -# For INT8 reference -name: "VGG_VOC0712_SSD_300x300_test" -layer { - name: "data" - type: "DummyData" - top: "data" - dummy_data_param { - data_filler { - type: "constant" - value: 0.01 - } - shape { - dim: 32 - dim: 3 - dim: 300 - dim: 300 - } - } -} -layer { - name: "data" - type: "DummyData" - top: "label" - dummy_data_param { - data_filler { - type: "constant" - value: 1 - } - shape { - dim: 1 - dim: 1 - dim: 1 - dim: 8 - } - } -} -layer { - name: "conv1_1" - type: "Convolution" - bottom: "data" - top: "conv1_1" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 64 - pad: 1 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } -} -layer { - name: "relu1_1" - type: "ReLU" - bottom: "conv1_1" - top: "conv1_1" -} -layer { - name: "conv1_2" - type: "Convolution" - bottom: "conv1_1" - top: "conv1_2" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 64 - pad: 1 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 0.319999992847 - scale_out: 0.0799999982119 - scale_params: 454.859985352 - } -} -layer { - name: "relu1_2" - type: "ReLU" - bottom: "conv1_2" - top: "conv1_2" -} -layer { - name: "pool1" - type: "Pooling" - bottom: "conv1_2" - top: "pool1" - pooling_param { - pool: MAX - kernel_size: 2 - stride: 2 - } -} -layer { - name: "conv2_1" - type: "Convolution" - bottom: "pool1" - top: "conv2_1" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 128 - pad: 1 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 0.0799999982119 - scale_out: 0.0599999986589 - scale_params: 299.019989014 - } -} -layer { - name: "relu2_1" - type: "ReLU" - bottom: "conv2_1" - top: "conv2_1" -} -layer { - name: "conv2_2" - type: "Convolution" - bottom: "conv2_1" - top: "conv2_2" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 128 - pad: 1 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 0.0599999986589 - scale_out: 0.0500000007451 - scale_params: 540.909973145 - } -} -layer { - name: "relu2_2" - type: "ReLU" - bottom: "conv2_2" - top: "conv2_2" -} -layer { - name: "pool2" - type: "Pooling" - bottom: "conv2_2" - top: "pool2" - pooling_param { - pool: MAX - kernel_size: 2 - stride: 2 - } -} -layer { - name: "conv3_1" - type: "Convolution" - bottom: "pool2" - top: "conv3_1" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 256 - pad: 1 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 0.0500000007451 - scale_out: 0.0399999991059 - scale_params: 256.5 - } -} -layer { - name: "relu3_1" - type: "ReLU" - bottom: "conv3_1" - top: "conv3_1" -} -layer { - name: "conv3_2" - type: "Convolution" - bottom: "conv3_1" - top: "conv3_2" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 256 - pad: 1 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 0.0399999991059 - scale_out: 0.0500000007451 - scale_params: 306.799987793 - } -} -layer { - name: "relu3_2" - type: "ReLU" - bottom: "conv3_2" - top: "conv3_2" -} -layer { - name: "conv3_3" - type: "Convolution" - bottom: "conv3_2" - top: "conv3_3" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 256 - pad: 1 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 0.0500000007451 - scale_out: 0.0599999986589 - scale_params: 352.630004883 - } -} -layer { - name: "relu3_3" - type: "ReLU" - bottom: "conv3_3" - top: "conv3_3" -} -layer { - name: "pool3" - type: "Pooling" - bottom: "conv3_3" - top: "pool3" - pooling_param { - pool: MAX - kernel_size: 2 - stride: 2 - } -} -layer { - name: "conv4_1" - type: "Convolution" - bottom: "pool3" - top: "conv4_1" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 512 - pad: 1 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 0.0599999986589 - scale_out: 0.0799999982119 - scale_params: 478.589996338 - } -} -layer { - name: "relu4_1" - type: "ReLU" - bottom: "conv4_1" - top: "conv4_1" -} -layer { - name: "conv4_2" - type: "Convolution" - bottom: "conv4_1" - top: "conv4_2" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 512 - pad: 1 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 0.0799999982119 - scale_out: 0.180000007153 - scale_params: 485.910003662 - } -} -layer { - name: "relu4_2" - type: "ReLU" - bottom: "conv4_2" - top: "conv4_2" -} -layer { - name: "conv4_3" - type: "Convolution" - bottom: "conv4_2" - top: "conv4_3" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 512 - pad: 1 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 0.180000007153 - scale_out: 0.40000000596 - scale_params: 552.33001709 - } -} -layer { - name: "relu4_3" - type: "ReLU" - bottom: "conv4_3" - top: "conv4_3" -} -layer { - name: "pool4" - type: "Pooling" - bottom: "conv4_3" - top: "pool4" - pooling_param { - pool: MAX - kernel_size: 2 - stride: 2 - } -} -layer { - name: "conv5_1" - type: "Convolution" - bottom: "pool4" - top: "conv5_1" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 512 - pad: 1 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - dilation: 1 - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 0.40000000596 - scale_out: 0.550000011921 - scale_params: 766.260009766 - } -} -layer { - name: "relu5_1" - type: "ReLU" - bottom: "conv5_1" - top: "conv5_1" -} -layer { - name: "conv5_2" - type: "Convolution" - bottom: "conv5_1" - top: "conv5_2" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 512 - pad: 1 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - dilation: 1 - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 0.550000011921 - scale_out: 1.16999995708 - scale_params: 838.429992676 - } -} -layer { - name: "relu5_2" - type: "ReLU" - bottom: "conv5_2" - top: "conv5_2" -} -layer { - name: "conv5_3" - type: "Convolution" - bottom: "conv5_2" - top: "conv5_3" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 512 - pad: 1 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - dilation: 1 - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 1.16999995708 - scale_out: 1.78999996185 - scale_params: 717.200012207 - } -} -layer { - name: "relu5_3" - type: "ReLU" - bottom: "conv5_3" - top: "conv5_3" -} -layer { - name: "pool5" - type: "Pooling" - bottom: "conv5_3" - top: "pool5" - pooling_param { - pool: MAX - pad: 1 - kernel_size: 3 - stride: 1 - } -} -layer { - name: "fc6" - type: "Convolution" - bottom: "pool5" - top: "fc6" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 1024 - pad: 6 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - dilation: 6 - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 1.78999996185 - scale_out: 5.80999994278 - scale_params: 581.219970703 - } -} -layer { - name: "relu6" - type: "ReLU" - bottom: "fc6" - top: "fc6" -} -layer { - name: "fc7" - type: "Convolution" - bottom: "fc6" - top: "fc7" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 1024 - kernel_size: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 5.80999994278 - scale_out: 23.5200004578 - scale_params: 937.08001709 - } -} -layer { - name: "relu7" - type: "ReLU" - bottom: "fc7" - top: "fc7" -} -layer { - name: "conv6_1" - type: "Convolution" - bottom: "fc7" - top: "conv6_1" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 256 - pad: 0 - kernel_size: 1 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 23.5200004578 - scale_out: 41.3400001526 - scale_params: 590.469970703 - } -} -layer { - name: "conv6_1_relu" - type: "ReLU" - bottom: "conv6_1" - top: "conv6_1" -} -layer { - name: "conv6_2" - type: "Convolution" - bottom: "conv6_1" - top: "conv6_2" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 512 - pad: 1 - kernel_size: 3 - stride: 2 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 41.3400001526 - scale_out: 32.3899993896 - scale_params: 1789.36999512 - } -} -layer { - name: "conv6_2_relu" - type: "ReLU" - bottom: "conv6_2" - top: "conv6_2" -} -layer { - name: "conv7_1" - type: "Convolution" - bottom: "conv6_2" - top: "conv7_1" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 128 - pad: 0 - kernel_size: 1 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 32.3899993896 - scale_out: 20.6700000763 - scale_params: 882.909973145 - } -} -layer { - name: "conv7_1_relu" - type: "ReLU" - bottom: "conv7_1" - top: "conv7_1" -} -layer { - name: "conv7_2" - type: "Convolution" - bottom: "conv7_1" - top: "conv7_2" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 256 - pad: 1 - kernel_size: 3 - stride: 2 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 20.6700000763 - scale_out: 14.25 - scale_params: 1246.82995605 - } -} -layer { - name: "conv7_2_relu" - type: "ReLU" - bottom: "conv7_2" - top: "conv7_2" -} -layer { - name: "conv8_1" - type: "Convolution" - bottom: "conv7_2" - top: "conv8_1" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 128 - pad: 0 - kernel_size: 1 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 14.25 - scale_out: 18.6299991608 - scale_params: 646.679992676 - } -} -layer { - name: "conv8_1_relu" - type: "ReLU" - bottom: "conv8_1" - top: "conv8_1" -} -layer { - name: "conv8_2" - type: "Convolution" - bottom: "conv8_1" - top: "conv8_2" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 256 - pad: 0 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 18.6299991608 - scale_out: 18.4300003052 - scale_params: 1516.22998047 - } -} -layer { - name: "conv8_2_relu" - type: "ReLU" - bottom: "conv8_2" - top: "conv8_2" -} -layer { - name: "conv9_1" - type: "Convolution" - bottom: "conv8_2" - top: "conv9_1" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 128 - pad: 0 - kernel_size: 1 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 18.4300003052 - scale_out: 16.2800006866 - scale_params: 864.780029297 - } -} -layer { - name: "conv9_1_relu" - type: "ReLU" - bottom: "conv9_1" - top: "conv9_1" -} -layer { - name: "conv9_2" - type: "Convolution" - bottom: "conv9_1" - top: "conv9_2" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 256 - pad: 0 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 16.2800006866 - scale_out: 10.6199998856 - scale_params: 1733.91003418 - } -} -layer { - name: "conv9_2_relu" - type: "ReLU" - bottom: "conv9_2" - top: "conv9_2" -} -layer { - name: "conv4_3_norm" - type: "Normalize" - bottom: "conv4_3" - top: "conv4_3_norm" - norm_param { - across_spatial: false - scale_filler { - type: "constant" - value: 20.0 - } - channel_shared: false - } -} -layer { - name: "conv4_3_norm_mbox_loc" - type: "Convolution" - bottom: "conv4_3_norm" - top: "conv4_3_norm_mbox_loc" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 16 - pad: 1 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 22.3600006104 - scale_out: 9.88000011444 - scale_params: 247.979995728 - } -} -layer { - name: "conv4_3_norm_mbox_loc_perm" - type: "Permute" - bottom: "conv4_3_norm_mbox_loc" - top: "conv4_3_norm_mbox_loc_perm" - permute_param { - order: 0 - order: 2 - order: 3 - order: 1 - } -} -layer { - name: "conv4_3_norm_mbox_loc_flat" - type: "Flatten" - bottom: "conv4_3_norm_mbox_loc_perm" - top: "conv4_3_norm_mbox_loc_flat" - flatten_param { - axis: 1 - } -} -layer { - name: "conv4_3_norm_mbox_conf" - type: "Convolution" - bottom: "conv4_3_norm" - top: "conv4_3_norm_mbox_conf" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 84 - pad: 1 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 22.3600006104 - scale_out: 9.13000011444 - scale_params: 793.659973145 - } -} -layer { - name: "conv4_3_norm_mbox_conf_perm" - type: "Permute" - bottom: "conv4_3_norm_mbox_conf" - top: "conv4_3_norm_mbox_conf_perm" - permute_param { - order: 0 - order: 2 - order: 3 - order: 1 - } -} -layer { - name: "conv4_3_norm_mbox_conf_flat" - type: "Flatten" - bottom: "conv4_3_norm_mbox_conf_perm" - top: "conv4_3_norm_mbox_conf_flat" - flatten_param { - axis: 1 - } -} -layer { - name: "conv4_3_norm_mbox_priorbox" - type: "PriorBox" - bottom: "conv4_3_norm" - bottom: "data" - top: "conv4_3_norm_mbox_priorbox" - prior_box_param { - min_size: 30.0 - max_size: 60.0 - aspect_ratio: 2.0 - flip: true - clip: false - variance: 0.10000000149 - variance: 0.10000000149 - variance: 0.20000000298 - variance: 0.20000000298 - step: 8.0 - offset: 0.5 - } -} -layer { - name: "fc7_mbox_loc" - type: "Convolution" - bottom: "fc7" - top: "fc7_mbox_loc" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 24 - pad: 1 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 23.5200004578 - scale_out: 28.1800003052 - scale_params: 1580.34997559 - } -} -layer { - name: "fc7_mbox_loc_perm" - type: "Permute" - bottom: "fc7_mbox_loc" - top: "fc7_mbox_loc_perm" - permute_param { - order: 0 - order: 2 - order: 3 - order: 1 - } -} -layer { - name: "fc7_mbox_loc_flat" - type: "Flatten" - bottom: "fc7_mbox_loc_perm" - top: "fc7_mbox_loc_flat" - flatten_param { - axis: 1 - } -} -layer { - name: "fc7_mbox_conf" - type: "Convolution" - bottom: "fc7" - top: "fc7_mbox_conf" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 126 - pad: 1 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 23.5200004578 - scale_out: 4.11999988556 - scale_params: 975.270019531 - } -} -layer { - name: "fc7_mbox_conf_perm" - type: "Permute" - bottom: "fc7_mbox_conf" - top: "fc7_mbox_conf_perm" - permute_param { - order: 0 - order: 2 - order: 3 - order: 1 - } -} -layer { - name: "fc7_mbox_conf_flat" - type: "Flatten" - bottom: "fc7_mbox_conf_perm" - top: "fc7_mbox_conf_flat" - flatten_param { - axis: 1 - } -} -layer { - name: "fc7_mbox_priorbox" - type: "PriorBox" - bottom: "fc7" - bottom: "data" - top: "fc7_mbox_priorbox" - prior_box_param { - min_size: 60.0 - max_size: 111.0 - aspect_ratio: 2.0 - aspect_ratio: 3.0 - flip: true - clip: false - variance: 0.10000000149 - variance: 0.10000000149 - variance: 0.20000000298 - variance: 0.20000000298 - step: 16.0 - offset: 0.5 - } -} -layer { - name: "conv6_2_mbox_loc" - type: "Convolution" - bottom: "conv6_2" - top: "conv6_2_mbox_loc" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 24 - pad: 1 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 32.3899993896 - scale_out: 30.3400001526 - scale_params: 1448.85998535 - } -} -layer { - name: "conv6_2_mbox_loc_perm" - type: "Permute" - bottom: "conv6_2_mbox_loc" - top: "conv6_2_mbox_loc_perm" - permute_param { - order: 0 - order: 2 - order: 3 - order: 1 - } -} -layer { - name: "conv6_2_mbox_loc_flat" - type: "Flatten" - bottom: "conv6_2_mbox_loc_perm" - top: "conv6_2_mbox_loc_flat" - flatten_param { - axis: 1 - } -} -layer { - name: "conv6_2_mbox_conf" - type: "Convolution" - bottom: "conv6_2" - top: "conv6_2_mbox_conf" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 126 - pad: 1 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 32.3899993896 - scale_out: 4.40999984741 - scale_params: 886.849975586 - } -} -layer { - name: "conv6_2_mbox_conf_perm" - type: "Permute" - bottom: "conv6_2_mbox_conf" - top: "conv6_2_mbox_conf_perm" - permute_param { - order: 0 - order: 2 - order: 3 - order: 1 - } -} -layer { - name: "conv6_2_mbox_conf_flat" - type: "Flatten" - bottom: "conv6_2_mbox_conf_perm" - top: "conv6_2_mbox_conf_flat" - flatten_param { - axis: 1 - } -} -layer { - name: "conv6_2_mbox_priorbox" - type: "PriorBox" - bottom: "conv6_2" - bottom: "data" - top: "conv6_2_mbox_priorbox" - prior_box_param { - min_size: 111.0 - max_size: 162.0 - aspect_ratio: 2.0 - aspect_ratio: 3.0 - flip: true - clip: false - variance: 0.10000000149 - variance: 0.10000000149 - variance: 0.20000000298 - variance: 0.20000000298 - step: 32.0 - offset: 0.5 - } -} -layer { - name: "conv7_2_mbox_loc" - type: "Convolution" - bottom: "conv7_2" - top: "conv7_2_mbox_loc" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 24 - pad: 1 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 14.25 - scale_out: 26.8600006104 - scale_params: 1228.0300293 - } -} -layer { - name: "conv7_2_mbox_loc_perm" - type: "Permute" - bottom: "conv7_2_mbox_loc" - top: "conv7_2_mbox_loc_perm" - permute_param { - order: 0 - order: 2 - order: 3 - order: 1 - } -} -layer { - name: "conv7_2_mbox_loc_flat" - type: "Flatten" - bottom: "conv7_2_mbox_loc_perm" - top: "conv7_2_mbox_loc_flat" - flatten_param { - axis: 1 - } -} -layer { - name: "conv7_2_mbox_conf" - type: "Convolution" - bottom: "conv7_2" - top: "conv7_2_mbox_conf" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 126 - pad: 1 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 14.25 - scale_out: 4.65999984741 - scale_params: 896.140014648 - } -} -layer { - name: "conv7_2_mbox_conf_perm" - type: "Permute" - bottom: "conv7_2_mbox_conf" - top: "conv7_2_mbox_conf_perm" - permute_param { - order: 0 - order: 2 - order: 3 - order: 1 - } -} -layer { - name: "conv7_2_mbox_conf_flat" - type: "Flatten" - bottom: "conv7_2_mbox_conf_perm" - top: "conv7_2_mbox_conf_flat" - flatten_param { - axis: 1 - } -} -layer { - name: "conv7_2_mbox_priorbox" - type: "PriorBox" - bottom: "conv7_2" - bottom: "data" - top: "conv7_2_mbox_priorbox" - prior_box_param { - min_size: 162.0 - max_size: 213.0 - aspect_ratio: 2.0 - aspect_ratio: 3.0 - flip: true - clip: false - variance: 0.10000000149 - variance: 0.10000000149 - variance: 0.20000000298 - variance: 0.20000000298 - step: 64.0 - offset: 0.5 - } -} -layer { - name: "conv8_2_mbox_loc" - type: "Convolution" - bottom: "conv8_2" - top: "conv8_2_mbox_loc" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 16 - pad: 1 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 18.4300003052 - scale_out: 26.6599998474 - scale_params: 1359.68994141 - } -} -layer { - name: "conv8_2_mbox_loc_perm" - type: "Permute" - bottom: "conv8_2_mbox_loc" - top: "conv8_2_mbox_loc_perm" - permute_param { - order: 0 - order: 2 - order: 3 - order: 1 - } -} -layer { - name: "conv8_2_mbox_loc_flat" - type: "Flatten" - bottom: "conv8_2_mbox_loc_perm" - top: "conv8_2_mbox_loc_flat" - flatten_param { - axis: 1 - } -} -layer { - name: "conv8_2_mbox_conf" - type: "Convolution" - bottom: "conv8_2" - top: "conv8_2_mbox_conf" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 84 - pad: 1 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 18.4300003052 - scale_out: 5.67999982834 - scale_params: 1086.95996094 - } -} -layer { - name: "conv8_2_mbox_conf_perm" - type: "Permute" - bottom: "conv8_2_mbox_conf" - top: "conv8_2_mbox_conf_perm" - permute_param { - order: 0 - order: 2 - order: 3 - order: 1 - } -} -layer { - name: "conv8_2_mbox_conf_flat" - type: "Flatten" - bottom: "conv8_2_mbox_conf_perm" - top: "conv8_2_mbox_conf_flat" - flatten_param { - axis: 1 - } -} -layer { - name: "conv8_2_mbox_priorbox" - type: "PriorBox" - bottom: "conv8_2" - bottom: "data" - top: "conv8_2_mbox_priorbox" - prior_box_param { - min_size: 213.0 - max_size: 264.0 - aspect_ratio: 2.0 - flip: true - clip: false - variance: 0.10000000149 - variance: 0.10000000149 - variance: 0.20000000298 - variance: 0.20000000298 - step: 100.0 - offset: 0.5 - } -} -layer { - name: "conv9_2_mbox_loc" - type: "Convolution" - bottom: "conv9_2" - top: "conv9_2_mbox_loc" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 16 - pad: 1 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 10.6199998856 - scale_out: 35.0900001526 - scale_params: 1117.32995605 - } -} -layer { - name: "conv9_2_mbox_loc_perm" - type: "Permute" - bottom: "conv9_2_mbox_loc" - top: "conv9_2_mbox_loc_perm" - permute_param { - order: 0 - order: 2 - order: 3 - order: 1 - } -} -layer { - name: "conv9_2_mbox_loc_flat" - type: "Flatten" - bottom: "conv9_2_mbox_loc_perm" - top: "conv9_2_mbox_loc_flat" - flatten_param { - axis: 1 - } -} -layer { - name: "conv9_2_mbox_conf" - type: "Convolution" - bottom: "conv9_2" - top: "conv9_2_mbox_conf" - param { - lr_mult: 1.0 - decay_mult: 1.0 - } - param { - lr_mult: 2.0 - decay_mult: 0.0 - } - convolution_param { - num_output: 84 - pad: 1 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0.0 - } - } - quantization_param { - precision: DYNAMIC_FIXED_POINT - bw_layer_in: 8 - bw_layer_out: 8 - bw_params: 8 - scale_in: 10.6199998856 - scale_out: 5.92000007629 - scale_params: 539.520019531 - } -} -layer { - name: "conv9_2_mbox_conf_perm" - type: "Permute" - bottom: "conv9_2_mbox_conf" - top: "conv9_2_mbox_conf_perm" - permute_param { - order: 0 - order: 2 - order: 3 - order: 1 - } -} -layer { - name: "conv9_2_mbox_conf_flat" - type: "Flatten" - bottom: "conv9_2_mbox_conf_perm" - top: "conv9_2_mbox_conf_flat" - flatten_param { - axis: 1 - } -} -layer { - name: "conv9_2_mbox_priorbox" - type: "PriorBox" - bottom: "conv9_2" - bottom: "data" - top: "conv9_2_mbox_priorbox" - prior_box_param { - min_size: 264.0 - max_size: 315.0 - aspect_ratio: 2.0 - flip: true - clip: false - variance: 0.10000000149 - variance: 0.10000000149 - variance: 0.20000000298 - variance: 0.20000000298 - step: 300.0 - offset: 0.5 - } -} -layer { - name: "mbox_loc" - type: "Concat" - bottom: "conv4_3_norm_mbox_loc_flat" - bottom: "fc7_mbox_loc_flat" - bottom: "conv6_2_mbox_loc_flat" - bottom: "conv7_2_mbox_loc_flat" - bottom: "conv8_2_mbox_loc_flat" - bottom: "conv9_2_mbox_loc_flat" - top: "mbox_loc" - concat_param { - axis: 1 - } -} -layer { - name: "mbox_conf" - type: "Concat" - bottom: "conv4_3_norm_mbox_conf_flat" - bottom: "fc7_mbox_conf_flat" - bottom: "conv6_2_mbox_conf_flat" - bottom: "conv7_2_mbox_conf_flat" - bottom: "conv8_2_mbox_conf_flat" - bottom: "conv9_2_mbox_conf_flat" - top: "mbox_conf" - concat_param { - axis: 1 - } -} -layer { - name: "mbox_priorbox" - type: "Concat" - bottom: "conv4_3_norm_mbox_priorbox" - bottom: "fc7_mbox_priorbox" - bottom: "conv6_2_mbox_priorbox" - bottom: "conv7_2_mbox_priorbox" - bottom: "conv8_2_mbox_priorbox" - bottom: "conv9_2_mbox_priorbox" - top: "mbox_priorbox" - concat_param { - axis: 2 - } -} -layer { - name: "mbox_conf_reshape" - type: "Reshape" - bottom: "mbox_conf" - top: "mbox_conf_reshape" - reshape_param { - shape { - dim: 0 - dim: -1 - dim: 21 - } - } -} -layer { - name: "mbox_conf_softmax" - type: "Softmax" - bottom: "mbox_conf_reshape" - top: "mbox_conf_softmax" - softmax_param { - axis: 2 - } -} -layer { - name: "mbox_conf_flatten" - type: "Flatten" - bottom: "mbox_conf_softmax" - top: "mbox_conf_flatten" - flatten_param { - axis: 1 - } -} -layer { - name: "detection_out" - type: "DetectionOutput" - bottom: "mbox_loc" - bottom: "mbox_conf_flatten" - bottom: "mbox_priorbox" - top: "detection_out" - include { - phase: TEST - } - detection_output_param { - num_classes: 21 - share_location: true - background_label_id: 0 - nms_param { - nms_threshold: 0.449999988079 - top_k: 400 - } - code_type: CENTER_SIZE - keep_top_k: 200 - confidence_threshold: 0.00999999977648 - } -} - diff --git a/models/intel_optimized_models/mobilenet_v2/mobilenet_v2_deploy.prototxt b/models/intel_optimized_models/mobilenet_v2/mobilenet_v2_deploy.prototxt deleted file mode 100644 index 59e363477..000000000 --- a/models/intel_optimized_models/mobilenet_v2/mobilenet_v2_deploy.prototxt +++ /dev/null @@ -1,3442 +0,0 @@ -name: "MOBILENET_V2" -layer { - name: "data" - type: "Data" - top: "data" - top: "label" - include { - phase: TEST - } - transform_param { - mirror: false - crop_size: 224 - scale: 0.017 - mean_value: 103.94 - mean_value: 116.78 - mean_value: 123.68 - random_resize_param { - min_size: 256 - max_size: 256 - resize_param { - interp_mode: CUBIC - } - } - } - data_param { - source: "examples/imagenet/ilsvrc12_val_lmdb" - batch_size: 50 - backend: LMDB - } -} - -layer { - name: "conv1" - type: "Convolution" - bottom: "data" - top: "conv1" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 32 - bias_term: false - pad: 1 - kernel_size: 3 - stride: 2 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv1/bn" - type: "BatchNorm" - bottom: "conv1" - top: "conv1/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv1/scale" - type: "Scale" - bottom: "conv1/bn" - top: "conv1/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu1" - type: "ReLU" - bottom: "conv1/bn" - top: "conv1/bn" -} -layer { - name: "conv2_1/expand" - type: "Convolution" - bottom: "conv1/bn" - top: "conv2_1/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 32 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv2_1/expand/bn" - type: "BatchNorm" - bottom: "conv2_1/expand" - top: "conv2_1/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv2_1/expand/scale" - type: "Scale" - bottom: "conv2_1/expand/bn" - top: "conv2_1/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu2_1/expand" - type: "ReLU" - bottom: "conv2_1/expand/bn" - top: "conv2_1/expand/bn" -} -layer { - name: "conv2_1/dwise" - type: "Convolution" - bottom: "conv2_1/expand/bn" - top: "conv2_1/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 32 - bias_term: false - pad: 1 - kernel_size: 3 - group: 32 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv2_1/dwise/bn" - type: "BatchNorm" - bottom: "conv2_1/dwise" - top: "conv2_1/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv2_1/dwise/scale" - type: "Scale" - bottom: "conv2_1/dwise/bn" - top: "conv2_1/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu2_1/dwise" - type: "ReLU" - bottom: "conv2_1/dwise/bn" - top: "conv2_1/dwise/bn" -} -layer { - name: "conv2_1/linear" - type: "Convolution" - bottom: "conv2_1/dwise/bn" - top: "conv2_1/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 16 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv2_1/linear/bn" - type: "BatchNorm" - bottom: "conv2_1/linear" - top: "conv2_1/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv2_1/linear/scale" - type: "Scale" - bottom: "conv2_1/linear/bn" - top: "conv2_1/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "conv2_2/expand" - type: "Convolution" - bottom: "conv2_1/linear/bn" - top: "conv2_2/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 96 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv2_2/expand/bn" - type: "BatchNorm" - bottom: "conv2_2/expand" - top: "conv2_2/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv2_2/expand/scale" - type: "Scale" - bottom: "conv2_2/expand/bn" - top: "conv2_2/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu2_2/expand" - type: "ReLU" - bottom: "conv2_2/expand/bn" - top: "conv2_2/expand/bn" -} -layer { - name: "conv2_2/dwise" - type: "Convolution" - bottom: "conv2_2/expand/bn" - top: "conv2_2/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 96 - bias_term: false - pad: 1 - kernel_size: 3 - group: 96 - stride: 2 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv2_2/dwise/bn" - type: "BatchNorm" - bottom: "conv2_2/dwise" - top: "conv2_2/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv2_2/dwise/scale" - type: "Scale" - bottom: "conv2_2/dwise/bn" - top: "conv2_2/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu2_2/dwise" - type: "ReLU" - bottom: "conv2_2/dwise/bn" - top: "conv2_2/dwise/bn" -} -layer { - name: "conv2_2/linear" - type: "Convolution" - bottom: "conv2_2/dwise/bn" - top: "conv2_2/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 24 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv2_2/linear/bn" - type: "BatchNorm" - bottom: "conv2_2/linear" - top: "conv2_2/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv2_2/linear/scale" - type: "Scale" - bottom: "conv2_2/linear/bn" - top: "conv2_2/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "conv3_1/expand" - type: "Convolution" - bottom: "conv2_2/linear/bn" - top: "conv3_1/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 144 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv3_1/expand/bn" - type: "BatchNorm" - bottom: "conv3_1/expand" - top: "conv3_1/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv3_1/expand/scale" - type: "Scale" - bottom: "conv3_1/expand/bn" - top: "conv3_1/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu3_1/expand" - type: "ReLU" - bottom: "conv3_1/expand/bn" - top: "conv3_1/expand/bn" -} -layer { - name: "conv3_1/dwise" - type: "Convolution" - bottom: "conv3_1/expand/bn" - top: "conv3_1/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 144 - bias_term: false - pad: 1 - kernel_size: 3 - group: 144 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv3_1/dwise/bn" - type: "BatchNorm" - bottom: "conv3_1/dwise" - top: "conv3_1/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv3_1/dwise/scale" - type: "Scale" - bottom: "conv3_1/dwise/bn" - top: "conv3_1/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu3_1/dwise" - type: "ReLU" - bottom: "conv3_1/dwise/bn" - top: "conv3_1/dwise/bn" -} -layer { - name: "conv3_1/linear" - type: "Convolution" - bottom: "conv3_1/dwise/bn" - top: "conv3_1/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 24 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv3_1/linear/bn" - type: "BatchNorm" - bottom: "conv3_1/linear" - top: "conv3_1/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv3_1/linear/scale" - type: "Scale" - bottom: "conv3_1/linear/bn" - top: "conv3_1/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "block_3_1" - type: "Eltwise" - bottom: "conv2_2/linear/bn" - bottom: "conv3_1/linear/bn" - top: "block_3_1" -} -layer { - name: "conv3_2/expand" - type: "Convolution" - bottom: "block_3_1" - top: "conv3_2/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 144 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv3_2/expand/bn" - type: "BatchNorm" - bottom: "conv3_2/expand" - top: "conv3_2/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv3_2/expand/scale" - type: "Scale" - bottom: "conv3_2/expand/bn" - top: "conv3_2/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu3_2/expand" - type: "ReLU" - bottom: "conv3_2/expand/bn" - top: "conv3_2/expand/bn" -} -layer { - name: "conv3_2/dwise" - type: "Convolution" - bottom: "conv3_2/expand/bn" - top: "conv3_2/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 144 - bias_term: false - pad: 1 - kernel_size: 3 - group: 144 - stride: 2 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv3_2/dwise/bn" - type: "BatchNorm" - bottom: "conv3_2/dwise" - top: "conv3_2/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv3_2/dwise/scale" - type: "Scale" - bottom: "conv3_2/dwise/bn" - top: "conv3_2/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu3_2/dwise" - type: "ReLU" - bottom: "conv3_2/dwise/bn" - top: "conv3_2/dwise/bn" -} -layer { - name: "conv3_2/linear" - type: "Convolution" - bottom: "conv3_2/dwise/bn" - top: "conv3_2/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 32 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv3_2/linear/bn" - type: "BatchNorm" - bottom: "conv3_2/linear" - top: "conv3_2/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv3_2/linear/scale" - type: "Scale" - bottom: "conv3_2/linear/bn" - top: "conv3_2/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "conv4_1/expand" - type: "Convolution" - bottom: "conv3_2/linear/bn" - top: "conv4_1/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 192 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_1/expand/bn" - type: "BatchNorm" - bottom: "conv4_1/expand" - top: "conv4_1/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_1/expand/scale" - type: "Scale" - bottom: "conv4_1/expand/bn" - top: "conv4_1/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu4_1/expand" - type: "ReLU" - bottom: "conv4_1/expand/bn" - top: "conv4_1/expand/bn" -} -layer { - name: "conv4_1/dwise" - type: "Convolution" - bottom: "conv4_1/expand/bn" - top: "conv4_1/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 192 - bias_term: false - pad: 1 - kernel_size: 3 - group: 192 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_1/dwise/bn" - type: "BatchNorm" - bottom: "conv4_1/dwise" - top: "conv4_1/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_1/dwise/scale" - type: "Scale" - bottom: "conv4_1/dwise/bn" - top: "conv4_1/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu4_1/dwise" - type: "ReLU" - bottom: "conv4_1/dwise/bn" - top: "conv4_1/dwise/bn" -} -layer { - name: "conv4_1/linear" - type: "Convolution" - bottom: "conv4_1/dwise/bn" - top: "conv4_1/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 32 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_1/linear/bn" - type: "BatchNorm" - bottom: "conv4_1/linear" - top: "conv4_1/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_1/linear/scale" - type: "Scale" - bottom: "conv4_1/linear/bn" - top: "conv4_1/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "block_4_1" - type: "Eltwise" - bottom: "conv3_2/linear/bn" - bottom: "conv4_1/linear/bn" - top: "block_4_1" -} -layer { - name: "conv4_2/expand" - type: "Convolution" - bottom: "block_4_1" - top: "conv4_2/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 192 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_2/expand/bn" - type: "BatchNorm" - bottom: "conv4_2/expand" - top: "conv4_2/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_2/expand/scale" - type: "Scale" - bottom: "conv4_2/expand/bn" - top: "conv4_2/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu4_2/expand" - type: "ReLU" - bottom: "conv4_2/expand/bn" - top: "conv4_2/expand/bn" -} -layer { - name: "conv4_2/dwise" - type: "Convolution" - bottom: "conv4_2/expand/bn" - top: "conv4_2/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 192 - bias_term: false - pad: 1 - kernel_size: 3 - group: 192 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_2/dwise/bn" - type: "BatchNorm" - bottom: "conv4_2/dwise" - top: "conv4_2/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_2/dwise/scale" - type: "Scale" - bottom: "conv4_2/dwise/bn" - top: "conv4_2/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu4_2/dwise" - type: "ReLU" - bottom: "conv4_2/dwise/bn" - top: "conv4_2/dwise/bn" -} -layer { - name: "conv4_2/linear" - type: "Convolution" - bottom: "conv4_2/dwise/bn" - top: "conv4_2/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 32 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_2/linear/bn" - type: "BatchNorm" - bottom: "conv4_2/linear" - top: "conv4_2/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_2/linear/scale" - type: "Scale" - bottom: "conv4_2/linear/bn" - top: "conv4_2/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "block_4_2" - type: "Eltwise" - bottom: "block_4_1" - bottom: "conv4_2/linear/bn" - top: "block_4_2" -} -layer { - name: "conv4_3/expand" - type: "Convolution" - bottom: "block_4_2" - top: "conv4_3/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 192 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_3/expand/bn" - type: "BatchNorm" - bottom: "conv4_3/expand" - top: "conv4_3/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_3/expand/scale" - type: "Scale" - bottom: "conv4_3/expand/bn" - top: "conv4_3/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu4_3/expand" - type: "ReLU" - bottom: "conv4_3/expand/bn" - top: "conv4_3/expand/bn" -} -layer { - name: "conv4_3/dwise" - type: "Convolution" - bottom: "conv4_3/expand/bn" - top: "conv4_3/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 192 - bias_term: false - pad: 1 - kernel_size: 3 - group: 192 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_3/dwise/bn" - type: "BatchNorm" - bottom: "conv4_3/dwise" - top: "conv4_3/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_3/dwise/scale" - type: "Scale" - bottom: "conv4_3/dwise/bn" - top: "conv4_3/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu4_3/dwise" - type: "ReLU" - bottom: "conv4_3/dwise/bn" - top: "conv4_3/dwise/bn" -} -layer { - name: "conv4_3/linear" - type: "Convolution" - bottom: "conv4_3/dwise/bn" - top: "conv4_3/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 64 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_3/linear/bn" - type: "BatchNorm" - bottom: "conv4_3/linear" - top: "conv4_3/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_3/linear/scale" - type: "Scale" - bottom: "conv4_3/linear/bn" - top: "conv4_3/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "conv4_4/expand" - type: "Convolution" - bottom: "conv4_3/linear/bn" - top: "conv4_4/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 384 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_4/expand/bn" - type: "BatchNorm" - bottom: "conv4_4/expand" - top: "conv4_4/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_4/expand/scale" - type: "Scale" - bottom: "conv4_4/expand/bn" - top: "conv4_4/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu4_4/expand" - type: "ReLU" - bottom: "conv4_4/expand/bn" - top: "conv4_4/expand/bn" -} -layer { - name: "conv4_4/dwise" - type: "Convolution" - bottom: "conv4_4/expand/bn" - top: "conv4_4/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 384 - bias_term: false - pad: 1 - kernel_size: 3 - group: 384 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_4/dwise/bn" - type: "BatchNorm" - bottom: "conv4_4/dwise" - top: "conv4_4/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_4/dwise/scale" - type: "Scale" - bottom: "conv4_4/dwise/bn" - top: "conv4_4/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu4_4/dwise" - type: "ReLU" - bottom: "conv4_4/dwise/bn" - top: "conv4_4/dwise/bn" -} -layer { - name: "conv4_4/linear" - type: "Convolution" - bottom: "conv4_4/dwise/bn" - top: "conv4_4/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 64 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_4/linear/bn" - type: "BatchNorm" - bottom: "conv4_4/linear" - top: "conv4_4/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_4/linear/scale" - type: "Scale" - bottom: "conv4_4/linear/bn" - top: "conv4_4/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "block_4_4" - type: "Eltwise" - bottom: "conv4_3/linear/bn" - bottom: "conv4_4/linear/bn" - top: "block_4_4" -} -layer { - name: "conv4_5/expand" - type: "Convolution" - bottom: "block_4_4" - top: "conv4_5/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 384 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_5/expand/bn" - type: "BatchNorm" - bottom: "conv4_5/expand" - top: "conv4_5/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_5/expand/scale" - type: "Scale" - bottom: "conv4_5/expand/bn" - top: "conv4_5/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu4_5/expand" - type: "ReLU" - bottom: "conv4_5/expand/bn" - top: "conv4_5/expand/bn" -} -layer { - name: "conv4_5/dwise" - type: "Convolution" - bottom: "conv4_5/expand/bn" - top: "conv4_5/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 384 - bias_term: false - pad: 1 - kernel_size: 3 - group: 384 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_5/dwise/bn" - type: "BatchNorm" - bottom: "conv4_5/dwise" - top: "conv4_5/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_5/dwise/scale" - type: "Scale" - bottom: "conv4_5/dwise/bn" - top: "conv4_5/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu4_5/dwise" - type: "ReLU" - bottom: "conv4_5/dwise/bn" - top: "conv4_5/dwise/bn" -} -layer { - name: "conv4_5/linear" - type: "Convolution" - bottom: "conv4_5/dwise/bn" - top: "conv4_5/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 64 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_5/linear/bn" - type: "BatchNorm" - bottom: "conv4_5/linear" - top: "conv4_5/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_5/linear/scale" - type: "Scale" - bottom: "conv4_5/linear/bn" - top: "conv4_5/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "block_4_5" - type: "Eltwise" - bottom: "block_4_4" - bottom: "conv4_5/linear/bn" - top: "block_4_5" -} -layer { - name: "conv4_6/expand" - type: "Convolution" - bottom: "block_4_5" - top: "conv4_6/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 384 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_6/expand/bn" - type: "BatchNorm" - bottom: "conv4_6/expand" - top: "conv4_6/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_6/expand/scale" - type: "Scale" - bottom: "conv4_6/expand/bn" - top: "conv4_6/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu4_6/expand" - type: "ReLU" - bottom: "conv4_6/expand/bn" - top: "conv4_6/expand/bn" -} -layer { - name: "conv4_6/dwise" - type: "Convolution" - bottom: "conv4_6/expand/bn" - top: "conv4_6/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 384 - bias_term: false - pad: 1 - kernel_size: 3 - group: 384 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_6/dwise/bn" - type: "BatchNorm" - bottom: "conv4_6/dwise" - top: "conv4_6/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_6/dwise/scale" - type: "Scale" - bottom: "conv4_6/dwise/bn" - top: "conv4_6/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu4_6/dwise" - type: "ReLU" - bottom: "conv4_6/dwise/bn" - top: "conv4_6/dwise/bn" -} -layer { - name: "conv4_6/linear" - type: "Convolution" - bottom: "conv4_6/dwise/bn" - top: "conv4_6/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 64 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_6/linear/bn" - type: "BatchNorm" - bottom: "conv4_6/linear" - top: "conv4_6/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_6/linear/scale" - type: "Scale" - bottom: "conv4_6/linear/bn" - top: "conv4_6/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "block_4_6" - type: "Eltwise" - bottom: "block_4_5" - bottom: "conv4_6/linear/bn" - top: "block_4_6" -} -layer { - name: "conv4_7/expand" - type: "Convolution" - bottom: "block_4_6" - top: "conv4_7/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 384 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_7/expand/bn" - type: "BatchNorm" - bottom: "conv4_7/expand" - top: "conv4_7/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_7/expand/scale" - type: "Scale" - bottom: "conv4_7/expand/bn" - top: "conv4_7/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu4_7/expand" - type: "ReLU" - bottom: "conv4_7/expand/bn" - top: "conv4_7/expand/bn" -} -layer { - name: "conv4_7/dwise" - type: "Convolution" - bottom: "conv4_7/expand/bn" - top: "conv4_7/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 384 - bias_term: false - pad: 1 - kernel_size: 3 - group: 384 - stride: 2 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_7/dwise/bn" - type: "BatchNorm" - bottom: "conv4_7/dwise" - top: "conv4_7/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_7/dwise/scale" - type: "Scale" - bottom: "conv4_7/dwise/bn" - top: "conv4_7/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu4_7/dwise" - type: "ReLU" - bottom: "conv4_7/dwise/bn" - top: "conv4_7/dwise/bn" -} -layer { - name: "conv4_7/linear" - type: "Convolution" - bottom: "conv4_7/dwise/bn" - top: "conv4_7/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 96 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv4_7/linear/bn" - type: "BatchNorm" - bottom: "conv4_7/linear" - top: "conv4_7/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv4_7/linear/scale" - type: "Scale" - bottom: "conv4_7/linear/bn" - top: "conv4_7/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "conv5_1/expand" - type: "Convolution" - bottom: "conv4_7/linear/bn" - top: "conv5_1/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 576 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv5_1/expand/bn" - type: "BatchNorm" - bottom: "conv5_1/expand" - top: "conv5_1/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv5_1/expand/scale" - type: "Scale" - bottom: "conv5_1/expand/bn" - top: "conv5_1/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu5_1/expand" - type: "ReLU" - bottom: "conv5_1/expand/bn" - top: "conv5_1/expand/bn" -} -layer { - name: "conv5_1/dwise" - type: "Convolution" - bottom: "conv5_1/expand/bn" - top: "conv5_1/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 576 - bias_term: false - pad: 1 - kernel_size: 3 - group: 576 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv5_1/dwise/bn" - type: "BatchNorm" - bottom: "conv5_1/dwise" - top: "conv5_1/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv5_1/dwise/scale" - type: "Scale" - bottom: "conv5_1/dwise/bn" - top: "conv5_1/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu5_1/dwise" - type: "ReLU" - bottom: "conv5_1/dwise/bn" - top: "conv5_1/dwise/bn" -} -layer { - name: "conv5_1/linear" - type: "Convolution" - bottom: "conv5_1/dwise/bn" - top: "conv5_1/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 96 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv5_1/linear/bn" - type: "BatchNorm" - bottom: "conv5_1/linear" - top: "conv5_1/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv5_1/linear/scale" - type: "Scale" - bottom: "conv5_1/linear/bn" - top: "conv5_1/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "block_5_1" - type: "Eltwise" - bottom: "conv4_7/linear/bn" - bottom: "conv5_1/linear/bn" - top: "block_5_1" -} -layer { - name: "conv5_2/expand" - type: "Convolution" - bottom: "block_5_1" - top: "conv5_2/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 576 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv5_2/expand/bn" - type: "BatchNorm" - bottom: "conv5_2/expand" - top: "conv5_2/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv5_2/expand/scale" - type: "Scale" - bottom: "conv5_2/expand/bn" - top: "conv5_2/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu5_2/expand" - type: "ReLU" - bottom: "conv5_2/expand/bn" - top: "conv5_2/expand/bn" -} -layer { - name: "conv5_2/dwise" - type: "Convolution" - bottom: "conv5_2/expand/bn" - top: "conv5_2/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 576 - bias_term: false - pad: 1 - kernel_size: 3 - group: 576 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv5_2/dwise/bn" - type: "BatchNorm" - bottom: "conv5_2/dwise" - top: "conv5_2/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv5_2/dwise/scale" - type: "Scale" - bottom: "conv5_2/dwise/bn" - top: "conv5_2/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu5_2/dwise" - type: "ReLU" - bottom: "conv5_2/dwise/bn" - top: "conv5_2/dwise/bn" -} -layer { - name: "conv5_2/linear" - type: "Convolution" - bottom: "conv5_2/dwise/bn" - top: "conv5_2/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 96 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv5_2/linear/bn" - type: "BatchNorm" - bottom: "conv5_2/linear" - top: "conv5_2/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv5_2/linear/scale" - type: "Scale" - bottom: "conv5_2/linear/bn" - top: "conv5_2/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "block_5_2" - type: "Eltwise" - bottom: "block_5_1" - bottom: "conv5_2/linear/bn" - top: "block_5_2" -} -layer { - name: "conv5_3/expand" - type: "Convolution" - bottom: "block_5_2" - top: "conv5_3/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 576 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv5_3/expand/bn" - type: "BatchNorm" - bottom: "conv5_3/expand" - top: "conv5_3/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv5_3/expand/scale" - type: "Scale" - bottom: "conv5_3/expand/bn" - top: "conv5_3/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu5_3/expand" - type: "ReLU" - bottom: "conv5_3/expand/bn" - top: "conv5_3/expand/bn" -} -layer { - name: "conv5_3/dwise" - type: "Convolution" - bottom: "conv5_3/expand/bn" - top: "conv5_3/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 576 - bias_term: false - pad: 1 - kernel_size: 3 - group: 576 - stride: 2 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv5_3/dwise/bn" - type: "BatchNorm" - bottom: "conv5_3/dwise" - top: "conv5_3/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv5_3/dwise/scale" - type: "Scale" - bottom: "conv5_3/dwise/bn" - top: "conv5_3/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu5_3/dwise" - type: "ReLU" - bottom: "conv5_3/dwise/bn" - top: "conv5_3/dwise/bn" -} -layer { - name: "conv5_3/linear" - type: "Convolution" - bottom: "conv5_3/dwise/bn" - top: "conv5_3/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 160 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv5_3/linear/bn" - type: "BatchNorm" - bottom: "conv5_3/linear" - top: "conv5_3/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv5_3/linear/scale" - type: "Scale" - bottom: "conv5_3/linear/bn" - top: "conv5_3/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "conv6_1/expand" - type: "Convolution" - bottom: "conv5_3/linear/bn" - top: "conv6_1/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 960 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv6_1/expand/bn" - type: "BatchNorm" - bottom: "conv6_1/expand" - top: "conv6_1/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv6_1/expand/scale" - type: "Scale" - bottom: "conv6_1/expand/bn" - top: "conv6_1/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu6_1/expand" - type: "ReLU" - bottom: "conv6_1/expand/bn" - top: "conv6_1/expand/bn" -} -layer { - name: "conv6_1/dwise" - type: "Convolution" - bottom: "conv6_1/expand/bn" - top: "conv6_1/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 960 - bias_term: false - pad: 1 - kernel_size: 3 - group: 960 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv6_1/dwise/bn" - type: "BatchNorm" - bottom: "conv6_1/dwise" - top: "conv6_1/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv6_1/dwise/scale" - type: "Scale" - bottom: "conv6_1/dwise/bn" - top: "conv6_1/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu6_1/dwise" - type: "ReLU" - bottom: "conv6_1/dwise/bn" - top: "conv6_1/dwise/bn" -} -layer { - name: "conv6_1/linear" - type: "Convolution" - bottom: "conv6_1/dwise/bn" - top: "conv6_1/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 160 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv6_1/linear/bn" - type: "BatchNorm" - bottom: "conv6_1/linear" - top: "conv6_1/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv6_1/linear/scale" - type: "Scale" - bottom: "conv6_1/linear/bn" - top: "conv6_1/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "block_6_1" - type: "Eltwise" - bottom: "conv5_3/linear/bn" - bottom: "conv6_1/linear/bn" - top: "block_6_1" -} -layer { - name: "conv6_2/expand" - type: "Convolution" - bottom: "block_6_1" - top: "conv6_2/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 960 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv6_2/expand/bn" - type: "BatchNorm" - bottom: "conv6_2/expand" - top: "conv6_2/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv6_2/expand/scale" - type: "Scale" - bottom: "conv6_2/expand/bn" - top: "conv6_2/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu6_2/expand" - type: "ReLU" - bottom: "conv6_2/expand/bn" - top: "conv6_2/expand/bn" -} -layer { - name: "conv6_2/dwise" - type: "Convolution" - bottom: "conv6_2/expand/bn" - top: "conv6_2/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 960 - bias_term: false - pad: 1 - kernel_size: 3 - group: 960 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv6_2/dwise/bn" - type: "BatchNorm" - bottom: "conv6_2/dwise" - top: "conv6_2/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv6_2/dwise/scale" - type: "Scale" - bottom: "conv6_2/dwise/bn" - top: "conv6_2/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu6_2/dwise" - type: "ReLU" - bottom: "conv6_2/dwise/bn" - top: "conv6_2/dwise/bn" -} -layer { - name: "conv6_2/linear" - type: "Convolution" - bottom: "conv6_2/dwise/bn" - top: "conv6_2/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 160 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv6_2/linear/bn" - type: "BatchNorm" - bottom: "conv6_2/linear" - top: "conv6_2/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv6_2/linear/scale" - type: "Scale" - bottom: "conv6_2/linear/bn" - top: "conv6_2/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "block_6_2" - type: "Eltwise" - bottom: "block_6_1" - bottom: "conv6_2/linear/bn" - top: "block_6_2" -} -layer { - name: "conv6_3/expand" - type: "Convolution" - bottom: "block_6_2" - top: "conv6_3/expand" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 960 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv6_3/expand/bn" - type: "BatchNorm" - bottom: "conv6_3/expand" - top: "conv6_3/expand/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv6_3/expand/scale" - type: "Scale" - bottom: "conv6_3/expand/bn" - top: "conv6_3/expand/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu6_3/expand" - type: "ReLU" - bottom: "conv6_3/expand/bn" - top: "conv6_3/expand/bn" -} -layer { - name: "conv6_3/dwise" - type: "Convolution" - bottom: "conv6_3/expand/bn" - top: "conv6_3/dwise" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 960 - bias_term: false - pad: 1 - kernel_size: 3 - group: 960 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv6_3/dwise/bn" - type: "BatchNorm" - bottom: "conv6_3/dwise" - top: "conv6_3/dwise/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv6_3/dwise/scale" - type: "Scale" - bottom: "conv6_3/dwise/bn" - top: "conv6_3/dwise/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu6_3/dwise" - type: "ReLU" - bottom: "conv6_3/dwise/bn" - top: "conv6_3/dwise/bn" -} -layer { - name: "conv6_3/linear" - type: "Convolution" - bottom: "conv6_3/dwise/bn" - top: "conv6_3/linear" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 320 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv6_3/linear/bn" - type: "BatchNorm" - bottom: "conv6_3/linear" - top: "conv6_3/linear/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv6_3/linear/scale" - type: "Scale" - bottom: "conv6_3/linear/bn" - top: "conv6_3/linear/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "conv6_4" - type: "Convolution" - bottom: "conv6_3/linear/bn" - top: "conv6_4" - param { - lr_mult: 1 - decay_mult: 1 - } - convolution_param { - num_output: 1280 - bias_term: false - kernel_size: 1 - weight_filler { - type: "msra" - } - } -} -layer { - name: "conv6_4/bn" - type: "BatchNorm" - bottom: "conv6_4" - top: "conv6_4/bn" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - batch_norm_param { - use_global_stats: true - eps: 1e-5 - } -} -layer { - name: "conv6_4/scale" - type: "Scale" - bottom: "conv6_4/bn" - top: "conv6_4/bn" - param { - lr_mult: 1 - decay_mult: 0 - } - param { - lr_mult: 1 - decay_mult: 0 - } - scale_param { - bias_term: true - } -} -layer { - name: "relu6_4" - type: "ReLU" - bottom: "conv6_4/bn" - top: "conv6_4/bn" -} -layer { - name: "pool6" - type: "Pooling" - bottom: "conv6_4/bn" - top: "pool6" - pooling_param { - pool: AVE - global_pooling: true - } -} -layer { - name: "fc7" - type: "Convolution" - bottom: "pool6" - top: "fc7" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 0 - } - convolution_param { - num_output: 1000 - kernel_size: 1 - weight_filler { - type: "msra" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "accuracy/top-1" - type: "Accuracy" - bottom: "fc7" - bottom: "label" - top: "accuracy/top-1" - accuracy_param - { - top_k: 1 - } - include { - phase: TEST - } -} -layer { - name: "accuracy/top-5" - type: "Accuracy" - bottom: "fc7" - bottom: "label" - top: "accuracy/top-5" - accuracy_param - { - top_k: 5 - } - include { - phase: TEST - } -} - diff --git a/models/intel_optimized_models/multinode/default_resnet50_16nodes/solver.prototxt b/models/intel_optimized_models/multinode/default_resnet50_16nodes/solver.prototxt index b5f73dee9..27054d7d2 100644 --- a/models/intel_optimized_models/multinode/default_resnet50_16nodes/solver.prototxt +++ b/models/intel_optimized_models/multinode/default_resnet50_16nodes/solver.prototxt @@ -1,6 +1,6 @@ net: "models/intel_optimized_models/multinode/default_resnet50_16nodes/train_val.prototxt" test_iter: 1000 -test_interval: 563 +test_interval: 625 test_initialization: false display: 40 base_lr: 0.8 @@ -9,11 +9,11 @@ stepvalue:18750 stepvalue:37500 stepvalue:50000 gamma: 0.1 -max_iter: 56300 +max_iter: 62556 # 56300 warmup_iter: 3125 # 1281167 / 2048 * 5 epochs warmup_start_lr: 0.1 momentum: 0.9 weight_decay: 0.0001 -snapshot: 5630 +snapshot: 6250 snapshot_prefix: "default_resnet_50_16_nodes" solver_mode: CPU diff --git a/models/intel_optimized_models/multinode/default_resnet50_64nodes/solver.prototxt b/models/intel_optimized_models/multinode/default_resnet50_64nodes/solver.prototxt index 947e2bacc..0854902f8 100644 --- a/models/intel_optimized_models/multinode/default_resnet50_64nodes/solver.prototxt +++ b/models/intel_optimized_models/multinode/default_resnet50_64nodes/solver.prototxt @@ -1,6 +1,6 @@ net: "models/intel_optimized_models/multinode/default_resnet50_64nodes/train_val.prototxt" test_iter: 1000 -test_interval: 140 +test_interval: 156 test_initialization: false display: 40 base_lr: 3.2 diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index c53299d26..bc7c2c38d 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -5,9 +5,15 @@ endif() file(GLOB_RECURSE python_srcs ${PROJECT_SOURCE_DIR}/python/*.cpp) -add_library(pycaffe SHARED ${python_srcs}) +add_library(pycaffe MODULE ${python_srcs}) caffe_default_properties(pycaffe) set_target_properties(pycaffe PROPERTIES PREFIX "" OUTPUT_NAME "_caffe") + +if(MSVC) + set_target_properties(pycaffe PROPERTIES SUFFIX ".pyd") + set_target_properties(pycaffe PROPERTIES LINK_FLAGS "/WHOLEARCHIVE:${Caffe_LINK}") +endif() + target_include_directories(pycaffe PUBLIC ${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIR}) target_link_libraries(pycaffe PUBLIC ${Caffe_LINK} ${PYTHON_LIBRARIES}) @@ -19,6 +25,13 @@ if(UNIX OR APPLE) COMMAND touch ${PROJECT_SOURCE_DIR}/python/caffe/proto/__init__.py COMMAND cp ${proto_gen_folder}/*.py ${PROJECT_SOURCE_DIR}/python/caffe/proto/ COMMENT "Creating symlink ${__linkname} -> ${PROJECT_BINARY_DIR}/lib/_caffe${Caffe_POSTFIX}.so") +elseif(WIN32) + add_custom_command(TARGET pycaffe POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${PROJECT_SOURCE_DIR}/python/caffe + COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/python/caffe/proto + COMMAND ${CMAKE_COMMAND} -E touch ${PROJECT_SOURCE_DIR}/python/caffe/proto/__init__.py + COMMAND (robocopy "\"${proto_gen_folder}\" \"${PROJECT_SOURCE_DIR}/python/caffe/proto\" *.py") ^& IF %ERRORLEVEL% LEQ 4 set ERRORLEVEL=0 + COMMENT "Creating symlink ${__linkname} -> ${PROJECT_BINARY_DIR}/lib/_caffe.pyd") endif() # ---[ Install diff --git a/python/caffe/_caffe.cpp b/python/caffe/_caffe.cpp index fb9209bd5..01f21bdb0 100644 --- a/python/caffe/_caffe.cpp +++ b/python/caffe/_caffe.cpp @@ -133,9 +133,9 @@ void InitLogLevel(int level) { FLAGS_minloglevel = level; InitLog(); } -void InitLogLevelPipe(int level, bool stderr) { +void InitLogLevelPipe(int level, bool std_err) { FLAGS_minloglevel = level; - FLAGS_logtostderr = stderr; + FLAGS_logtostderr = std_err; InitLog(); } void Log(const string& s) { diff --git a/python/caffe/test/test_net_spec.py b/python/caffe/test/test_net_spec.py index 36520c2a5..3ff08b9ec 100755 --- a/python/caffe/test/test_net_spec.py +++ b/python/caffe/test/test_net_spec.py @@ -100,14 +100,14 @@ def test_lenet(self): net_proto.layer[6].top) net = self.load_net(net_proto) # check that all layers are present - self.assertEqual(len(net.layers), 9) + self.assertEqual(len(net.layers), 8) # now the check the version with automatically-generated layer names net_proto = anon_lenet(50) self.assertEqual(net_proto.layer[6].bottom, net_proto.layer[6].top) net = self.load_net(net_proto) - self.assertEqual(len(net.layers), 9) + self.assertEqual(len(net.layers), 8) def test_zero_tops(self): """Test net construction for top-less layers.""" diff --git a/run.sh b/run.sh index d59d864b3..b64363854 100755 --- a/run.sh +++ b/run.sh @@ -1,12 +1,12 @@ #!/bin/bash -prototxt="models/intel_optimized_models/resnet50_v1/resnet50_int8_perf.prototxt" +prototxt="models/intel_optimized_models/int8/resnet50_int8_perf_clx_winograd.prototxt" iterations=1200 skip=200 NUM_CORE=56 -s_BS=10 -e_BS=10 -INSTANCE=2 +s_BS=11 +e_BS=11 +INSTANCE=14 rm -rf logs mkdir logs @@ -34,7 +34,7 @@ do export KMP_AFFINITY=granularity=fine,compact,1,0 export OMP_NUM_THREADS=$INTERVAL - sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches' + #sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches' for ((i = 0; i < $NUM_CORE; i += $INTERVAL)) do diff --git a/run_accuracy.sh b/run_accuracy.sh index ec6375bae..80cd1b919 100755 --- a/run_accuracy.sh +++ b/run_accuracy.sh @@ -6,7 +6,6 @@ # loss3/top-1 = 0.75522 # loss3/top-5 = 0.926621 -bs=50 prototxt="./models/intel_optimized_models/resnet50_v1/resnet50_int8_acc.prototxt" sed -i "1,/dim/s/dim.*/dim:$bs/" $prototxt diff --git a/scripts/calibrator.py b/scripts/calibrator.py index 1c3b4068c..57c89a627 100644 --- a/scripts/calibrator.py +++ b/scripts/calibrator.py @@ -46,9 +46,11 @@ import google.protobuf.text_format as txtf import sampling import numpy as np +import first_conv_force_u8 as fu -int8_layers = ["Convolution", "ReLU", "Split", "Concat", "Pooling", "Eltwise", "InnerProduct"] -quantize_layers = ["Convolution", "InnerProduct"] +quantize_layers = ["Convolution"] +memory_layers = ["ReLU", "Split", "Concat", "Pooling", "Eltwise"] +int8_layers = quantize_layers + memory_layers def isclose(a, b, rel_tol=1e-09, abs_tol=0.0): return abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol) @@ -181,17 +183,6 @@ def analyze_conv_output_with_relu_from_net(convs_output_with_relu, compiled_net, return new_convs_output_with_relu -def find_last_conv_layers(top_blobs_map, bottom_blobs_map, convolution_layers, non_int8_layers): - last_conv_indexes = [] - for (l, index) in convolution_layers: - top_blob = top_blobs_map[l.name][0] - for k, v in bottom_blobs_map.iteritems(): - if len(v) == 1 and v[0] == top_blob: - output_index = find_index_by_name(k, non_int8_layers) - if output_index != -1: - last_conv_indexes.append(index) - - return last_conv_indexes def transform_convolutions(model_path, compiled_model_path, top_blobs_map, bottom_blobs_map, use_unsigned_range, concat_use_fp32, unify_concat_scales, conv_algo, enable_1st_conv = False): net = caffe_pb2.NetParameter() @@ -291,14 +282,6 @@ def transform_convolutions(model_path, compiled_model_path, top_blobs_map, botto new_net.layer[index_in_net].quantization_param.bw_layer_out = 32 new_net.layer[index_in_net].quantization_param.scale_out[:] = [1.0] - non_int8_layers = [(value, index) for index, value in enumerate(net.layer) if value.type not in int8_layers] - last_conv_indexes = find_last_conv_layers(top_blobs_map, bottom_blobs_map, convolution_layers, non_int8_layers) - - # TODO: support last convolution without consumer - for index in last_conv_indexes: - new_net.layer[index].quantization_param.bw_layer_out = 32 - new_net.layer[index].quantization_param.scale_out[:] = [1.0] - with open(model_path, 'w') as f: f.write(str(new_net)) @@ -314,8 +297,8 @@ def generate_sample_bak(sample_path, input_model, weights, os.system(cmd) -def generate_sample(input_model, weights, quantized_model, scaling_mode, calibration_algo, conv_algo, iterations=10, enable_1st_conv=False): - (blobs, params, top_blobs_map, bottom_blobs_map, conv_top_blob_layer_map, conv_bottom_blob_layer_map, winograd_bottoms, winograd_convolutions) = sampling.sample(input_model, weights, conv_algo, iterations, enable_1st_conv) +def generate_sample(input_model, weights, quantized_model, scaling_mode, calibration_algo, conv_algo, iterations=10, enable_1st_conv=False, sampling_single=False): + (blobs, params, top_blobs_map, bottom_blobs_map, conv_top_blob_layer_map, conv_bottom_blob_layer_map, winograd_bottoms, winograd_convolutions) = sampling.sample(input_model, weights, conv_algo, iterations, enable_1st_conv, sampling_single) (inputs_max, outputs_max, inputs_min) = sampling.calibrate_activations(blobs, conv_top_blob_layer_map, conv_bottom_blob_layer_map, winograd_bottoms, calibration_algo, "SINGLE", conv_algo) params_max = sampling.calibrate_parameters(params, winograd_convolutions, "DIRECT", scaling_mode.upper(), conv_algo) @@ -464,6 +447,125 @@ def generate_dummy_model(model_path, dummy): with open(dummy, 'w') as f: f.write(str(net)) +def force_fp32_opt(quantized_prototxt): + net = caffe_pb2.NetParameter() + with open(quantized_prototxt) as f: + s = f.read() + txtf.Merge(s, net) + base_net = caffe_pb2.NetParameter() + compiled_net_str = caffe.compile_net(quantized_prototxt, caffe.TEST, "MKLDNN") + txtf.Merge(compiled_net_str, base_net) + new_net = copy.deepcopy(net) + quantize_layers_indexes = [index for index, value in enumerate(base_net.layer) if value.type in quantize_layers] + layer_infos = [(value, index) for index, value in enumerate(new_net.layer)] + layer_bottom_name_map={} + for index,layer in enumerate(base_net.layer): + for bottom in layer.bottom: + if bottom not in layer_bottom_name_map.keys(): + layer_bottom_name_map[bottom]=[index] + else: + layer_bottom_name_map[bottom].append(index) + for index in quantize_layers_indexes: + if int(base_net.layer[index].quantization_param.bw_layer_out) != 32: + force_fp32 = True + if base_net.layer[index].top[0] in layer_bottom_name_map.keys(): + bottom_layer_indexes=layer_bottom_name_map[base_net.layer[index].top[0]] + for bottom_layer_index in bottom_layer_indexes: + if base_net.layer[bottom_layer_index].type in int8_layers: + force_fp32 = False + if force_fp32 or index == np.max(quantize_layers_indexes): + new_net_index=find_index_by_name(base_net.layer[index].name, layer_infos) + new_net.layer[new_net_index].quantization_param.scale_out[:]=[1.0] + new_net.layer[new_net_index].quantization_param.bw_layer_out=32 + print(new_net.layer[new_net_index].name) + with open(quantized_prototxt, 'w') as f: + f.write(str(new_net)) + print('force_fp32 done') + +def find_next_layers(net, index): + layer = net.layer[index] + next_layers = [] + for i in range(index + 1, len(net.layer)): + for top in layer.top: + if top in net.layer[i].bottom: + next_layers.append(i) + return next_layers + +def find_previous_layers(net, index): + layer = net.layer[index] + previous_layers = [] + for i in range(index): + for bottom in layer.bottom: + if bottom in net.layer[i].top: + previous_layers.append(i) + return previous_layers + +def find_down_quantize(net, index): + next_layers = find_next_layers(net, index) + if len(next_layers) == 0: + return None + elif len(next_layers) == 1: + next_layer = net.layer[next_layers[0]] + if next_layer.type in quantize_layers and int(next_layer.quantization_param.bw_layer_in) == 8: + return next_layers[0] + elif next_layer.type in memory_layers: + return find_down_quantize(net, next_layers[0]) + else: + return None + else: # just consider one branch + return None + +def find_up_quantize(net, index): + previous_layers = find_previous_layers(net, index) + has_concat = False + if len(previous_layers) == 0: + return None, has_concat + elif len(previous_layers) == 1: + previous_layer = net.layer[previous_layers[0]] + if previous_layer.type in quantize_layers and int(previous_layer.quantization_param.bw_layer_out) == 8: + return previous_layers[0], has_concat + elif previous_layer.type in memory_layers: + return find_up_quantize(net, previous_layers[0]) + else: + return None, has_concat + else: + if net.layer[index].type == 'Concat': + has_concat = True + concat_output_layers = find_next_layers(net, index) + for concat_output in concat_output_layers: + if net.layer[concat_output].type in quantize_layers and int(net.layer[concat_output].quantization_param.bw_layer_in) == 8: + return concat_output, has_concat + return None, has_concat + else: + return None, has_concat + +def cac_opt(quantized_prototxt): + net = caffe_pb2.NetParameter() + with open(quantized_prototxt) as f: + s = f.read() + txtf.Merge(s,net) + base_net = caffe_pb2.NetParameter() + compiled_net_str = caffe.compile_net(quantized_prototxt, caffe.TEST, "MKLDNN") + txtf.Merge(compiled_net_str, base_net) + new_net = copy.deepcopy(net) + avg_pool_layers = [index for index, value in enumerate(base_net.layer) if value.type == 'Pooling' and value.pooling_param.pool == 1] #max=0 ave=1 + layer_infos = [(value, index) for index, value in enumerate(new_net.layer)] + for index in avg_pool_layers: + up_quantize, has_concat = find_up_quantize(base_net, index) + down_quantize = find_down_quantize(base_net, index) + if up_quantize and down_quantize: + new_net_up_index = find_index_by_name(base_net.layer[up_quantize].name, layer_infos) + new_net_down_index = find_index_by_name(base_net.layer[down_quantize].name, layer_infos) + if not has_concat: + new_net.layer[new_net_down_index].quantization_param.scale_in[:]=new_net.layer[new_net_up_index].quantization_param.scale_out[:] + else: + new_net.layer[new_net_down_index].quantization_param.scale_in[:]=new_net.layer[new_net_up_index].quantization_param.scale_in[:] + print([new_net.layer[new_net_up_index].name,new_net.layer[new_net_down_index].name]) + with open(quantized_prototxt, 'w') as f: + f.write(str(new_net)) + print('cac opt done') + + if __name__ == '__main__': usage_string = 'Usage: 1.Build the caffe\n ' \ '2.cd /path/to/caffe/scripts\n ' \ @@ -505,10 +607,13 @@ def generate_dummy_model(model_path, dummy): parser.add_argument('-c', '--weights_channel', action='store', dest='scaling_mode', default='single', help='the scaling mode for weights') - + parser.add_argument('-s', '--sampling_iterations', action='store', dest='sampling_iterations', default=10, help='iteration number of sampling, the default value is 10.') + parser.add_argument('-ss', '--sampling_single', action='store_true', dest='sampling_single', default=False, + help='sampling single batch') + parser.add_argument('-p', '--performance_model', dest='performance_model', action="store_true", default=False, help='to generate model to measure performance only') @@ -532,7 +637,22 @@ def generate_dummy_model(model_path, dummy): parser.add_argument('-1st', '--enable_1st_conv', dest='enable_1st_conv', action="store_true", default=False, help='to enable 1st conv quantization') - + + parser.add_argument('-uff', '--disable_force_fp32', dest='disable_force_fp32', action="store_true", default=False, + help='to disable force fp32 output in conv/fc + fp32') + + parser.add_argument('-ucac', '--disable_cac_unify', dest='disable_cac_unify', action="store_true", default=False, + help='to disable scale unify in conv/fc + avg pooling + conv/fc') + + parser.add_argument('-fc', '--fc_int8', dest='fc_int8', action="store_true", default=False, + help='to enable int8 fc in quantized model') + + parser.add_argument('-fu', '--first_conv_force_u8', dest='first_conv_force_u8', action="store_true", default=False, + help='to enable 1st conv force u8 input') + + parser.add_argument('-clx', '--is_clx', dest='is_clx', action="store_true", default=False, + help='just work with -fu, means test machine is a clx') + params = parser.parse_args() if not check_existence(params.root): @@ -581,7 +701,7 @@ def generate_dummy_model(model_path, dummy): else: user_scaling_mode = params.scaling_mode - if params.calibration_algos != 'DIRECT' and params.calibration_algos != "KL" and params.calibration_algos != "MAXP": + if params.calibration_algos != 'DIRECT' and params.calibration_algos != "KL" and params.calibration_algos != "MAXP" and params.calibration_algos != "MA": user_calibration_algos = 'DIRECT' else: user_calibration_algos = params.calibration_algos @@ -591,6 +711,10 @@ def generate_dummy_model(model_path, dummy): else: user_conv_algo = params.conv_algo + if params.fc_int8: + quantize_layers.append("InnerProduct") + int8_layers.append("InnerProduct") + try: toleration = float(params.loss) if toleration >= 1 or toleration < 0: @@ -634,7 +758,7 @@ def generate_dummy_model(model_path, dummy): quantized_prototxt = model.rsplit('.')[0] + '_quantized.prototxt' print 'Sampling...' - (top_blobs_map, bottom_blobs_map) = generate_sample(model, user_input_weights, quantized_prototxt, user_scaling_mode, user_calibration_algos, user_conv_algo, user_sampling_iteration, user_enable_1st_conv) + (top_blobs_map, bottom_blobs_map) = generate_sample(model, user_input_weights, quantized_prototxt, user_scaling_mode, user_calibration_algos, user_conv_algo, user_sampling_iteration, user_enable_1st_conv, params.sampling_single) print 'Sampling done' top_1 = None if not params.quantize_model: @@ -646,5 +770,11 @@ def generate_dummy_model(model_path, dummy): tuning_quantized_topology(top_1, quantized_prototxt, caffe_bin_path, user_input_weights, top_blobs_map, bottom_blobs_map, user_input_iterations, toleration, detection_flag, target_blob_name, params.quantize_model, params.unsigned_range, params.concat_use_fp32, params.unify_concat_scales, params.conv_algo, user_enable_1st_conv) - + if not params.disable_force_fp32: + force_fp32_opt(quantized_prototxt) + if not params.disable_cac_unify: + cac_opt(quantized_prototxt) print 'Updated prototxt {} is generated.'.format(quantized_prototxt) + if params.first_conv_force_u8: + fu.first_conv_u8_input(quantized_prototxt, user_input_weights, params.is_clx) + diff --git a/scripts/conv_param.csv b/scripts/conv_param.csv deleted file mode 100644 index 843a0a587..000000000 --- a/scripts/conv_param.csv +++ /dev/null @@ -1,36 +0,0 @@ -Layer IFM OFM IH IW OH OW KH KW S Multiplier post-conv MACs %MACs pad_h pad_w -conv1_1 3 64 300 300 300 300 3 3 1 154829568 0.52% 1 1 -conv1_2 64 64 300 300 300 300 3 3 1 3303030784 11.02% 1 1 -conv2_1 64 128 150 150 150 150 3 3 1 1644167168 5.49% 1 1 -conv2_2 128 128 150 150 150 150 3 3 1 3288334336 10.97% 1 1 -conv3_1 128 256 75 75 75 75 3 3 1 1629519872 5.44% 1 1 -conv3_2 256 256 75 75 75 75 3 3 1 3259039744 10.88% 1 1 -conv3_3 256 256 75 75 75 75 3 3 1 3259039744 10.88% 1 1 -conv4_1 256 512 38 38 38 38 3 3 1 1644167168 5.49% 1 1 -conv4_2 512 512 38 38 38 38 3 3 1 3288334336 10.97% 1 1 -conv4_3 512 512 38 38 38 38 3 3 1 3288334336 10.97% 1 1 -conv5_1 512 512 19 19 19 19 3 3 1 792985600 2.65% 1 1 -conv5_2 512 512 19 19 19 19 3 3 1 792985600 2.65% 1 1 -conv5_3 512 512 19 19 19 19 3 3 1 792985600 2.65% 1 1 -fc6 512 1024 19 19 19 19 3 3 1 1061683200 3.54% 6 6 -fc7 1024 1024 19 19 19 19 1 1 1 378535936 1.26% 1 1 -conv6_1 1024 256 19 19 19 19 1 1 1 94633984 0.32% 0 0 -conv6_2 256 512 19 19 10 10 3 3 2 102760448 0.34% 1 1 -conv7_1 512 128 10 10 10 10 1 1 1 6553600 0.02% 0 0 -conv7_2 128 256 10 10 5 5 3 3 2 6422528 0.02% 1 1 -conv8_1 256 128 5 5 5 5 1 1 1 819200 0.00% 0 0 -conv8_2 128 256 5 5 3 3 3 3 1 2654208 0.01% 0 0 -conv9_1 256 128 3 3 3 3 1 1 1 294912 0.00% 0 0 -conv9_2 128 256 3 3 1 1 3 3 1 294912 0.00% 0 0 -conv4_3_norm_mbox_loc 512 16 38 38 38 38 3 3 1 102760448 0.34% 1 1 -conv4_3_norm_mbox_conf 512 84 38 38 38 38 3 3 1 539492352 1.80% 1 1 -fc7_mbox_loc 1024 24 19 19 19 19 3 3 1 74342400 0.25% 1 1 -fc7_mbox_conf 1024 126 19 19 19 19 3 3 1 390297600 1.30% 1 1 -conv6_2_mbox_loc 512 24 10 10 10 10 3 3 1 9633792 0.03% 1 1 -conv6_2_mbox_conf 512 126 10 10 10 10 3 3 1 50577408 0.17% 1 1 -conv7_2_mbox_loc 256 24 5 5 5 5 3 3 1 1038336 0.00% 1 1 -conv7_2_mbox_conf 256 126 5 5 5 5 3 3 1 5451264 0.02% 1 1 -conv8_2_mbox_loc 256 16 3 3 3 3 3 3 1 200704 0.00% 1 1 -conv8_2_mbox_conf 256 84 3 3 3 3 3 3 1 1053696 0.00% 1 1 -conv9_2_mbox_loc 256 16 1 1 1 1 3 3 1 4096 0.00% 1 1 -conv9_2_mbox_conf 256 84 1 1 1 1 3 3 1 21504 0.00% 1 1 diff --git a/scripts/fullyconnected0_bias.txt b/scripts/fullyconnected0_bias.txt deleted file mode 100755 index 7a34ce7fb..000000000 --- a/scripts/fullyconnected0_bias.txt +++ /dev/null @@ -1,50 +0,0 @@ --0.52648 -0.14514 --0.00609 --0.54142 --0.33371 -0.15921 -0.23688 --0.15909 -0.00000 -0.17268 -0.00000 -0.19106 --0.51010 -0.25068 --0.15763 -0.00532 -0.17466 -0.18762 --0.40360 -0.15760 --0.01277 -0.15623 -0.14291 -0.16817 --0.55435 -0.18330 --0.04775 --0.00545 -0.22381 --0.47685 --0.08149 --0.18368 -0.13688 --0.21559 -0.15994 -0.20392 -0.16123 --0.01336 --0.52437 --0.48815 -0.17127 -0.15154 --0.00809 -0.15623 -0.11234 --0.50226 --0.00459 -0.15509 --0.24297 -0.17359 diff --git a/scripts/fullyconnected0_weight.txt b/scripts/fullyconnected0_weight.txt deleted file mode 100755 index de4e7501b..000000000 --- a/scripts/fullyconnected0_weight.txt +++ /dev/null @@ -1,50 +0,0 @@ --0.07129 -0.53003 -0.35646 -0.14660 -0.16897 -0.23321 0.20957 -0.21513 0.00676 -0.09984 -0.42841 -0.27223 0.15670 -0.48676 -0.37537 -0.03728 -0.07060 -0.59026 0.03390 0.03871 -0.25896 -0.53132 -0.25636 -0.18938 -0.10396 -1.06565 -0.09902 0.54675 -1.79427 0.16398 -1.20422 -0.87072 -0.65275 -0.23073 -0.39300 0.01479 -0.00872 -0.23273 -0.57216 -0.58088 -0.58137 -0.57471 0.58094 0.58803 -0.58208 -0.57547 0.54975 0.56634 -0.57466 0.55053 0.56831 -0.55852 0.57747 0.54008 -0.31504 0.05590 0.18050 -0.07114 0.09375 0.04324 -0.03441 0.39587 0.15662 -0.09118 0.05118 0.40652 -0.19351 0.43114 0.01540 0.06368 0.03740 0.49264 -0.25244 -0.13939 0.41900 0.37942 0.46467 0.58328 0.26813 0.22404 0.01901 -0.16339 0.35144 -0.54153 0.39548 0.34408 0.36756 0.00671 -0.01854 -0.00556 -0.01745 -0.00261 0.15576 0.16259 0.14990 0.16314 -0.15868 -0.16190 0.16092 0.16521 -0.13036 -0.13619 0.12696 -0.12873 -0.12619 0.11293 -0.11293 -0.11986 -0.01482 0.00217 -0.01004 0.00327 -0.00497 0.00204 -0.00852 -0.00771 0.00574 0.00621 -0.01347 0.00366 -0.00289 0.00157 0.01195 0.00273 0.00255 -0.00526 -0.00911 -0.00692 0.00048 0.00137 -0.00287 0.00524 -0.00909 0.00118 0.00983 0.00898 -0.00894 0.00035 -0.00515 0.00724 0.00103 -0.00553 -0.01070 -0.00396 -0.00226 -0.00600 0.00604 0.00856 0.00436 -0.01028 -0.00237 0.00455 -0.01009 -0.00311 0.00592 -0.00666 -0.00335 -0.00322 0.00153 0.00829 -0.00901 -0.00197 --0.07939 -0.54605 -0.36569 -0.13772 -0.16909 -0.20098 0.22403 -0.21093 -0.00298 -0.09327 -0.43509 -0.26365 0.14746 -0.48391 -0.38155 -0.02875 -0.08224 -0.56676 0.02778 0.05303 -0.25526 -0.51492 -0.24285 -0.18757 -0.09895 -1.11378 -0.08893 0.56609 -1.79342 0.16093 -1.22135 -0.88018 -0.65195 -0.24857 -0.39486 0.01486 -0.00361 -0.24204 -0.59950 -0.59401 -0.59635 -0.59279 0.59121 0.60679 -0.59616 -0.59848 0.58388 0.57765 -0.59764 0.56903 0.58680 -0.58005 0.59219 0.56268 --0.04202 -0.32420 -0.21364 -0.11038 -0.17401 -0.24882 0.26104 -0.13919 -0.00768 -0.05587 -0.33370 -0.26666 0.15516 -0.34230 -0.24430 -0.08988 -0.04403 -0.42627 0.14506 0.09205 -0.21965 -0.15794 -0.17879 -0.08251 -0.10573 -0.77296 0.03772 0.49371 -1.15174 0.18240 -0.72824 -0.61026 -0.38789 -0.14319 -0.22062 0.01166 0.03784 -0.11819 -0.40129 -0.41011 -0.41699 -0.41144 0.40913 0.41099 -0.41432 -0.42474 0.47878 0.46701 -0.48998 0.46719 0.48665 -0.48367 0.49837 0.47219 -0.25139 0.07045 0.16751 -0.06525 0.11980 0.04643 -0.02117 0.41337 0.15222 -0.02785 0.07451 0.39956 -0.13087 0.41647 0.01117 0.02004 0.02713 0.47537 -0.36040 -0.17710 0.40380 0.37846 0.46491 0.59606 0.28123 0.22395 0.03115 -0.12906 0.34034 -0.55429 0.39627 0.35513 0.37017 0.00305 -0.00587 -0.01270 -0.01215 -0.00965 0.15992 0.17607 0.17407 0.15823 -0.17475 -0.18025 0.16094 0.17539 -0.14490 -0.16912 0.15322 -0.15501 -0.15311 0.12603 -0.14554 -0.14497 -0.17334 0.08373 0.32159 0.03957 0.07506 0.24123 0.15122 0.08764 0.19520 -0.17830 0.21728 0.29816 -0.08938 0.31567 0.19024 0.12456 0.07695 0.28141 -0.33547 -0.26959 0.20212 0.51325 0.27379 0.35976 0.26197 0.29079 0.06204 -0.17294 0.35431 -0.50796 0.57057 0.42845 0.36520 -0.04434 0.07827 -0.01556 -0.01220 0.01560 0.23801 0.26755 0.24846 0.24262 -0.27500 -0.26478 0.24856 0.25265 -0.09829 -0.08942 0.07988 -0.09540 -0.08643 0.07514 -0.08149 -0.09020 --0.21773 -0.05651 -0.22950 0.05865 -0.19038 -0.02731 0.07481 -0.41719 -0.17847 0.13759 -0.14828 -0.34193 0.15557 -0.38498 -0.02207 -0.01024 -0.07651 -0.47633 0.39887 0.21208 -0.36190 -0.37979 -0.51301 -0.65768 -0.24519 -0.23486 -0.04090 0.16204 -0.41672 0.63046 -0.54179 -0.40904 -0.33699 0.03222 0.02464 -0.02683 -0.01405 0.04300 -0.16940 -0.16668 -0.16227 -0.16573 0.16492 0.16028 -0.16186 -0.16913 0.11233 0.10373 -0.09540 0.09072 0.10719 -0.10077 0.08124 0.08966 -0.00421 0.00760 -0.00591 0.00982 -0.00019 -0.00809 -0.00927 0.00561 -0.00369 0.00185 0.00115 -0.00530 0.00737 0.00930 -0.00713 0.00890 -0.00104 0.00697 0.00318 -0.00055 0.00323 0.00683 0.00677 -0.00738 0.00065 -0.00383 -0.00921 -0.00074 -0.00809 0.00484 0.00598 -0.00028 -0.00195 -0.00726 0.00365 -0.00313 0.00004 -0.00351 -0.00206 -0.00399 0.00572 -0.00669 0.00903 -0.00170 -0.00484 -0.00104 0.00040 0.00550 0.00736 0.00593 -0.00081 0.00045 -0.00780 -0.00079 -0.08833 0.11830 0.15874 -0.02356 0.21160 0.06759 0.03009 0.44376 0.08070 0.05392 0.04947 0.39527 -0.11193 0.45965 -0.02606 0.01465 0.00271 0.48532 -0.40854 -0.21379 0.42440 0.33333 0.51209 0.65403 0.23512 0.24579 0.02502 -0.16941 0.35144 -0.58247 0.46821 0.41654 0.39684 0.01319 0.00112 -0.00160 -0.00976 -0.02611 0.17752 0.17300 0.18061 0.18062 -0.18397 -0.19463 0.17731 0.17166 -0.12545 -0.13181 0.13416 -0.13014 -0.11659 0.12186 -0.13460 -0.12224 --0.00403 -0.00064 -0.00048 0.00629 -0.00013 -0.00517 0.00215 0.00250 0.00638 0.00055 0.00055 0.00208 0.00878 -0.00469 0.00447 -0.00135 -0.00642 0.00014 0.00239 -0.00201 0.00125 -0.00425 0.00527 0.00843 0.00613 -0.00176 -0.00403 0.00819 -0.00047 -0.00954 -0.00858 -0.00250 0.00807 -0.00601 0.00608 -0.00314 -0.00991 -0.00112 -0.00565 -0.00004 0.00459 -0.00171 -0.00360 -0.00571 0.00098 -0.00567 -0.00926 -0.00535 0.00634 0.00458 0.00036 -0.00168 0.00039 0.00168 --0.13252 0.14245 0.22001 0.07312 0.21515 0.15146 0.11787 0.25420 0.07698 -0.08362 0.20081 0.25801 -0.06229 0.26367 0.12811 0.00835 0.03558 0.39161 -0.35978 -0.22702 0.27457 0.39831 0.35672 0.29827 0.25773 0.22618 0.05350 -0.11497 0.26595 -0.38660 0.44212 0.37185 0.27811 -0.02625 0.04579 -0.00262 -0.00757 -0.01599 0.18170 0.17817 0.18011 0.17785 -0.19399 -0.19410 0.18374 0.18986 -0.15736 -0.16203 0.14443 -0.15361 -0.15043 0.14583 -0.16073 -0.14882 --0.05895 -0.52177 -0.35276 -0.14265 -0.17177 -0.21471 0.22030 -0.21286 0.00526 -0.08713 -0.41523 -0.26440 0.15526 -0.46596 -0.35418 -0.02507 -0.06767 -0.57021 0.02741 0.04426 -0.26356 -0.52634 -0.25028 -0.18078 -0.10419 -1.06727 -0.07365 0.55494 -1.78344 0.15509 -1.18012 -0.84672 -0.63405 -0.22355 -0.37001 0.01409 -0.00414 -0.21414 -0.56747 -0.56968 -0.55627 -0.55763 0.56756 0.58188 -0.56614 -0.56134 0.54906 0.55996 -0.58177 0.56176 0.56238 -0.54726 0.56918 0.55339 --0.25868 0.15158 0.43422 0.02838 0.34141 0.35725 0.08343 0.13204 0.11817 -0.14135 0.40602 0.10423 -0.08862 0.22744 0.22742 0.10724 0.00192 0.21377 -0.34167 -0.18606 0.04361 0.65780 0.32283 0.20995 0.15448 0.18815 0.15813 -0.06164 0.16763 -0.26916 0.62624 0.39086 0.32932 -0.06457 0.10966 -0.00494 -0.01288 -0.00808 0.24405 0.25134 0.24039 0.25519 -0.24479 -0.24481 0.24376 0.25115 -0.04099 -0.02527 0.01300 -0.01508 -0.01765 0.01280 -0.04579 -0.01084 --0.28581 -0.06771 -0.17854 0.09740 -0.09284 -0.02965 0.04797 -0.38918 -0.16333 0.11721 -0.07377 -0.41302 0.21138 -0.44156 -0.05278 -0.06071 -0.03223 -0.49078 0.30772 0.16742 -0.42971 -0.38074 -0.46121 -0.61829 -0.28165 -0.24622 0.01496 0.18993 -0.37025 0.58244 -0.42922 -0.39900 -0.39208 0.01754 0.04652 0.03596 -0.01679 0.02340 -0.15852 -0.16210 -0.15764 -0.16397 0.17697 0.16823 -0.16030 -0.16624 0.11833 0.12088 -0.12368 0.12096 0.12255 -0.12404 0.11821 0.11771 -0.01443 0.00645 0.04876 -0.00590 -0.00049 -0.02791 0.03080 -0.00818 -0.00993 0.00338 -0.00680 0.00943 -0.01933 0.01706 -0.01471 0.03053 -0.00279 0.04307 -0.03899 -0.00188 0.00554 0.01659 0.03270 0.00590 0.03819 -0.01284 0.00945 -0.02036 0.02217 -0.04360 0.03696 0.04804 0.02271 -0.01498 -0.01127 -0.00527 -0.00920 -0.00093 0.01387 0.00623 0.00109 0.01345 -0.01377 -0.00520 0.00506 -0.00282 0.03188 0.02993 -0.02531 0.01937 0.02429 -0.03299 0.03694 0.02493 -0.25640 0.08077 0.20210 -0.06494 0.12527 0.04964 -0.00777 0.43210 0.16327 -0.05690 0.08925 0.40768 -0.13684 0.43840 0.01296 0.01605 0.04515 0.49490 -0.37238 -0.18157 0.40691 0.41200 0.49724 0.63483 0.26809 0.23320 0.04537 -0.15579 0.34724 -0.58023 0.46788 0.39495 0.37531 -0.00004 -0.00409 -0.00808 -0.01128 -0.00652 0.17629 0.17920 0.17326 0.18188 -0.19134 -0.19410 0.17853 0.18656 -0.14678 -0.14646 0.13336 -0.15208 -0.14476 0.10934 -0.13772 -0.12813 -0.02998 0.13087 0.15628 0.10862 0.12548 0.10527 0.08897 0.38276 0.16351 -0.07921 0.16579 0.37210 -0.07706 0.38551 0.04685 0.02290 0.05555 0.48050 -0.30497 -0.22148 0.32555 0.28765 0.47846 0.56550 0.28048 0.25936 0.04357 -0.14332 0.32908 -0.47990 0.44846 0.37282 0.33052 -0.01973 0.02283 -0.00710 -0.00991 -0.01366 0.20141 0.21561 0.20910 0.20161 -0.22297 -0.22163 0.21218 0.20028 -0.14116 -0.14017 0.15078 -0.13519 -0.12680 0.12431 -0.14351 -0.13200 --0.03890 -0.40089 -0.26255 -0.16242 -0.16887 -0.26770 0.30492 -0.17793 -0.00894 -0.05787 -0.37124 -0.31209 0.18376 -0.41671 -0.32393 -0.06853 -0.04035 -0.52704 0.14876 0.15043 -0.29336 -0.28899 -0.23471 -0.12833 -0.10891 -0.93392 0.01413 0.61139 -1.54641 0.23298 -1.01226 -0.79963 -0.54319 -0.15096 -0.26188 0.01021 0.04380 -0.12893 -0.47865 -0.49239 -0.48756 -0.48400 0.49460 0.49917 -0.48378 -0.48230 0.58289 0.58166 -0.60459 0.57400 0.57316 -0.57188 0.60821 0.56681 -0.28383 0.06131 0.18968 -0.09013 0.10018 0.05203 -0.03668 0.41155 0.16887 -0.07993 0.08662 0.39137 -0.14978 0.42394 0.03009 0.03803 0.05907 0.47838 -0.28453 -0.17172 0.40101 0.37440 0.46207 0.58961 0.27811 0.22488 0.03278 -0.15021 0.35071 -0.52393 0.39822 0.35570 0.35444 -0.00134 0.00023 -0.00462 -0.01234 -0.00475 0.17502 0.18025 0.16660 0.16143 -0.17199 -0.17851 0.16273 0.18010 -0.15302 -0.16251 0.13667 -0.13899 -0.13519 0.13107 -0.13748 -0.13073 -0.00173 -0.00655 -0.01019 -0.00586 -0.00716 -0.00525 0.00513 -0.00379 0.00826 0.00621 -0.01368 -0.00149 0.00364 -0.00410 -0.00671 0.00275 -0.00406 -0.00108 0.00126 -0.00278 -0.01077 0.00142 0.00918 -0.00560 -0.00539 -0.01733 -0.00262 0.00339 -0.02064 -0.00399 -0.00343 -0.00120 -0.00098 -0.01218 -0.01800 -0.00531 -0.00470 -0.01540 -0.01504 -0.00293 -0.00351 0.00192 0.00508 0.00438 0.00000 -0.00471 -0.00596 0.01507 -0.00700 0.00849 0.00693 -0.00652 -0.00437 -0.00584 -0.12876 0.08157 0.23548 0.01819 0.13070 0.05380 0.03104 0.39022 0.16514 -0.06491 0.07274 0.36085 -0.09698 0.40149 0.02340 0.04668 0.04127 0.44723 -0.29059 -0.20788 0.36682 0.35595 0.45230 0.60086 0.26302 0.24586 0.01880 -0.15474 0.30265 -0.46598 0.41248 0.35201 0.33330 -0.00599 0.01020 -0.01501 -0.02072 -0.00314 0.16578 0.17178 0.15922 0.16677 -0.16696 -0.17371 0.16551 0.16524 -0.12752 -0.13031 0.11535 -0.11929 -0.12955 0.12018 -0.12286 -0.12314 -0.24124 0.03472 0.20888 0.03354 0.08943 0.02755 0.01490 0.38370 0.15713 -0.05474 0.00428 0.41411 -0.13374 0.42034 0.00720 0.07668 0.01638 0.47316 -0.19767 -0.09100 0.39624 0.37288 0.46282 0.57042 0.25708 0.21436 0.01390 -0.16205 0.34342 -0.49248 0.40313 0.32623 0.34871 0.01570 -0.00448 -0.01379 -0.01850 0.00208 0.15434 0.15401 0.15897 0.15443 -0.16265 -0.15708 0.15783 0.15405 -0.09921 -0.10542 0.10852 -0.11727 -0.10686 0.08269 -0.10004 -0.10615 -0.11687 0.09709 0.15745 0.00469 0.16234 0.05894 0.03838 0.42547 0.15129 -0.02227 0.10008 0.39952 -0.10588 0.43308 -0.02211 0.02120 0.03354 0.45862 -0.37291 -0.22450 0.38360 0.39060 0.48796 0.62996 0.27663 0.21914 0.04663 -0.14158 0.33422 -0.56062 0.45565 0.38186 0.35897 0.00070 0.00847 -0.00166 -0.00251 -0.01189 0.17542 0.17823 0.18784 0.19099 -0.18968 -0.19754 0.18708 0.19171 -0.15371 -0.15624 0.14658 -0.14471 -0.15432 0.13953 -0.14106 -0.13925 --0.09731 -0.55817 -0.36119 -0.10733 -0.20424 -0.20057 0.23422 -0.21096 0.00829 -0.11498 -0.45224 -0.26521 0.07833 -0.47016 -0.35755 0.03216 -0.08534 -0.57401 0.05179 0.05828 -0.24497 -0.50072 -0.23393 -0.17363 -0.10444 -1.13222 -0.09313 0.58729 -1.74984 0.13928 -1.20330 -0.86081 -0.61973 -0.24779 -0.42363 0.01477 -0.00790 -0.24536 -0.59683 -0.61680 -0.60700 -0.61837 0.61140 0.62216 -0.60247 -0.61499 0.57894 0.58199 -0.59537 0.57442 0.58805 -0.57479 0.60248 0.58056 -0.18101 0.11234 0.17539 -0.04237 0.15187 0.06758 0.02366 0.41803 0.11652 -0.02271 0.12734 0.42368 -0.12553 0.44415 -0.01248 -0.01505 0.03367 0.48919 -0.41265 -0.24987 0.41592 0.41171 0.49844 0.62830 0.27624 0.23102 0.04189 -0.14713 0.37291 -0.57674 0.48821 0.38775 0.37364 0.00619 0.00548 -0.01296 -0.00983 -0.01707 0.19383 0.19444 0.19686 0.19112 -0.20660 -0.19445 0.19981 0.19547 -0.15890 -0.15770 0.14203 -0.14653 -0.13982 0.13088 -0.13603 -0.13852 -0.00508 -0.05852 -0.00063 -0.03610 -0.06868 -0.04074 0.09851 0.00891 -0.00516 0.04876 -0.09951 -0.06879 0.06401 -0.03416 -0.04700 -0.03395 -0.03747 -0.05805 0.07867 0.08512 -0.05216 -0.02262 -0.02672 -0.03659 -0.04780 -0.14612 0.03647 0.12971 -0.17659 0.03914 -0.12065 -0.08962 -0.06212 -0.02534 -0.00666 -0.00516 -0.00151 -0.00370 -0.06934 -0.06235 -0.06181 -0.06486 0.06758 0.07030 -0.07752 -0.06728 0.21596 0.22151 -0.22464 0.20236 0.22504 -0.22031 0.20427 0.22791 -0.00857 -0.00952 -0.00386 -0.00603 -0.01326 -0.00053 0.00392 0.00690 -0.00505 -0.00506 0.00565 -0.00797 0.00567 0.00246 -0.00151 -0.00833 0.00176 -0.00893 -0.00589 -0.00803 -0.00225 0.01221 -0.00022 0.00597 -0.00178 -0.00664 -0.00943 -0.01315 -0.00204 -0.00747 0.00744 0.00046 0.00872 -0.00585 -0.00124 -0.00593 -0.00416 -0.01346 0.00512 0.00586 -0.00394 0.00159 -0.00796 0.00513 0.00072 -0.00102 0.00504 -0.00898 -0.00346 0.00187 -0.00050 -0.00075 0.00728 -0.01003 --0.22877 0.15993 0.27453 0.00914 0.26460 0.36852 0.14316 0.10350 0.11807 -0.06993 0.29734 0.20646 -0.11835 0.16446 0.20613 0.07237 0.04805 0.22757 -0.31196 -0.15184 0.14680 0.49527 0.29157 0.22988 0.15584 0.17776 0.13359 -0.07501 0.24963 -0.33586 0.47757 0.36076 0.28695 -0.05499 0.07972 -0.00600 -0.02297 -0.00683 0.23302 0.22146 0.22716 0.22544 -0.23101 -0.23735 0.22340 0.22591 -0.09137 -0.07499 0.06899 -0.07604 -0.08237 0.07087 -0.09045 -0.06497 --0.10377 -0.49015 -0.31480 -0.03879 -0.14855 -0.18386 0.25575 -0.17262 -0.00449 -0.07313 -0.45765 -0.21976 0.08241 -0.40047 -0.28872 0.08279 -0.05727 -0.42011 0.04582 0.08937 -0.19486 -0.39360 -0.17947 -0.09598 -0.08694 -0.92659 -0.08277 0.45321 -1.38542 0.09929 -0.89098 -0.69134 -0.45626 -0.22763 -0.36307 0.01060 -0.00469 -0.22411 -0.51442 -0.51523 -0.52083 -0.52044 0.51220 0.52639 -0.51767 -0.51011 0.54515 0.55314 -0.56909 0.54233 0.56219 -0.54951 0.56749 0.54215 --0.04741 -0.06329 0.00237 -0.01481 -0.02645 -0.05616 -0.01556 -0.00651 0.00234 -0.00912 -0.07531 -0.03977 0.01515 -0.01298 -0.04740 -0.00942 -0.02366 -0.02747 0.03201 0.00609 -0.02454 -0.03017 -0.01302 -0.00516 -0.00975 -0.06742 -0.05922 -0.04074 -0.06703 -0.01230 -0.06432 -0.05185 -0.01683 -0.07813 -0.06685 -0.00511 -0.00922 -0.07168 -0.07526 -0.08511 -0.08584 -0.09006 0.07599 0.08746 -0.08750 -0.08920 0.08603 0.08165 -0.08230 0.07316 0.07999 -0.09063 0.08473 0.07190 --0.00492 -0.16840 -0.05136 -0.01279 -0.10804 -0.13087 0.03202 -0.04752 0.00401 0.03779 -0.20249 -0.10857 0.03847 -0.11223 -0.12695 -0.06953 -0.07243 -0.17622 0.10371 0.03084 -0.08029 -0.04124 -0.08691 -0.04062 -0.03961 -0.33282 -0.00534 0.16857 -0.35022 0.08962 -0.23223 -0.22346 -0.10392 -0.11887 -0.11752 -0.00011 0.02657 -0.09921 -0.23400 -0.23471 -0.25294 -0.24818 0.23799 0.24945 -0.24423 -0.23365 0.33447 0.31976 -0.32693 0.32011 0.33431 -0.34459 0.33103 0.32632 -0.27101 0.03486 0.19390 -0.03218 0.09038 0.02846 -0.01681 0.39777 0.15374 -0.06807 0.01081 0.40166 -0.15863 0.41490 0.00921 0.06190 0.01762 0.46395 -0.22579 -0.11357 0.39641 0.35005 0.46080 0.58297 0.24730 0.24155 0.00596 -0.16111 0.32670 -0.50997 0.37342 0.34450 0.36344 0.00539 -0.00477 -0.00589 -0.01820 -0.00153 0.14134 0.15735 0.15521 0.14847 -0.15603 -0.14878 0.15819 0.15863 -0.11974 -0.12480 0.11819 -0.12053 -0.11759 0.09501 -0.10291 -0.10820 --0.22447 -0.13051 -0.25306 0.09535 -0.15175 -0.09023 0.09153 -0.45978 -0.19017 0.18296 -0.20273 -0.42504 0.19694 -0.45884 -0.08451 -0.04196 -0.05113 -0.55255 0.39315 0.24464 -0.44034 -0.45893 -0.52538 -0.68497 -0.30922 -0.25825 -0.03396 0.19998 -0.43371 0.68443 -0.57686 -0.46764 -0.40206 0.03319 0.01922 -0.01586 -0.00777 0.02206 -0.22271 -0.23566 -0.22128 -0.22418 0.23062 0.24026 -0.23059 -0.22652 0.18398 0.18042 -0.15980 0.18625 0.18318 -0.17078 0.16738 0.16356 -0.29005 0.06457 0.21000 -0.07787 0.09481 0.05369 -0.04299 0.41675 0.17360 -0.07460 0.07584 0.39120 -0.17505 0.43155 0.03505 0.05746 0.03151 0.47996 -0.23728 -0.17072 0.41903 0.37122 0.47171 0.60533 0.28186 0.24059 0.02847 -0.15146 0.36321 -0.53493 0.40408 0.37073 0.35053 0.00020 -0.01645 -0.00475 -0.01390 0.00137 0.16650 0.17144 0.17386 0.16231 -0.18295 -0.17154 0.17396 0.17741 -0.13875 -0.13711 0.12215 -0.14639 -0.14225 0.11446 -0.12813 -0.13762 --0.12678 0.14110 0.25961 0.03802 0.25764 0.17758 0.09043 0.21659 0.09431 -0.07572 0.22890 0.27752 -0.02886 0.21226 0.14438 0.02651 0.06424 0.37861 -0.40681 -0.23659 0.24500 0.36658 0.27459 0.25821 0.22465 0.19052 0.09479 -0.07132 0.23792 -0.42089 0.46947 0.40470 0.31557 -0.03581 0.06710 -0.01948 -0.01356 -0.02020 0.19587 0.18338 0.19827 0.17982 -0.18342 -0.19574 0.18005 0.18107 -0.14053 -0.12365 0.12331 -0.12642 -0.12536 0.10927 -0.13853 -0.12104 -0.17785 0.06052 0.19735 -0.02175 0.21575 -0.06908 0.03354 0.35645 0.07186 0.07298 0.15303 0.29835 -0.09770 0.39907 -0.03966 -0.05255 0.06343 0.34359 -0.43586 -0.15348 0.29698 0.20315 0.30194 0.53072 0.14130 0.15107 0.04997 -0.14373 0.31402 -0.65907 0.44908 0.40153 0.34393 0.01170 0.03293 -0.01539 -0.00951 -0.03221 0.13586 0.15120 0.15453 0.13694 -0.15456 -0.14995 0.14552 0.15203 0.01099 0.00367 -0.00187 0.00631 0.00927 -0.02562 0.00425 0.01445 --0.00292 -0.01248 -0.01583 -0.01074 -0.00672 -0.01191 -0.00163 -0.01012 0.00791 -0.01967 -0.01156 -0.01119 -0.00280 -0.00439 -0.00576 -0.01440 -0.00846 -0.01029 -0.00767 0.00102 -0.00154 0.00264 -0.00653 -0.00077 -0.01588 -0.00528 -0.01034 -0.00202 -0.01123 -0.00261 -0.01477 -0.00425 -0.01723 -0.00491 -0.01415 -0.00568 -0.00219 -0.01847 -0.01271 0.00236 -0.01137 -0.00728 -0.00106 0.01065 -0.00836 -0.01620 0.00485 -0.00058 0.00040 -0.00798 0.00652 -0.00664 0.00814 -0.00669 --0.08925 -0.52541 -0.36233 -0.13361 -0.16689 -0.20359 0.21304 -0.22919 -0.00657 -0.11252 -0.42856 -0.26142 0.10903 -0.46618 -0.35429 -0.01044 -0.06593 -0.57215 0.04504 0.04449 -0.25208 -0.50480 -0.23588 -0.18389 -0.09374 -1.06509 -0.08598 0.56841 -1.75972 0.16547 -1.18390 -0.84609 -0.62835 -0.23451 -0.39309 0.01382 -0.00513 -0.22579 -0.57315 -0.58350 -0.58242 -0.57991 0.58234 0.60192 -0.59663 -0.57923 0.56278 0.55743 -0.57552 0.56586 0.56726 -0.55754 0.58620 0.55889 --0.04514 -0.50222 -0.32824 -0.14738 -0.15352 -0.21102 0.20443 -0.21487 0.00129 -0.08242 -0.42212 -0.27296 0.17071 -0.47148 -0.35210 -0.04443 -0.06143 -0.55997 0.02050 0.04292 -0.25924 -0.50733 -0.23020 -0.19478 -0.09290 -1.01991 -0.07087 0.53350 -1.73347 0.14730 -1.17325 -0.85055 -0.63209 -0.20918 -0.35667 0.01569 -0.00049 -0.19748 -0.53883 -0.53514 -0.52980 -0.52847 0.53277 0.53847 -0.53142 -0.54177 0.53557 0.53098 -0.53626 0.53976 0.52377 -0.52397 0.56100 0.53344 -0.09937 0.10693 0.18522 0.03374 0.14388 0.07049 0.05490 0.39333 0.17201 -0.08445 0.11656 0.36677 -0.09668 0.42262 0.01530 0.04289 0.06943 0.47917 -0.28829 -0.23160 0.35061 0.37837 0.46584 0.58709 0.24900 0.22592 0.03539 -0.12817 0.31451 -0.49770 0.41829 0.36070 0.33459 -0.00850 0.00970 -0.01064 -0.01827 -0.00968 0.17964 0.18956 0.19323 0.17699 -0.19639 -0.19096 0.18970 0.17838 -0.14407 -0.12695 0.12584 -0.13889 -0.13238 0.12672 -0.12726 -0.12717 -0.23496 0.04348 0.19508 -0.06786 0.17484 0.04127 0.06097 0.42647 0.07948 0.02734 0.06940 0.45033 -0.12952 0.41785 -0.04806 -0.03795 0.00035 0.48004 -0.39918 -0.23578 0.39074 0.38878 0.50533 0.61913 0.25208 0.21925 0.02070 -0.17142 0.33904 -0.54970 0.46099 0.39443 0.35406 0.00948 -0.00897 -0.00231 -0.01015 -0.01714 0.15845 0.16422 0.16678 0.16114 -0.17705 -0.16211 0.17112 0.16944 -0.16311 -0.16433 0.15471 -0.15452 -0.14871 0.13601 -0.15159 -0.16171 --0.01030 -0.00437 0.00471 0.00564 -0.01376 -0.00483 0.00600 -0.00271 0.00542 -0.01138 -0.01406 -0.00355 0.00839 -0.00136 -0.01452 -0.00771 0.00006 -0.00327 -0.00114 0.00646 -0.00872 -0.00376 -0.00099 0.00535 0.00101 -0.01420 0.00200 0.00736 -0.00621 -0.00286 -0.00937 0.00180 0.00456 -0.00985 -0.01192 -0.00454 -0.00460 -0.00411 -0.00463 0.00391 0.00586 -0.00062 0.00980 0.00110 -0.01227 0.00114 0.00027 0.01439 -0.00255 0.00320 -0.00199 0.00169 -0.01120 0.00907 -0.29757 0.07857 0.17624 -0.08556 0.11071 0.04669 -0.03488 0.41297 0.16405 -0.04440 0.09246 0.41425 -0.15427 0.43031 0.00413 0.00031 0.05600 0.48691 -0.38241 -0.21299 0.41620 0.38624 0.47890 0.62526 0.26719 0.25107 0.01410 -0.15419 0.34041 -0.52272 0.40303 0.35937 0.36167 0.00259 -0.02256 -0.00802 -0.01375 -0.00130 0.15939 0.16638 0.16697 0.16956 -0.17787 -0.17315 0.16196 0.16564 -0.16409 -0.17299 0.16019 -0.15701 -0.16039 0.15205 -0.15089 -0.14549 -0.07154 0.09884 0.10016 -0.05161 0.09757 0.04540 -0.04229 0.17209 0.04696 -0.08337 0.10200 0.29421 -0.12470 0.30331 0.00310 0.02291 -0.01200 0.32978 -0.23603 -0.16426 0.35203 0.24271 0.37444 0.30973 0.26225 0.15996 0.00187 -0.13822 0.22558 -0.39364 0.37136 0.31571 0.24327 -0.00546 -0.03161 -0.00420 -0.00729 -0.02827 0.11907 0.13157 0.12538 0.11572 -0.12540 -0.12234 0.13272 0.12661 -0.14490 -0.15908 0.15392 -0.14220 -0.14910 0.13439 -0.14240 -0.15383 --0.06360 -0.51967 -0.35433 -0.14806 -0.15754 -0.22092 0.21372 -0.20918 -0.00405 -0.08481 -0.41181 -0.27195 0.16843 -0.46442 -0.36730 -0.02732 -0.06094 -0.57313 0.02683 0.03389 -0.26019 -0.51362 -0.24190 -0.18038 -0.08543 -1.04889 -0.06866 0.55588 -1.77296 0.16334 -1.17874 -0.83676 -0.63104 -0.22954 -0.36823 0.01443 -0.00057 -0.20004 -0.55520 -0.56081 -0.56244 -0.55941 0.56797 0.55984 -0.55313 -0.56049 0.55103 0.55722 -0.55896 0.55072 0.54941 -0.54970 0.56467 0.54803 -0.00896 -0.01581 -0.00720 0.00901 0.00109 0.00939 -0.00366 0.00438 -0.00721 0.00224 -0.00150 -0.00385 0.00407 -0.00038 -0.00133 0.00506 0.01106 -0.00383 0.00146 0.00030 -0.00318 0.01289 0.00295 0.00408 -0.00517 0.00377 -0.00243 0.00305 -0.00641 0.00042 0.00144 0.00488 0.00550 -0.01500 -0.00326 -0.00456 -0.00903 -0.00520 -0.00547 -0.00920 0.00801 0.00931 -0.00816 -0.00523 0.00187 -0.00701 0.00525 -0.00505 0.00049 -0.00867 0.00187 -0.00160 -0.00076 -0.00955 -0.29736 0.07067 0.18365 -0.07929 0.09987 0.06166 -0.02671 0.41022 0.17817 -0.10154 0.06896 0.39306 -0.14491 0.41661 0.02818 0.06516 0.03404 0.47656 -0.24919 -0.20347 0.41350 0.37480 0.46044 0.58929 0.27701 0.24720 0.00779 -0.17774 0.36077 -0.48858 0.38720 0.35541 0.35986 -0.00400 -0.01159 -0.00266 -0.01614 0.00370 0.17335 0.17297 0.16204 0.17179 -0.17425 -0.18571 0.16625 0.16312 -0.14914 -0.15875 0.14187 -0.14834 -0.14798 0.12671 -0.13739 -0.13896 --0.06784 -0.24360 -0.10987 -0.03836 -0.10634 -0.14264 0.15080 -0.09521 0.00016 0.03046 -0.22938 -0.16908 0.07246 -0.17070 -0.15746 -0.02488 -0.09113 -0.18756 0.11555 0.11432 -0.10394 -0.18731 -0.07801 -0.07479 -0.07999 -0.43967 -0.04476 0.23873 -0.52723 0.05472 -0.34747 -0.37213 -0.23812 -0.15566 -0.16549 -0.00129 0.00202 -0.12890 -0.31049 -0.30603 -0.31141 -0.29788 0.30611 0.30878 -0.31432 -0.30756 0.42850 0.41998 -0.44033 0.41086 0.42033 -0.42968 0.42963 0.42655 -0.15753 0.10089 0.18717 -0.05181 0.16186 0.05620 0.01761 0.42108 0.06842 0.02737 0.08587 0.40773 -0.12868 0.43920 -0.01451 -0.00080 -0.00326 0.46932 -0.39952 -0.23007 0.39889 0.35557 0.48204 0.63506 0.26862 0.21245 0.03899 -0.14288 0.33428 -0.60642 0.45904 0.42270 0.38672 0.01009 0.00922 -0.00107 -0.01348 -0.02753 0.16528 0.18094 0.17616 0.18103 -0.19188 -0.18478 0.18423 0.18345 -0.15186 -0.16280 0.16246 -0.15373 -0.15389 0.13770 -0.16080 -0.14190 diff --git a/scripts/fullyconnected1_bias.txt b/scripts/fullyconnected1_bias.txt deleted file mode 100755 index cab303e18..000000000 --- a/scripts/fullyconnected1_bias.txt +++ /dev/null @@ -1,100 +0,0 @@ -0.15514 -0.14642 -0.15423 -0.16977 --0.02847 -0.15264 --0.17916 -0.15611 --0.00592 -0.15220 -0.27332 --0.00574 --0.15880 -0.13076 --0.01589 --0.02664 --0.00532 --0.00600 --0.00600 --0.00821 -0.14866 -0.13446 --0.00600 --0.00816 -0.06226 -0.15537 --0.03911 -0.26826 --0.01579 -0.24282 -0.18751 -0.16900 --0.21704 --0.00552 -0.11303 -0.17758 --0.01164 --0.01136 --0.06757 -0.12659 --0.15496 -0.15092 --0.11152 -0.11684 -0.14628 --0.00607 --0.00104 -0.13117 --0.08426 --0.18187 --0.00600 --0.00631 -0.42974 --0.00965 -0.04059 -0.15799 --0.08904 --0.00503 --0.00288 -0.17041 --0.06912 --0.01301 --0.07285 -0.12820 -0.00413 --0.00538 -0.13958 --0.00673 --0.01714 --0.00600 --0.11952 -0.16299 -0.14346 --0.00589 --0.03600 -0.53688 --0.02315 --0.06653 --0.21669 --0.19535 --0.33762 --0.05908 -0.14294 --0.07217 -0.16249 --0.37725 --0.02282 -0.31571 --0.00803 -0.12523 --0.01116 -0.19809 --0.02756 --0.01790 --0.18551 --0.00608 --0.15788 -0.16545 -0.17362 -0.20541 diff --git a/scripts/fullyconnected1_weight.txt b/scripts/fullyconnected1_weight.txt deleted file mode 100755 index 121c7b1b3..000000000 --- a/scripts/fullyconnected1_weight.txt +++ /dev/null @@ -1,100 +0,0 @@ --0.01227 0.05150 -0.00495 -0.01940 -0.06041 0.02969 0.24649 -0.03841 -0.00707 0.03044 0.00139 0.07712 -0.00866 0.07466 -0.06570 -0.00031 0.05964 0.00592 -0.03752 0.05502 -0.00797 0.01270 0.04677 0.03813 -0.00868 0.06670 -0.00062 0.00305 0.01680 -0.00812 -0.00664 -0.05372 0.02591 -0.02397 0.05343 0.07474 0.18774 0.00030 -0.01350 -0.01130 0.00785 0.06249 -0.01100 0.05915 0.05795 -0.00221 0.00330 0.04858 -0.01116 0.12227 --0.01617 0.03672 -0.00542 -0.01021 -0.03836 0.03600 0.24673 -0.03182 0.00238 0.01918 -0.00050 0.03665 -0.02045 0.05095 -0.06810 -0.00530 0.04783 0.00409 -0.03829 0.02918 -0.00072 0.00359 0.03476 0.02955 -0.01814 0.07407 -0.01633 0.00172 0.01539 -0.02255 -0.00689 -0.02078 0.04337 -0.02640 0.04740 0.06214 0.18447 0.00241 -0.01309 -0.01397 -0.00917 0.07106 -0.01472 0.04360 0.06965 -0.02629 -0.00120 0.03802 -0.02515 0.11966 --0.00334 -0.00605 -0.01094 0.00072 -0.02334 0.03351 0.02492 -0.02441 -0.00901 0.01082 0.00038 0.03615 -0.01968 0.00154 -0.05522 -0.01963 0.03738 0.01996 -0.02198 0.00682 -0.00744 0.02511 0.00496 0.04325 -0.00624 0.04762 0.00051 0.00684 0.02122 -0.00107 -0.00250 -0.01701 0.01496 -0.02120 0.00948 0.07662 0.18130 -0.00023 -0.00341 -0.02083 0.00949 0.00523 -0.00757 0.01476 0.01124 -0.00720 -0.01341 0.01431 -0.02260 0.01029 --0.01608 0.03226 0.00614 -0.01039 -0.03614 0.04358 0.09322 -0.04328 0.00790 0.04476 0.00858 0.06623 -0.00976 0.10590 -0.05994 -0.00724 0.07654 0.06205 -0.03264 0.02904 0.01303 0.02578 0.03567 0.05355 -0.00876 0.06788 -0.00959 0.00096 0.05003 -0.00895 -0.01550 -0.03943 0.03625 -0.02395 0.02763 0.09610 0.19236 -0.00701 -0.01866 -0.02870 0.00796 0.01607 0.00156 0.03062 0.01843 -0.01947 0.00764 0.01525 -0.01872 0.06876 -0.00734 -0.00902 0.00088 0.00430 -0.02145 -0.00855 0.01967 0.01228 0.00532 0.01262 -0.00623 0.00197 -0.00902 0.00071 -0.03691 -0.00022 -0.00758 0.01219 -0.02257 0.00114 0.00043 0.00156 -0.02132 -0.01265 -0.00039 -0.06132 -0.00265 -0.00046 0.00203 -0.00356 0.00787 -0.00345 -0.02890 0.00070 -0.01008 -0.01000 0.02590 0.00320 -0.00664 -0.01288 0.00013 -0.00278 0.00101 0.00425 -0.00561 -0.00272 0.01409 -0.00369 -0.00114 -0.00152 --0.02605 0.06119 0.00390 -0.00996 -0.03300 0.04740 0.26265 -0.02976 -0.00359 0.02410 0.00772 0.05053 -0.01894 0.05695 -0.08502 -0.01585 0.05690 0.00924 -0.03760 0.05904 -0.01447 0.01824 0.04627 0.03978 -0.02906 0.07679 -0.00044 -0.01434 0.02250 -0.01525 -0.00570 -0.02236 0.06024 -0.02325 0.06958 0.07503 0.16943 -0.01480 -0.01999 -0.01570 -0.00204 0.05403 -0.00982 0.07380 0.06725 -0.01325 -0.00090 0.05305 -0.00976 0.12229 -0.01119 -0.00876 -0.00199 0.01163 -0.00716 -0.00531 0.01289 -0.01147 -0.00979 0.01467 -0.00540 0.02848 -0.00780 0.01973 -0.02894 -0.00920 0.01248 -0.00478 -0.00493 -0.00488 0.01512 0.00967 0.00960 -0.00493 0.00464 -0.01121 -0.01473 0.00422 0.00483 0.01309 0.01078 0.01139 0.00699 -0.00946 0.00199 0.00284 -0.00269 0.00417 0.00550 0.00286 0.00854 0.00616 -0.00006 -0.02542 -0.00284 0.01085 0.01177 0.00519 0.00895 0.00429 --0.01472 0.00851 0.00710 -0.01546 -0.04385 0.02428 -0.00057 -0.04553 0.00867 0.00464 0.00432 0.06070 -0.02039 0.03009 -0.06215 -0.00427 0.04132 0.02906 -0.01950 0.01317 0.01755 0.01842 0.00243 0.04250 -0.00815 0.04841 -0.01579 -0.00253 0.01847 -0.02106 -0.00706 -0.02565 0.00561 -0.01508 -0.00108 0.08608 0.19335 0.01140 -0.00916 -0.00835 -0.00301 -0.00795 -0.00288 0.01855 0.01266 -0.01435 0.00594 -0.00043 -0.01806 0.02094 -0.00101 -0.00465 0.00214 -0.00050 -0.01205 -0.00641 -0.01426 -0.00034 0.00736 -0.00385 0.00629 -0.00917 -0.00993 -0.00478 -0.01549 0.00336 -0.00081 0.00276 -0.00323 0.00572 -0.00472 -0.00100 0.00819 -0.00006 -0.00247 -0.00915 -0.01033 0.00034 -0.00701 -0.01573 0.00384 -0.00500 -0.00494 -0.00467 0.00770 -0.01375 -0.00311 -0.01475 -0.01035 -0.00451 -0.00197 -0.00029 -0.00897 -0.00397 -0.00907 -0.01521 -0.00829 0.00268 -0.01249 0.00594 --0.01475 0.02549 0.00683 -0.01727 -0.04433 0.04858 0.07898 -0.05155 -0.00008 0.03058 -0.00054 0.06944 -0.02020 0.07663 -0.04404 -0.01156 0.04401 0.05756 -0.04269 0.02930 0.01387 0.03146 0.02244 0.03355 -0.01971 0.03941 -0.01471 -0.00074 0.05814 -0.01852 -0.01712 -0.02989 0.02971 -0.02268 0.02363 0.08587 0.16490 0.00932 -0.01607 -0.02992 0.01690 0.01628 0.00796 0.03026 0.02933 -0.02469 0.00596 0.01004 -0.00514 0.05446 --0.12057 -0.03980 -0.00962 -0.12017 -0.03978 -0.06504 0.14291 -0.10326 -0.00559 -0.03251 0.00101 0.09278 -0.12211 0.24027 0.03255 0.00271 -0.00056 -0.02766 -0.06210 -0.03795 -0.01395 0.00677 -0.00842 -0.00337 -0.09521 -0.00490 0.00178 -0.00546 0.12164 -0.03921 -0.01001 -0.01194 -0.01920 -0.09068 -0.01332 0.08427 -0.03843 0.00129 -0.08148 -0.12042 0.01236 -0.06978 -0.00228 -0.06502 -0.08209 -0.12199 -0.00481 -0.02206 -0.03859 -0.03173 --0.00116 0.00755 -0.00434 -0.01121 -0.02529 0.00211 0.00068 -0.01572 0.00122 -0.00836 0.00296 0.00059 -0.00761 -0.00424 -0.00276 0.00667 -0.01283 -0.01429 -0.02517 0.00213 -0.00561 -0.00546 -0.00164 -0.00679 -0.00850 -0.00709 -0.01490 0.00000 0.00118 -0.01387 -0.00845 -0.01332 0.00185 -0.01179 -0.00985 -0.01018 0.00623 -0.01351 0.00324 0.00280 -0.01236 0.00035 0.00415 -0.00733 0.00801 -0.01330 -0.01386 -0.00011 -0.00092 0.00092 -0.00223 -0.00584 0.01139 0.00491 -0.00090 0.00222 0.01430 0.00463 -0.00272 0.00740 0.00844 0.00753 0.00178 0.00979 -0.02396 0.00806 0.00851 -0.00430 -0.01143 -0.00785 -0.00391 -0.00073 0.00647 0.00555 0.01189 -0.03674 -0.00643 0.01272 0.01327 0.00902 0.01076 0.00061 0.02654 -0.00945 -0.00080 0.00447 -0.07919 0.00890 0.00980 0.00698 0.00734 0.02213 -0.00218 -0.01960 -0.00352 -0.00192 0.01283 -0.00373 0.00193 0.00287 --0.05213 -0.00888 0.00709 -0.05254 -0.03502 0.01894 0.14914 -0.04847 -0.00775 0.12947 0.00088 0.06391 -0.04772 0.19144 0.01464 -0.02871 0.03861 0.09765 -0.05353 -0.00636 -0.00019 -0.00069 -0.00448 0.04046 -0.03204 0.07599 -0.01655 -0.00899 0.08720 -0.05180 0.00688 -0.01929 -0.02087 -0.06509 -0.00821 0.15643 0.11210 -0.00269 -0.03982 -0.06615 0.02417 0.07276 -0.00409 0.01247 0.09455 -0.04866 -0.00523 -0.03470 0.00802 0.12097 -0.00297 -0.02803 0.00023 -0.01259 -0.01088 -0.00428 -0.03473 -0.01394 -0.00581 -0.00274 0.00721 0.00113 -0.00197 -0.00991 -0.03325 -0.00564 -0.00290 0.00066 -0.00351 -0.02224 0.00136 -0.00759 -0.01644 0.00055 -0.01301 0.02524 -0.00850 -0.01429 -0.01307 -0.00942 -0.01344 -0.00703 -0.02999 -0.00217 -0.02705 -0.00412 0.04873 -0.01078 -0.01018 -0.00309 0.00186 0.00603 -0.00106 0.00304 -0.00799 -0.00555 -0.00211 -0.01754 -0.00060 0.01766 --0.00624 -0.00299 -0.00292 -0.00505 -0.00257 0.00787 -0.00934 -0.00268 0.00885 -0.00550 0.00684 -0.00097 -0.01251 -0.00272 -0.00418 -0.00104 0.00028 -0.00470 -0.00405 0.00750 -0.00219 0.00279 -0.00810 -0.00857 -0.00904 -0.02238 0.00249 -0.00827 0.00196 -0.00347 -0.00481 -0.00743 -0.00421 -0.00517 -0.00868 -0.00955 0.00094 -0.01422 0.00207 0.00047 -0.00241 0.00929 -0.00715 -0.00477 -0.00076 -0.01133 -0.00017 -0.00318 -0.01030 -0.00103 --0.00439 0.00236 -0.00954 -0.00596 -0.00190 -0.00162 -0.00714 -0.00239 -0.00835 0.00023 0.00342 -0.00332 0.00477 0.00022 -0.00333 -0.00729 -0.01405 -0.01151 -0.00964 -0.00195 -0.00038 0.00039 -0.00705 -0.01027 -0.00726 -0.01315 -0.00534 0.00861 -0.00691 -0.00747 -0.00847 -0.00324 -0.01492 -0.01371 0.00957 -0.00112 0.00517 0.00300 -0.00938 0.00094 0.00185 -0.00141 0.00166 0.00392 0.00127 -0.00445 0.00474 -0.00533 0.00286 0.00691 --0.00026 -0.01152 -0.00207 0.00378 -0.00937 -0.01293 -0.00729 -0.00593 -0.00480 -0.01465 0.00830 -0.00100 -0.00580 -0.01238 -0.00375 -0.00751 -0.01181 -0.01147 -0.00516 -0.01040 -0.00283 -0.01533 0.00195 -0.01091 -0.00356 -0.00262 -0.01483 0.00520 -0.00670 -0.00548 -0.01239 0.00224 -0.00086 0.00225 0.00383 -0.00515 0.00977 -0.00850 -0.00361 -0.01563 0.00343 0.00121 0.00498 0.00033 -0.01549 -0.01422 0.00952 -0.00343 -0.00657 -0.01389 -0.00003 -0.00297 0.00159 0.00937 -0.00574 -0.01126 -0.00271 -0.00814 -0.00887 -0.01435 -0.00404 0.00048 -0.00339 -0.01021 -0.01281 -0.00672 -0.01565 -0.01272 -0.00794 -0.01043 -0.00970 -0.01586 -0.00054 -0.00347 -0.01309 0.00107 -0.01188 0.00851 -0.01025 -0.00396 -0.00417 -0.01642 0.00171 -0.01312 -0.01398 -0.00298 0.00588 -0.01064 0.00338 -0.00815 0.00165 0.00211 -0.00857 -0.00138 -0.01331 -0.01431 -0.00875 -0.01188 -0.00081 0.00180 --0.00703 -0.01013 -0.00645 -0.00591 -0.00629 -0.01148 -0.00022 -0.00776 0.00526 -0.00332 -0.00758 -0.01446 0.00683 -0.00982 -0.01203 0.00865 0.00009 -0.01120 -0.00802 -0.01816 -0.00041 -0.00027 -0.00560 -0.00543 -0.01289 0.00164 -0.00896 0.00243 -0.00005 0.00873 -0.00403 -0.00402 -0.00476 -0.01528 -0.00390 -0.00285 -0.00828 -0.00564 0.00301 -0.01675 -0.00614 -0.00196 -0.00352 -0.01597 -0.01468 -0.00749 -0.00407 -0.00515 -0.01841 -0.00072 --0.01364 0.06889 -0.00225 -0.01626 -0.05082 0.04994 0.24898 -0.02320 0.00713 0.01999 0.00414 0.05554 -0.01038 0.05700 -0.09355 -0.00688 0.05859 0.01182 -0.03543 0.05372 -0.01152 0.00624 0.05494 0.01972 -0.00999 0.07741 -0.01401 -0.00298 0.01164 0.00030 -0.00520 -0.03029 0.04247 -0.02665 0.06875 0.07760 0.18861 -0.00185 -0.00924 -0.01237 0.00707 0.06044 0.00338 0.07267 0.07136 -0.00247 0.00104 0.07316 -0.01649 0.11609 -0.00617 0.00316 -0.00659 -0.00378 -0.03089 0.01953 0.00775 -0.06364 0.00662 0.01219 -0.00207 0.03598 0.00035 0.02169 -0.04623 -0.00195 0.04386 0.02310 -0.02754 0.01584 -0.00337 0.02031 -0.00074 0.02679 -0.00589 0.04299 -0.01675 0.00014 0.02014 0.00320 0.00432 -0.01819 0.00467 0.00739 0.02254 0.05523 0.19430 -0.01044 -0.00093 0.00205 0.02067 0.00831 -0.00071 0.02187 0.00675 0.00154 -0.00214 0.02462 -0.01244 0.02221 --0.00668 -0.00571 0.00005 0.00693 -0.01335 0.00118 0.00271 -0.00379 0.00198 -0.01361 0.00108 -0.00557 0.00928 -0.00700 -0.00695 0.00795 -0.00791 -0.00611 -0.00487 -0.00590 -0.00416 -0.00870 -0.00280 -0.00034 -0.00432 0.00296 0.00316 -0.00740 -0.00277 0.00322 0.00390 -0.00673 -0.00709 -0.00982 -0.01500 0.00335 -0.00754 -0.00633 -0.00224 -0.00510 -0.00568 -0.00161 -0.00193 -0.00225 0.00091 -0.01505 0.00985 0.00176 -0.00719 -0.01218 -0.00252 -0.00413 -0.00606 0.00042 -0.00064 -0.00532 -0.01675 -0.00030 0.00149 -0.01263 0.00567 -0.00826 0.00260 -0.00639 -0.00235 -0.00048 0.00276 -0.00409 -0.01152 -0.01190 -0.01278 -0.00779 -0.00199 0.00006 -0.01316 -0.00858 -0.00060 -0.00327 0.00239 -0.00421 -0.01114 -0.01120 -0.01186 -0.00134 -0.01287 -0.00757 0.00338 -0.01033 -0.01070 0.00114 -0.00683 -0.01854 -0.01437 -0.01405 -0.00324 0.00357 -0.01204 -0.01122 -0.00450 -0.00344 -0.00049 0.03377 0.00364 -0.00025 -0.03875 -0.01180 -0.01140 0.12982 -0.00488 0.00129 0.00495 -0.00143 -0.01722 -0.01897 -0.00462 0.02805 -0.01100 -0.01757 -0.04157 -0.01512 0.00169 0.06377 0.19513 -0.02034 -0.01262 -0.09805 0.00211 0.01233 0.00761 -0.01145 0.01571 -0.02624 0.07535 0.07486 -0.00175 -0.02508 -0.00537 0.00839 -0.00174 -0.01259 0.00596 -0.00489 0.00844 -0.06969 -0.00278 -0.01985 0.00418 -0.01205 -0.00458 0.01123 --0.02204 0.05872 -0.01146 -0.01081 -0.03659 0.03688 0.16112 -0.04187 0.00755 0.07869 0.00769 0.04510 -0.01644 0.12164 -0.04881 -0.00377 0.05407 0.06481 -0.03907 0.05418 0.00292 0.03000 0.05325 0.02338 -0.02500 0.05589 -0.01882 0.00168 0.06200 -0.02425 -0.00900 -0.01817 0.04684 -0.04883 0.05628 0.08283 0.18026 -0.00574 -0.01810 -0.01568 0.03426 0.04798 -0.00250 0.05347 0.06324 -0.02289 -0.00175 0.04903 -0.02805 0.08618 --0.00074 0.00136 0.00340 0.00134 -0.00644 -0.02187 0.01623 -0.00664 -0.00895 0.01105 -0.00775 -0.02041 -0.00190 0.00977 -0.03601 -0.00493 -0.00506 0.01195 0.00115 -0.01009 -0.00800 0.00599 -0.01388 -0.00757 0.01078 -0.01214 0.00672 0.01057 0.01492 0.01565 0.00394 -0.00882 -0.01179 -0.00150 -0.00495 -0.00052 0.00417 0.00747 0.00441 0.00843 0.00367 0.01569 -0.00555 -0.00362 0.00740 0.00416 0.00454 -0.01203 -0.00085 0.01705 --0.09281 -0.04503 -0.00656 -0.11105 -0.02310 -0.02951 0.12563 -0.07210 0.00050 -0.03572 -0.00964 0.06316 -0.09690 0.10700 0.03982 -0.00698 0.00636 -0.00716 -0.04000 -0.03874 0.00148 -0.03263 -0.02297 0.05443 -0.07819 0.00933 -0.00815 -0.00216 -0.00085 -0.03955 -0.00372 -0.00874 -0.03844 -0.05241 -0.01680 0.06838 -0.02731 -0.00253 -0.08115 -0.09451 -0.01225 -0.03479 -0.00911 -0.04588 0.01403 -0.10275 -0.00269 -0.03302 -0.02182 -0.01048 --0.03209 -0.00308 -0.00290 -0.03510 -0.02903 -0.00229 0.00223 -0.00027 -0.00727 -0.00147 0.00140 -0.00150 -0.02321 -0.01582 -0.02566 0.00581 -0.00831 -0.00865 -0.03212 -0.00073 -0.01262 -0.00993 -0.01501 -0.01275 -0.04269 0.00057 0.00261 0.00205 -0.01557 -0.02170 -0.00750 -0.01541 -0.00110 -0.00295 -0.01255 -0.00097 -0.02015 -0.00875 -0.03580 -0.04117 -0.00422 -0.01337 -0.00843 0.00035 -0.00846 -0.03006 -0.00276 0.00021 0.00198 -0.01097 --0.17875 -0.04909 0.00382 -0.17591 -0.08908 -0.05648 0.08963 -0.09079 0.00478 -0.04018 -0.00641 0.07845 -0.19255 0.23707 0.06107 0.00078 -0.01314 0.01973 -0.09338 -0.03630 -0.00822 -0.00615 -0.03991 -0.00649 -0.17242 -0.00637 -0.00508 0.00757 0.13780 -0.07419 0.00365 -0.01771 -0.04459 -0.08801 -0.04206 0.12016 -0.00842 -0.00980 -0.17537 -0.20171 0.00493 -0.03547 -0.00512 -0.07090 -0.04255 -0.18349 -0.00589 -0.04189 -0.05555 -0.01801 -0.00094 0.06669 -0.00405 0.00556 -0.06007 0.06856 0.29192 -0.02759 -0.00589 0.09619 -0.00566 0.07509 -0.01535 0.13215 -0.08917 0.00046 0.09429 0.05521 -0.05190 0.05959 -0.01486 0.03751 0.06475 0.05775 -0.01192 0.06666 -0.02407 -0.00807 0.06532 -0.00728 -0.01136 -0.05242 0.05524 -0.04816 0.07602 0.11195 0.18117 -0.00392 -0.00623 -0.00489 0.05053 0.05923 -0.00141 0.06169 0.06839 -0.00050 -0.00586 0.06641 -0.01208 0.11288 --0.01474 0.05807 -0.00799 -0.00354 -0.00352 0.04677 0.22731 -0.01479 -0.00222 0.01780 -0.00224 0.06808 -0.01306 0.04093 -0.09202 -0.00054 0.05398 0.00755 -0.01500 0.06061 -0.00955 0.00577 0.03789 -0.01072 -0.00992 0.04862 -0.00861 -0.00663 0.02639 -0.01470 0.00069 -0.00057 0.03560 -0.02856 0.06584 0.06361 0.17942 -0.01290 -0.00223 -0.00613 0.00365 0.03144 -0.00204 0.03888 0.07118 -0.00189 0.00371 0.05739 0.00279 0.10598 -0.00401 -0.00547 0.01164 0.01322 -0.00993 0.00155 0.00828 -0.00254 0.00848 0.01617 -0.00353 0.00726 -0.00037 0.00644 -0.01848 0.00786 0.00369 0.00427 -0.00100 -0.00842 -0.00063 -0.00039 0.00329 0.00550 0.01051 -0.00225 -0.00768 0.01125 0.01927 -0.00366 0.00600 0.00910 0.01999 0.00152 0.01168 0.00322 -0.01694 0.00772 0.00650 -0.00536 0.00889 0.00730 -0.00367 -0.02621 -0.00144 0.00029 -0.00220 -0.00728 0.00689 0.00920 --0.00609 -0.01425 0.00420 -0.00829 -0.02402 -0.00134 0.00470 -0.03025 0.00506 -0.01237 -0.00343 0.00235 -0.00388 0.00374 -0.01516 0.00827 0.00072 -0.01056 -0.02737 -0.01412 -0.00408 0.00021 -0.00271 -0.00532 -0.00472 -0.01526 -0.00641 -0.00271 -0.01173 0.00539 -0.00489 -0.01927 -0.01470 -0.02679 -0.00896 -0.01332 -0.00275 -0.00625 0.00555 -0.00475 0.00447 -0.00304 0.00522 -0.01187 -0.00410 0.00028 -0.00178 -0.00227 -0.00246 0.00406 --0.01759 0.04828 -0.00735 -0.00884 -0.02531 0.04006 0.21324 -0.02806 0.00109 0.00273 -0.00624 0.05634 -0.01508 0.02978 -0.07023 -0.01232 0.02619 -0.00361 -0.02924 0.04910 -0.00140 0.00107 0.04672 0.01995 -0.02438 0.05460 0.00183 -0.00197 0.00624 -0.01067 0.00042 -0.02827 0.03286 -0.02173 0.05739 0.04730 0.15925 0.00259 -0.02222 -0.01629 -0.00858 0.06074 -0.00498 0.05439 0.07032 -0.00820 -0.01099 0.04682 -0.02767 0.10580 --0.00584 0.04447 0.00658 -0.00683 -0.06208 0.05671 0.20247 -0.02212 -0.00692 0.07640 -0.00127 0.07886 -0.01727 0.19810 -0.07017 -0.00591 0.06360 0.07456 -0.05700 0.06489 0.00779 0.03944 0.04685 0.03561 -0.00788 0.08860 -0.00738 -0.00372 0.08279 -0.00893 -0.01308 -0.05193 0.05526 -0.05219 0.07256 0.09563 0.17640 0.00073 -0.01368 -0.00972 0.05255 0.04303 0.01601 0.04315 0.04499 -0.00204 0.00018 0.05784 -0.00968 0.10052 --0.00728 -0.00836 -0.00349 0.00260 -0.02905 -0.00713 -0.01230 -0.00949 -0.00248 -0.01133 -0.00277 -0.00040 -0.00525 -0.01258 -0.00788 -0.00171 -0.01108 -0.00405 -0.02839 0.00224 -0.00282 -0.00587 0.00017 -0.03725 -0.00142 -0.01535 0.00240 -0.00543 -0.00150 -0.00637 -0.00239 -0.03607 -0.00528 -0.03054 0.00194 -0.00558 -0.00250 -0.00858 -0.00844 -0.00645 -0.01441 -0.00221 -0.00133 -0.00485 -0.00352 -0.01512 0.00325 -0.00802 -0.00296 -0.01383 --0.00619 -0.00545 -0.00274 0.00713 -0.01995 0.00183 0.00986 -0.01400 0.00191 -0.00923 0.00684 -0.01348 -0.00069 -0.00208 -0.00650 0.00998 -0.00315 -0.00043 -0.02522 -0.00001 0.00912 -0.00405 -0.00689 -0.00354 -0.00156 0.00005 -0.02714 0.00002 -0.00999 -0.00046 0.00388 -0.00890 -0.01334 -0.02272 -0.00239 -0.01096 -0.00033 -0.00246 -0.00817 -0.00719 -0.00397 -0.00355 0.00780 -0.01451 -0.00538 0.00745 -0.00238 0.00316 -0.00879 -0.00194 -0.01194 0.00450 0.00563 0.00655 -0.00413 -0.02631 0.00729 0.00495 -0.00702 0.00540 0.00434 0.01236 0.00297 0.01321 -0.01749 -0.00864 0.01792 0.00500 0.00469 0.00457 0.00950 -0.00356 0.00157 0.00077 0.00251 -0.01378 0.00820 -0.00013 0.00064 0.01134 0.00345 -0.00429 -0.01608 -0.00348 0.00710 0.01193 0.00771 0.00352 0.00928 0.00011 0.00828 -0.00216 0.01387 -0.01288 0.00127 -0.00997 -0.00250 -0.00220 -0.00799 0.00238 --0.01433 0.03434 -0.01082 -0.02362 -0.02531 0.01277 0.21960 -0.02197 0.00312 0.00068 0.00700 0.05787 -0.01192 0.03135 -0.06749 -0.01838 0.03001 0.00240 -0.02775 0.03327 -0.00160 -0.01165 0.03223 0.03720 -0.02711 0.04598 -0.00541 -0.01309 -0.00294 -0.01901 -0.01482 -0.03040 0.00401 -0.02227 0.03868 0.05277 0.16072 -0.00256 -0.01999 -0.00645 -0.00316 0.04635 0.00119 0.04025 0.05518 -0.00732 -0.00780 0.04869 -0.02776 0.10858 -0.00988 -0.00109 -0.00233 0.00300 -0.01086 -0.02231 0.00686 -0.01374 -0.00470 0.00643 -0.00595 -0.01266 0.00368 0.00810 -0.02915 -0.00669 0.00075 0.01208 -0.01783 0.00100 -0.00341 0.01372 -0.01050 0.01686 0.00602 0.00385 0.00274 0.00538 0.01225 0.01468 0.00306 0.00218 -0.02959 0.00359 -0.01206 -0.00268 0.00641 0.00358 0.01149 -0.00228 0.01397 -0.00359 0.00206 0.00960 -0.01116 0.00750 0.00881 -0.01220 0.00248 0.00806 --0.01273 0.00447 0.00789 -0.01039 -0.02916 0.03071 0.07828 -0.07810 -0.00735 0.02468 -0.00434 0.06686 -0.02708 0.12792 -0.09601 -0.00400 0.03386 0.05109 -0.03218 0.02299 -0.00338 0.03240 -0.01021 0.01606 -0.00968 0.03108 -0.01135 -0.00187 0.07710 -0.01840 -0.01106 -0.02306 0.00272 -0.03836 0.01661 0.11424 0.17257 -0.00835 -0.01774 -0.01949 0.02700 -0.01613 -0.01116 0.01270 0.03205 -0.01983 -0.00986 0.00897 -0.02295 0.04350 -0.00299 -0.00259 0.00762 0.01319 -0.01157 0.00490 0.00190 0.00313 -0.00348 0.00879 0.00941 0.00878 -0.00457 0.01581 -0.01646 -0.00264 -0.00138 -0.00319 -0.01994 0.00175 0.01198 0.00247 0.00992 -0.00606 0.01158 -0.01250 0.00997 0.00817 0.00201 0.00973 0.01179 0.00539 0.01086 -0.00469 -0.00426 -0.00252 -0.04955 0.01075 -0.00491 0.00553 0.00022 0.01695 0.01490 -0.00953 -0.00167 -0.00027 -0.00195 -0.00970 0.00074 0.00905 --0.00688 0.02096 -0.01285 0.00392 -0.02128 0.04259 0.03345 -0.03190 0.00335 0.01792 0.00659 0.04894 -0.00661 0.02598 -0.04778 -0.00916 0.03568 0.03441 -0.03214 0.02473 0.00552 0.03030 0.02342 0.01587 -0.00565 0.05104 -0.00630 0.00227 0.02988 -0.00118 -0.00495 -0.01606 0.02261 -0.00786 0.02220 0.06336 0.15256 0.00492 -0.00998 -0.01069 0.01103 0.01241 -0.00510 0.03448 0.01371 -0.01568 -0.00828 0.01911 -0.00696 0.02894 --0.01347 0.06127 0.00254 -0.01748 -0.03571 0.06166 0.22812 -0.01738 0.00032 0.04160 0.00810 0.04244 -0.01797 0.10042 -0.08218 -0.01236 0.06989 0.02007 -0.02761 0.05682 0.00356 0.01621 0.04578 0.02582 -0.02064 0.07027 -0.00553 0.00316 0.01496 -0.02669 0.00003 -0.02780 0.05097 -0.03747 0.07363 0.06637 0.17182 -0.01371 -0.01826 -0.02457 0.02301 0.05362 -0.01112 0.07051 0.05973 -0.02102 -0.00401 0.04632 -0.01261 0.10432 -0.00316 -0.00659 -0.00427 -0.00837 -0.01357 -0.01615 -0.01333 -0.00699 0.00982 0.00264 -0.00051 -0.00908 -0.01053 0.00334 -0.00537 0.00158 -0.01592 -0.00122 -0.01090 -0.01273 -0.00427 0.00061 0.00294 -0.00516 -0.01464 -0.00341 -0.00529 0.00261 -0.00644 -0.01563 -0.01464 -0.00826 -0.00412 -0.01602 -0.01273 -0.00978 0.00726 0.00130 0.00343 0.00316 -0.00001 -0.00927 -0.00897 -0.00313 -0.01342 -0.00233 -0.01421 -0.00294 0.00185 0.00037 --0.00639 0.00367 0.00156 0.00421 -0.00890 0.00170 -0.00285 0.00704 0.00310 0.00420 -0.00104 -0.00768 -0.01166 -0.00370 -0.00462 0.00161 -0.01444 -0.00908 -0.01484 0.00148 -0.00802 -0.01146 -0.01492 -0.01208 -0.01045 -0.00242 0.01394 -0.00632 0.00441 -0.00919 0.00372 0.00204 -0.01290 -0.01322 -0.00024 -0.00328 -0.00163 0.00203 -0.01275 -0.00488 -0.00665 -0.00402 0.00856 -0.00966 0.00203 -0.00140 -0.00207 -0.00898 -0.00712 0.00154 --0.00818 0.05399 -0.00358 -0.00813 -0.05148 0.04195 0.22668 -0.01791 0.00848 0.02153 0.00874 0.07182 -0.00452 0.04916 -0.08529 -0.00825 0.03262 0.01242 -0.05010 0.05378 0.00237 0.00269 0.04728 0.02635 -0.00337 0.06049 -0.00072 -0.00688 0.00452 -0.00466 -0.00659 -0.04425 0.02745 -0.02314 0.05392 0.06746 0.17048 -0.01099 -0.00608 -0.00045 -0.00045 0.05720 -0.00981 0.06619 0.06347 -0.00357 -0.00179 0.04593 -0.00482 0.10954 --0.00434 0.05864 -0.00071 0.00891 0.00754 0.00198 0.01300 0.07746 0.00934 0.00410 -0.00216 -0.01451 0.01408 0.00312 0.01872 0.01826 0.00870 0.00493 0.00532 0.00082 0.01502 0.04653 0.13503 0.03005 0.00813 -0.00489 0.00744 0.00754 0.00887 0.00193 0.00553 0.00501 0.07567 0.04530 0.03050 -0.01872 -0.05657 -0.00126 0.00943 0.00180 0.00500 0.02252 0.00947 -0.00403 0.01076 0.00212 0.00244 0.01008 -0.00323 0.00878 -0.01048 0.00414 0.01137 0.00631 0.00030 -0.01638 0.01856 -0.01020 -0.00754 0.01972 0.00909 -0.01838 0.01033 0.01179 -0.01622 -0.00347 0.00125 0.00638 -0.01290 -0.02113 0.01236 0.01368 0.01131 -0.00165 0.01020 0.02694 0.01383 0.00655 0.01746 0.00013 0.01211 0.01267 0.01688 -0.00024 -0.01892 0.00183 -0.00534 0.01069 -0.00009 0.00525 0.00636 0.01881 0.00968 -0.00821 0.00865 -0.00633 0.00541 -0.01174 0.00943 0.00308 --0.00909 0.00142 0.00116 0.00192 -0.00865 -0.00914 -0.00407 -0.00344 -0.00919 0.00015 0.00666 0.00214 -0.00118 0.00058 -0.00386 -0.00460 -0.01132 -0.01527 -0.00719 -0.01497 -0.00675 -0.00674 -0.00437 -0.01262 -0.01122 0.00247 -0.00526 0.00125 -0.01521 -0.00682 -0.00942 -0.00282 0.00077 -0.01505 -0.00530 -0.00797 -0.00786 0.00284 -0.00396 -0.00069 -0.01597 -0.00795 0.00905 -0.00027 -0.00621 -0.00331 -0.00798 -0.01260 0.00847 -0.00239 --0.01194 0.00007 -0.00984 -0.00826 -0.00754 -0.01352 -0.01794 -0.00466 -0.00713 0.00331 0.00870 -0.01368 -0.00513 -0.00289 -0.00618 0.00039 -0.00122 -0.01040 -0.00972 -0.00329 -0.00501 0.00238 -0.00458 -0.01594 -0.01279 -0.01097 -0.01357 -0.00676 -0.00953 0.00252 -0.00791 -0.00792 -0.00749 0.00182 -0.00916 0.00200 0.00122 -0.00691 -0.01002 -0.00105 -0.01627 -0.01321 -0.00896 -0.00164 -0.00322 0.00014 0.00090 0.00245 0.00050 0.00648 --0.05104 -0.10290 -0.00468 -0.06364 -0.03153 -0.02673 0.08069 -0.08724 -0.00856 -0.00993 -0.00896 0.00343 -0.06092 0.26969 0.02932 -0.00999 0.02970 0.08775 -0.05014 0.00143 0.00224 -0.05885 -0.10461 0.00087 -0.05311 0.13274 -0.02961 -0.00752 0.15888 -0.04495 -0.00796 -0.00136 -0.10237 -0.07552 -0.05178 0.15221 -0.15473 -0.00876 -0.05104 -0.07921 0.07284 -0.02919 0.00319 0.01626 0.01772 -0.06520 -0.00435 -0.05121 -0.00875 -0.06513 --0.00828 -0.01940 0.00727 0.00263 -0.00936 -0.01792 0.00267 -0.01583 0.00053 0.00090 -0.00321 -0.00179 -0.00282 -0.00042 -0.00453 0.00173 -0.00269 -0.00170 -0.00286 -0.02221 0.01405 0.00047 -0.02603 -0.02104 0.00572 -0.00811 -0.01577 -0.00182 -0.00694 -0.01008 0.00643 -0.01175 -0.02329 -0.00003 0.00806 0.00714 -0.01678 0.01203 0.00151 0.00556 0.00326 -0.00660 0.00123 -0.01694 -0.00692 -0.00658 -0.00012 -0.02656 -0.00215 -0.01265 --0.01695 -0.09142 -0.00949 -0.01671 -0.05796 -0.08764 -0.05712 0.02800 0.00273 -0.05033 -0.00371 -0.00601 -0.01533 0.00777 -0.02520 -0.00721 -0.04775 -0.03274 -0.05420 -0.04586 -0.00029 -0.01993 -0.10674 0.02719 -0.02396 -0.00441 -0.01017 0.00390 -0.03053 -0.00636 0.00859 -0.04386 -0.09717 -0.00483 -0.05034 -0.02273 -0.02179 -0.00087 -0.00943 -0.02113 -0.02430 -0.07432 0.00785 -0.03630 -0.00396 -0.01902 0.00615 -0.05680 -0.00951 -0.04706 --0.00859 0.06462 -0.00289 -0.00707 -0.04325 0.06384 0.24489 -0.02815 -0.00192 0.02990 -0.00379 0.08194 -0.01071 0.08720 -0.08299 -0.01139 0.06253 0.02714 -0.02159 0.05981 -0.00147 0.02052 0.04974 0.06144 -0.01250 0.06396 -0.00208 -0.00090 0.01867 0.00350 0.00248 -0.04693 0.04113 -0.02702 0.06729 0.07583 0.19449 -0.00749 0.00514 -0.00543 0.00204 0.06661 -0.00637 0.07305 0.05142 -0.00984 -0.01473 0.06634 -0.00291 0.10752 --0.00321 0.00233 0.00838 0.00111 -0.01323 -0.01413 0.01853 -0.03128 0.00909 0.01627 0.00480 0.01866 -0.00252 0.01085 -0.03065 0.00334 -0.00253 0.01088 -0.01577 -0.01674 0.00091 0.00761 0.00247 0.01655 0.01493 -0.02802 -0.01343 0.01469 0.01647 0.00634 0.01013 -0.00407 -0.02459 -0.00998 -0.00810 -0.00152 -0.02575 0.01238 0.00806 0.00741 0.01258 0.00946 0.00844 -0.01001 0.00404 0.00291 0.01085 -0.01497 0.00625 -0.00352 --0.01391 -0.01087 -0.00613 -0.00102 0.00105 0.00080 -0.01809 -0.01445 -0.00634 -0.00006 -0.00775 -0.01075 0.00106 -0.01359 -0.01503 0.00529 -0.00810 -0.00417 -0.00633 -0.01153 -0.00071 -0.00515 -0.00805 0.00011 0.00261 0.00230 -0.01017 -0.01138 -0.00513 -0.01308 -0.00154 -0.00676 -0.00565 -0.00164 -0.01112 -0.01481 -0.00407 0.00160 -0.01320 0.00299 -0.01491 -0.01229 -0.00617 -0.00211 0.00384 -0.00604 0.00160 -0.00314 -0.01287 0.00199 --0.00990 0.00167 -0.00391 0.00338 0.00265 -0.00352 -0.00020 -0.00196 -0.00921 -0.00838 -0.00680 -0.01411 -0.01472 -0.01405 -0.00812 0.00311 0.00094 -0.00538 -0.00494 -0.01244 0.00362 -0.01617 0.00140 -0.00533 0.00281 -0.00895 -0.00232 -0.00476 -0.01112 -0.01531 0.00215 -0.01565 -0.00026 -0.00608 -0.01264 -0.00607 0.00208 -0.00139 -0.00126 -0.01069 -0.01154 -0.00854 0.00377 0.00199 -0.01558 -0.00329 -0.00612 -0.00014 0.00283 0.01066 --0.00696 0.04548 -0.00739 -0.00380 -0.05085 0.04679 0.16520 -0.03997 -0.00027 0.06814 -0.00535 0.07426 -0.00937 0.17298 -0.06840 -0.00325 0.06552 0.05078 -0.04739 0.06119 0.00119 0.05019 0.04363 0.05274 -0.01173 0.06051 -0.01795 -0.00528 0.06614 -0.00172 0.00032 -0.05109 0.04028 -0.03394 0.06277 0.10126 0.18461 0.00381 -0.00898 -0.01750 0.02678 0.03962 0.00342 0.05368 0.04041 -0.00184 -0.01128 0.04974 -0.02275 0.09503 -0.01105 0.06777 -0.00284 0.00819 -0.03392 0.01167 0.01522 0.10231 0.00760 -0.00724 0.00568 -0.00977 0.00768 0.00692 0.03553 0.02843 0.02064 -0.01585 -0.01351 -0.00476 0.01353 0.05512 0.16207 -0.00116 0.01064 -0.06043 0.01147 0.01511 0.00293 0.00075 0.00304 -0.02669 0.09625 0.05591 0.02867 -0.01612 -0.06674 0.00196 0.00384 0.01283 0.01957 0.01570 0.00791 -0.02211 0.02060 0.01969 -0.00220 0.00138 0.00258 0.00974 -0.00801 -0.00060 0.00834 -0.00973 -0.01871 -0.00580 -0.00199 -0.00536 0.00090 -0.00460 0.00284 0.00860 -0.00053 0.00084 -0.01178 0.00359 0.00179 -0.00600 -0.01677 -0.00324 0.00516 0.00103 -0.00878 -0.00432 -0.02107 0.00509 -0.00066 -0.00327 -0.00998 -0.00322 0.00379 -0.00617 -0.00238 -0.02188 0.00425 0.00414 0.00214 -0.00623 0.00853 0.00473 -0.00840 0.00744 0.00233 -0.00850 0.00199 -0.00852 -0.00294 0.00723 -0.01629 -0.00244 --0.00871 0.00649 0.01280 0.00462 -0.00382 -0.03393 0.00435 -0.00400 -0.00031 0.00182 0.00148 0.00393 -0.00779 0.00299 -0.02452 -0.00219 0.01126 -0.00289 -0.00869 -0.00600 -0.00296 -0.00152 -0.00990 -0.01458 -0.00823 -0.00999 -0.00719 0.00446 0.01170 0.00621 0.00702 0.00247 -0.02482 -0.00102 -0.00650 -0.00675 -0.00457 0.01043 0.00189 0.00709 0.00530 0.00198 0.01031 0.00054 -0.00400 -0.00691 0.00813 0.00325 0.00718 -0.00025 --0.01665 0.03985 -0.00269 -0.01046 -0.02821 0.01494 0.20920 -0.01752 0.00751 0.00044 0.00423 0.04443 -0.01266 0.02665 -0.07712 -0.01274 0.02731 -0.00922 -0.02969 0.04815 -0.00459 -0.00471 0.04031 0.02561 -0.02773 0.06005 -0.01275 -0.00052 0.01017 -0.02748 -0.01457 -0.02176 0.02077 -0.02580 0.05112 0.05673 0.17736 -0.00927 -0.02007 -0.00976 -0.00032 0.05879 -0.00490 0.05993 0.06970 -0.01849 -0.00272 0.05504 -0.02121 0.10179 --0.00186 0.02343 0.00781 -0.00761 -0.02489 0.00229 0.01142 0.08119 0.00839 -0.00205 -0.00496 0.00509 -0.01233 -0.00502 -0.00913 0.03654 -0.01660 0.00290 -0.02370 -0.00436 0.01168 0.02139 0.16296 -0.00432 -0.00130 -0.05814 -0.00162 0.00447 -0.00110 -0.00312 -0.00208 -0.01962 0.04774 0.03446 0.00831 0.00125 -0.00311 0.00015 -0.02107 -0.01826 0.01703 -0.01041 0.01232 -0.06233 0.00112 -0.01742 0.01290 -0.00398 -0.00193 0.01053 -0.00497 -0.00076 0.00119 0.00316 -0.00250 0.00435 -0.00908 -0.00258 0.00205 -0.01236 -0.00149 -0.00800 0.00077 0.00066 -0.00493 -0.00517 -0.01389 -0.01020 -0.01106 0.00135 -0.00073 -0.01121 0.00090 -0.00215 -0.00103 -0.00105 0.00325 -0.00671 -0.00200 0.00713 -0.00203 -0.00562 -0.00879 -0.01217 -0.01272 -0.00964 0.00348 -0.00952 0.00001 -0.00860 -0.00519 -0.00395 0.00202 0.00079 0.00031 -0.00697 0.00775 0.00308 -0.01167 -0.00421 --0.01157 0.03774 0.00782 -0.01696 -0.06543 0.04192 0.15242 -0.01999 -0.00987 0.05804 0.00382 0.06478 -0.01438 0.15287 -0.06074 -0.00394 0.05006 0.05660 -0.04751 0.05315 -0.00372 0.02761 0.03110 0.03757 -0.00341 0.05691 -0.00446 -0.00493 0.06328 0.00064 -0.01093 -0.06015 0.03755 -0.04300 0.04240 0.08548 0.16516 0.00178 -0.00419 -0.01261 0.03673 0.03657 -0.00844 0.05250 0.05701 -0.02158 -0.00991 0.04028 -0.01355 0.07320 --0.01206 -0.01475 -0.00725 -0.00050 0.00253 0.00002 -0.01143 -0.00059 -0.00144 -0.00015 -0.00070 -0.01072 0.00110 -0.00507 -0.00585 -0.00203 -0.00683 -0.00870 -0.00535 -0.01201 -0.00032 0.00084 0.00373 -0.01095 -0.01310 -0.00508 -0.00898 -0.00633 -0.00230 0.00276 -0.01224 -0.00780 -0.00458 -0.00857 0.00275 0.00131 -0.02916 -0.00177 -0.00100 -0.00750 -0.00617 -0.00225 -0.00880 0.00104 -0.01250 -0.01468 -0.00333 -0.01488 -0.00164 -0.00415 --0.00222 -0.01062 0.00067 0.00119 -0.01785 -0.00653 0.00035 -0.00213 0.00416 -0.00195 0.00093 -0.01328 -0.00335 -0.01098 -0.00195 0.00627 0.00125 -0.00252 -0.02495 -0.01062 -0.01479 -0.00462 0.00340 -0.02810 -0.00649 -0.00476 -0.00165 -0.00387 -0.01196 0.00185 -0.00202 -0.01950 0.00675 -0.01560 -0.00089 -0.00660 -0.00614 -0.00313 -0.00523 -0.00831 0.00117 -0.00838 -0.00450 0.00345 -0.00555 -0.00256 -0.00488 -0.01113 -0.01255 0.00695 --0.00258 -0.00178 0.00737 -0.00194 -0.00640 -0.00764 -0.01582 -0.01116 0.00500 -0.01530 0.00623 -0.00394 -0.00906 0.00290 -0.01452 -0.00392 0.00018 -0.00080 -0.00078 -0.01488 -0.00048 -0.00710 -0.00867 0.00202 -0.00744 0.00191 -0.00257 -0.00778 -0.01246 0.00782 -0.00388 -0.00871 -0.00804 -0.00995 0.00053 0.00133 0.00425 -0.00565 -0.00925 0.00060 -0.00783 -0.00140 -0.00057 -0.00017 -0.01036 -0.01223 -0.00597 -0.01338 -0.01344 -0.00190 -0.00051 0.00832 -0.00380 -0.00323 -0.01443 -0.02684 0.01534 -0.00183 0.00174 0.01715 0.00983 0.02340 -0.00224 0.01115 -0.02668 -0.01703 0.01288 0.00728 -0.00484 -0.00665 -0.00073 0.01258 -0.00515 0.00131 -0.00209 -0.05345 -0.00616 -0.00017 0.01804 -0.00142 0.00890 0.00287 -0.02248 0.00869 -0.00614 0.00578 -0.02050 0.00460 0.01427 0.01245 0.00751 0.00577 0.01015 -0.01130 0.00454 0.00571 -0.00329 -0.00559 0.00802 0.00982 --0.01223 0.05573 -0.01039 -0.00736 -0.05080 0.02922 0.23706 -0.03953 -0.00666 0.03780 0.00068 0.08833 -0.01266 0.10709 -0.07409 -0.01884 0.07631 0.00754 -0.04025 0.05065 -0.00892 0.01404 0.04231 0.05294 -0.00380 0.09380 -0.01271 -0.00707 0.01789 -0.00131 -0.00952 -0.05466 0.02472 -0.03337 0.07279 0.08755 0.19429 -0.01476 -0.00485 -0.00024 0.00575 0.06867 0.00098 0.05440 0.07261 -0.00978 -0.01299 0.04717 -0.02512 0.11875 --0.00443 0.04151 -0.00749 0.00524 -0.02917 0.04819 0.15512 -0.03505 -0.00556 0.07558 -0.00271 0.06978 -0.01072 0.16938 -0.05191 -0.00332 0.04903 0.06698 -0.01750 0.04613 0.01220 0.03887 0.04100 0.05375 -0.00325 0.07325 -0.00819 0.00200 0.05679 -0.01329 -0.01110 -0.03541 0.03138 -0.04191 0.05311 0.08430 0.18256 -0.01103 -0.01107 -0.01580 0.03501 0.04530 -0.00352 0.04897 0.05932 -0.01522 -0.00174 0.04127 -0.01253 0.08919 -0.00876 -0.00414 0.00995 -0.00206 0.00027 0.00891 -0.00089 -0.01306 0.00382 -0.00279 0.00415 -0.00544 -0.00244 -0.00774 -0.00428 -0.00554 0.00256 -0.00418 -0.01370 -0.00762 0.00324 -0.01332 -0.00434 -0.01511 -0.00379 -0.01062 -0.00809 0.00345 -0.00174 -0.00808 0.00857 0.00380 -0.00974 -0.01206 0.00358 -0.00524 -0.00481 0.00239 -0.00753 0.00121 -0.00606 -0.00362 0.00707 -0.01323 -0.00662 -0.00881 0.00101 0.00685 0.00328 0.00808 -0.01399 -0.00240 0.00520 0.00003 -0.01181 -0.03335 0.00705 -0.01816 0.00079 0.01944 0.00522 -0.02541 0.00890 0.01501 -0.02905 -0.00964 0.00037 0.01376 -0.00202 -0.01195 0.00918 0.01137 -0.01557 -0.00745 0.00094 -0.02413 -0.01089 0.00182 0.00537 0.00938 0.01414 0.00837 -0.02284 0.00912 -0.01375 0.00867 0.00312 -0.00021 -0.00337 0.00195 0.01669 0.00343 0.00719 -0.02109 -0.00153 0.00747 0.01492 0.00283 -0.00831 0.00277 --0.05940 -0.05944 0.00422 -0.06888 -0.03608 0.02463 0.03841 -0.10964 -0.00319 -0.02498 -0.00196 0.10204 -0.06043 0.19667 0.10858 -0.02798 0.02153 0.10726 -0.03698 0.01422 -0.00168 -0.02305 -0.07185 0.05346 -0.06835 0.02446 -0.00380 0.00885 0.09869 -0.04566 0.00248 -0.02818 -0.08158 -0.14346 -0.02345 0.07681 0.01655 -0.00010 -0.05812 -0.04652 0.03972 0.01528 -0.00627 0.03341 0.01037 -0.05565 0.00028 -0.00104 -0.01765 -0.01264 --0.00441 -0.00567 0.01438 0.00328 0.00019 -0.00514 0.01631 -0.01020 -0.00546 0.00692 0.00353 -0.01779 -0.00247 0.01270 -0.02812 -0.00230 -0.00853 0.00867 0.00119 0.00186 0.00334 -0.00288 -0.00351 -0.01210 0.00720 -0.02028 0.00674 -0.00167 0.01019 0.00348 0.00442 -0.01032 -0.01151 0.00811 -0.00302 0.00189 0.00162 -0.00326 0.00550 -0.00342 0.00616 0.00559 0.01418 -0.01258 -0.00848 0.00869 0.00504 -0.00683 -0.00118 -0.00845 -0.00082 -0.01240 0.01477 0.00027 -0.00390 -0.03248 0.01441 -0.01084 0.00665 0.01550 -0.00993 -0.01265 0.00256 0.01242 -0.02780 0.00775 -0.00152 0.00838 -0.00799 -0.00308 0.01127 0.01011 -0.00869 -0.00802 0.00214 -0.04938 0.00137 0.01467 0.01097 0.01076 0.00575 0.00759 -0.02597 0.00821 -0.00362 0.00270 -0.00048 0.00147 0.00288 0.00672 0.01319 0.01004 -0.00384 -0.02099 -0.00571 0.01148 0.00625 0.00036 0.00531 -0.00378 -0.00551 -0.00154 0.01298 -0.00029 -0.00499 0.01198 0.01287 -0.00486 0.00457 0.01983 -0.00111 0.02096 0.00467 0.01190 -0.02195 0.00898 -0.00011 -0.00296 -0.00553 0.00495 0.00885 -0.00147 0.00330 0.00412 0.01347 -0.04837 0.00478 0.00823 0.00851 0.01221 0.00526 0.00669 0.00147 0.00186 0.01320 0.00253 -0.00358 0.00459 0.00043 -0.00259 0.01297 -0.00132 0.01414 -0.03218 -0.01086 -0.00425 -0.00366 -0.00661 0.00657 0.00750 -0.00279 -0.00660 0.01225 0.00779 -0.00501 -0.01487 0.01964 -0.02040 0.00364 0.01487 0.00231 0.02822 0.01012 0.02101 -0.01891 0.00457 0.00110 0.00577 0.00282 -0.00795 0.00658 0.01514 0.00388 -0.00061 0.00023 -0.00555 -0.00988 0.01036 0.01034 0.00209 0.00860 0.00379 -0.01574 -0.00133 0.00185 0.00029 -0.02437 -0.00095 0.01293 -0.00441 0.01843 -0.00227 0.00284 -0.01366 -0.00752 0.01142 0.00925 -0.01270 0.00911 0.01564 -0.00243 -0.00696 0.01555 0.00670 0.00651 0.00594 0.03016 -0.01358 0.00843 0.00480 0.00019 0.03068 0.01012 0.01026 -0.02256 -0.00295 0.00483 0.00147 0.01357 -0.00438 0.01576 0.00360 0.00668 0.00343 0.01579 -0.01008 -0.00858 -0.00005 0.00288 -0.00009 0.01619 0.01222 0.00960 0.00341 0.00500 0.01434 -0.00319 0.01072 -0.00185 0.00009 0.02100 0.00217 0.00707 0.00332 -0.00379 0.00862 0.00810 -0.01190 0.00833 0.00302 -0.00658 -0.01072 0.01580 0.01324 -0.00459 -0.01296 0.00767 -0.01068 -0.00629 0.01659 0.00754 -0.00358 0.00345 0.00562 -0.03698 -0.00622 0.00200 0.00137 0.00032 -0.00709 -0.00320 -0.00331 -0.00705 -0.01153 -0.00526 -0.00520 0.00032 0.00813 0.00888 0.00380 0.00912 -0.00682 -0.00782 0.01062 0.00724 -0.00392 -0.00959 0.00971 0.00416 0.00754 0.00310 -0.00438 0.00351 0.00049 -0.00083 -0.00016 0.00558 -0.00893 0.00568 -0.00472 --0.01055 -0.00628 0.00132 -0.00796 -0.04986 0.02854 0.06218 -0.08003 -0.00342 0.02350 -0.00136 0.06895 -0.02099 0.11590 -0.08357 -0.00452 0.04791 0.04879 -0.03819 0.02812 -0.00369 0.03085 -0.01202 0.03543 0.00058 0.04019 -0.01477 -0.00737 0.06866 -0.00145 -0.00641 -0.01512 0.01381 -0.04507 0.01581 0.12039 0.16745 -0.01235 -0.01852 -0.02358 0.01593 0.00183 -0.00888 0.01479 0.03933 -0.01723 -0.00895 0.01029 -0.01427 0.03185 -0.03326 0.06279 0.01207 0.03231 0.02391 0.00737 0.00909 0.11926 -0.00082 -0.00584 -0.00429 0.00465 0.02526 -0.00902 0.05016 0.03272 0.03846 -0.00793 0.02638 0.00748 -0.00142 0.05675 0.20150 0.02755 0.02369 -0.03227 -0.00658 0.01188 0.00019 0.00014 0.01036 0.00518 0.09898 0.06239 0.04556 -0.01913 -0.02411 0.00269 0.02757 0.03263 0.01303 0.01470 0.00793 0.00173 -0.00640 0.02404 0.00795 0.00552 0.01009 0.00395 --0.00356 0.02835 0.00243 -0.01587 -0.04760 0.03950 0.19116 -0.02478 -0.00620 0.07574 -0.00068 0.07345 -0.01849 0.16345 -0.05294 0.00032 0.03337 0.07268 -0.03775 0.04433 0.01712 0.03647 0.02903 0.03869 -0.01106 0.04843 -0.00520 -0.00118 0.06288 -0.00960 -0.00468 -0.05127 0.02887 -0.05909 0.03449 0.08148 0.19509 0.00869 -0.01173 -0.00714 0.03845 0.03939 0.00834 0.03257 0.04829 -0.01360 0.00406 0.03381 -0.00995 0.07542 -0.01091 -0.00406 -0.00258 0.00722 0.00334 -0.00298 0.02311 -0.01604 0.00407 0.02076 0.00541 0.01708 0.00240 0.00721 -0.02480 -0.00752 0.01126 0.00822 0.00319 -0.00881 0.00509 0.00181 0.01159 -0.00147 0.00786 0.01576 0.00930 0.00022 0.00164 -0.00354 0.01434 0.01286 0.00687 0.00383 0.00664 0.01505 -0.01483 0.00544 0.00413 -0.00585 0.02145 -0.00129 0.00645 0.01731 -0.00928 0.01234 -0.00334 0.00345 0.01123 0.01695 --0.00407 -0.01475 0.00540 -0.00258 -0.00625 -0.02565 0.00189 -0.02467 -0.00975 -0.01415 -0.00687 0.00996 -0.00663 0.00141 -0.03201 0.00293 0.00014 0.00282 -0.00665 -0.02484 -0.00282 -0.01885 -0.01354 0.00270 0.00589 -0.01247 -0.00706 -0.00484 -0.00100 -0.00744 -0.00069 -0.00638 -0.01004 -0.03169 -0.00313 0.02280 -0.02796 -0.00407 -0.00803 -0.00407 -0.01835 -0.01614 -0.00958 -0.02668 0.01210 0.00785 -0.00535 -0.01762 0.00588 -0.01324 --0.04263 -0.09078 -0.00800 -0.03248 -0.02191 -0.07461 0.01589 -0.05570 -0.00436 -0.06506 -0.00829 0.00287 -0.03553 0.07150 0.04147 0.00068 0.05656 0.00528 -0.04501 -0.06243 0.00386 -0.05419 -0.06390 -0.00463 -0.03912 -0.04807 -0.01356 -0.00382 0.00332 -0.03654 -0.00500 -0.01301 -0.06479 -0.07547 -0.06669 0.02896 -0.04273 -0.01347 -0.04335 -0.05393 -0.00046 -0.04000 0.00287 -0.03030 -0.01238 -0.04872 0.00725 -0.06723 -0.01441 -0.08473 -0.00201 -0.00545 -0.00959 -0.00237 -0.00803 -0.00574 -0.00543 -0.01281 0.00024 -0.00317 0.00135 0.00245 0.00021 0.00529 -0.00938 -0.00052 0.00014 0.00215 -0.01349 0.00289 0.00539 -0.00253 0.00557 -0.00943 0.00956 0.00465 -0.01387 0.00744 0.01249 0.00660 -0.00134 -0.00887 -0.00191 -0.01427 0.00162 -0.00376 0.00183 0.00077 -0.00884 -0.00831 -0.01101 -0.00418 0.00389 0.00441 -0.00957 0.00579 0.00388 -0.00377 -0.01433 -0.01037 --0.00072 0.02109 0.00647 -0.00924 -0.01990 0.01638 0.01472 -0.03554 -0.00867 0.00022 -0.00542 0.05920 -0.01668 0.02402 -0.04831 -0.00957 0.03413 0.03250 -0.01057 0.02964 0.00995 0.02722 0.01736 0.04629 0.00162 0.03201 -0.01011 -0.00379 0.02518 0.00136 0.00013 -0.00849 0.00865 0.00064 0.02847 0.05107 0.13960 0.00524 -0.00754 -0.00727 0.02487 0.01536 -0.00885 0.02183 0.02482 -0.01802 0.00305 0.02812 0.00046 0.02424 -0.00340 -0.01153 0.00563 0.00787 -0.00830 -0.00025 -0.00411 -0.00515 -0.00953 -0.01312 -0.00095 -0.01648 -0.00698 -0.00846 -0.00269 -0.00369 0.00264 -0.01316 -0.01171 -0.01102 -0.01097 -0.01712 -0.02016 -0.01560 -0.00860 -0.00671 0.00364 0.00871 -0.01508 -0.00073 -0.00598 -0.01252 -0.02439 -0.00692 -0.01719 0.00289 0.00790 -0.00069 0.00105 0.00197 -0.00963 -0.01463 0.00001 -0.00703 0.00163 -0.00502 0.00943 -0.02098 0.00339 0.01030 --0.08246 -0.06532 -0.00270 -0.10040 -0.03360 -0.03803 0.16243 -0.08138 0.00136 0.01517 0.00881 0.09077 -0.08664 0.26318 0.03138 0.00556 -0.00750 0.05267 -0.02654 -0.02152 -0.00615 -0.02635 -0.05537 0.04831 -0.05203 0.00552 -0.01241 0.00688 0.15681 -0.02248 -0.00077 -0.01135 -0.05550 -0.09047 -0.05254 0.12129 0.01901 -0.00222 -0.06564 -0.07874 -0.01124 0.00982 0.00589 -0.07722 0.05693 -0.08639 0.00607 -0.05134 -0.02142 0.03231 -0.00737 -0.00040 0.00591 -0.00709 -0.02434 -0.01543 -0.00008 -0.03249 0.00294 -0.01130 0.00789 0.00208 0.00144 0.00409 -0.01787 -0.00939 -0.00288 -0.01004 -0.02718 -0.01238 0.00395 -0.01591 -0.00337 -0.00705 -0.00407 -0.03012 -0.00351 -0.00557 -0.01099 0.00285 0.00133 -0.03593 -0.01575 -0.04123 -0.00918 0.00684 0.01560 -0.00451 0.00668 -0.00041 -0.00865 -0.00200 -0.00271 -0.00348 0.00310 0.00062 -0.00738 0.00053 -0.00604 -0.00010 --0.00533 -0.01689 0.01098 -0.00204 -0.00982 -0.00275 -0.01344 -0.00809 -0.00634 -0.00522 0.00501 -0.00510 0.00280 -0.00654 -0.00306 0.00406 0.00629 0.01108 0.00468 -0.01510 0.01148 -0.00481 -0.00975 -0.00193 -0.00527 -0.01149 0.01087 0.01398 0.00092 -0.00882 -0.01129 -0.00903 -0.00177 0.00311 -0.02106 0.00586 -0.02227 0.01326 -0.00027 -0.00572 -0.01284 -0.02033 0.01129 -0.01519 -0.01460 -0.00563 0.01376 -0.00792 -0.00428 -0.01311 -0.01302 -0.00309 0.00451 0.00621 -0.01177 0.00928 0.01028 0.00070 -0.00479 0.00127 -0.00188 0.02679 0.00198 0.00116 -0.02522 -0.00937 0.00383 0.01318 -0.00204 -0.00637 0.00336 -0.00558 -0.00609 0.00375 0.00343 -0.02959 0.00367 0.00427 0.00779 0.00374 0.01632 -0.00057 0.01759 0.00729 0.00443 0.00986 -0.06156 0.00347 -0.00427 0.00144 0.00257 0.00157 -0.00014 -0.00214 0.00071 0.00259 0.01477 -0.00339 -0.00561 0.01362 --0.01144 0.00044 0.00176 -0.00376 -0.00337 -0.00333 -0.01375 0.00174 -0.00408 -0.00454 0.00354 -0.01066 -0.00324 -0.00104 -0.00201 0.00142 -0.01504 0.00354 -0.01450 -0.01534 0.00285 -0.00836 0.00304 -0.01175 -0.00516 -0.00935 -0.00634 0.00158 -0.01421 -0.00803 -0.01114 -0.00769 -0.00413 -0.01278 -0.00045 -0.00101 0.00028 -0.01135 -0.00748 -0.01537 -0.00038 -0.01538 -0.00158 -0.00062 0.00247 -0.01204 -0.00750 0.00314 0.00051 -0.01409 -0.01191 0.01941 0.00678 -0.00596 -0.00182 0.00311 0.00692 0.00303 0.00524 0.01255 0.00190 -0.00832 -0.00073 0.01509 -0.01960 -0.00626 -0.00128 0.00481 -0.01467 -0.01147 0.01137 -0.00005 0.00069 0.00867 -0.00342 -0.01447 -0.00096 0.00176 -0.00008 0.01132 0.00903 -0.00017 0.02495 -0.00848 -0.00647 -0.00381 -0.06553 -0.00346 0.00923 -0.00665 0.00928 0.00973 -0.00247 -0.00998 0.00867 0.00546 -0.00007 -0.00558 0.00635 0.01015 --0.00778 0.06281 -0.00469 -0.01169 -0.02419 0.04990 0.25173 -0.03448 -0.00492 0.03919 -0.00649 0.04912 -0.02577 0.06477 -0.07258 -0.00845 0.07770 0.02272 -0.03069 0.06250 0.00369 0.02960 0.05091 0.02323 -0.01031 0.06412 -0.02032 -0.01280 0.01819 -0.02485 -0.01510 -0.02157 0.05275 -0.03100 0.06355 0.07316 0.17523 -0.00977 -0.02445 -0.01289 0.01554 0.05452 0.00172 0.06376 0.06101 -0.01616 -0.01339 0.06478 -0.02240 0.10054 --0.01298 0.03718 -0.00621 0.00294 -0.02290 0.04587 0.18827 -0.03355 -0.00858 0.08080 -0.00427 0.07942 -0.01499 0.18688 -0.07385 -0.01342 0.05416 0.05726 -0.00895 0.04852 -0.00275 0.04551 0.04127 0.06660 -0.00189 0.08710 -0.01115 -0.00039 0.07668 -0.01678 -0.00375 -0.03345 0.04589 -0.04166 0.04778 0.10039 0.18520 -0.01304 -0.00001 -0.01489 0.04157 0.03507 -0.00787 0.04095 0.05016 -0.01298 -0.01328 0.04425 -0.00529 0.09037 --0.08499 0.00356 0.00030 -0.07454 -0.03180 -0.00262 -0.00124 -0.11473 0.00809 0.07966 -0.00159 0.11233 -0.06699 0.03629 0.00529 -0.00721 0.12834 0.06668 -0.05978 0.01057 -0.00881 0.02109 0.00313 0.08692 -0.07012 0.00716 -0.01494 0.00943 0.14547 -0.06296 -0.01035 -0.00852 -0.01092 -0.06647 0.02881 -0.00558 0.04286 -0.01361 -0.07148 -0.09108 0.10244 0.07079 -0.00819 -0.01120 -0.01907 -0.07969 0.00660 0.04265 -0.02701 0.02834 diff --git a/scripts/fullyconnected2_bias.txt b/scripts/fullyconnected2_bias.txt deleted file mode 100755 index 468adc194..000000000 --- a/scripts/fullyconnected2_bias.txt +++ /dev/null @@ -1,2 +0,0 @@ -0.04314 --0.04314 diff --git a/scripts/fullyconnected2_weight.txt b/scripts/fullyconnected2_weight.txt deleted file mode 100755 index 2a4e0c138..000000000 --- a/scripts/fullyconnected2_weight.txt +++ /dev/null @@ -1,2 +0,0 @@ -0.05475 0.04138 0.01032 0.04404 -0.00828 0.05638 0.00594 0.02925 0.00156 0.04180 0.14186 -0.00675 -0.00535 0.02814 -0.00675 -0.00425 0.00638 0.00748 -0.02885 0.00966 0.06460 0.02220 0.00242 -0.00630 -0.04709 0.07324 -0.00049 0.08063 -0.00550 0.34419 0.11215 0.01746 -0.00040 0.00121 0.01598 0.08494 0.00459 0.01049 -0.00731 0.03127 0.00486 0.06990 0.00063 0.02583 0.07850 -0.01284 0.00192 0.04871 -0.00957 -0.00578 0.00155 -0.01310 0.04457 -0.00886 0.00675 0.06613 0.01257 0.00345 -0.00662 0.07155 -0.01610 0.00334 0.01016 0.03726 -0.01639 -0.00059 0.06772 0.00034 -0.00375 0.00376 0.00265 0.06986 0.06801 -0.00090 -0.00260 0.13769 0.00718 -0.00732 0.00158 0.00042 -0.00477 -0.00241 0.06637 -0.03738 0.07309 -0.00386 0.02818 -0.00557 -0.00716 0.01844 -0.00269 0.15258 -0.00738 -0.01102 0.00486 -0.00256 0.00059 0.08059 0.07076 0.03567 --0.05857 -0.04227 -0.02106 -0.05449 0.00624 -0.06212 0.00664 -0.03500 0.01170 -0.05479 -0.14921 -0.00158 -0.00732 -0.02731 -0.00564 0.00706 0.00205 0.00091 0.01503 0.00318 -0.06232 -0.02818 -0.00590 -0.00043 0.03822 -0.06244 -0.01345 -0.09005 -0.00817 -0.33807 -0.09574 -0.01528 0.00001 0.00975 -0.02421 -0.07780 -0.00316 -0.01251 -0.00497 -0.03225 -0.00156 -0.07102 -0.00032 -0.01176 -0.08131 -0.00242 -0.00351 -0.05073 0.00902 -0.00383 -0.00504 -0.00301 -0.05006 -0.00440 -0.02233 -0.07276 -0.00396 0.01514 -0.00065 -0.06951 0.01994 -0.00622 0.00606 -0.03784 0.02202 -0.00954 -0.07022 0.00964 0.00542 0.00191 0.00003 -0.06577 -0.06617 -0.00287 0.00510 -0.12928 -0.00364 -0.00414 0.00200 -0.00440 0.00480 -0.01200 -0.06600 0.03217 -0.06861 0.00284 -0.02132 0.00463 0.01788 -0.01700 -0.01470 -0.14685 0.00858 -0.00594 -0.01149 -0.00973 -0.00171 -0.07285 -0.07734 -0.02677 diff --git a/scripts/gen_header.py b/scripts/gen_header.py deleted file mode 100644 index f88704359..000000000 --- a/scripts/gen_header.py +++ /dev/null @@ -1,59 +0,0 @@ -import os -import sys - -def readFile(filePath): - file = open(filePath, 'r') - lines = file.readlines() - file.close() - return lines - -def writeFile(filePath, lines): - file = open(filePath, 'w') - for line in lines: - file.write(line) - file.close() - -def gen_header(input_file): - lines = readFile(input_file) - outputs = [] - for index in range(1, len(lines)): - line = lines[index].strip() - output = "" - items = line.split("\t") - if len(items) == 1: continue - #['conv1_1', '3', '64', '300', '300', '300', '300', '3', '3', '1', '', '', '154829568', '0.52%', '1', '1'] - conv_name = items[0] - ic = items[1] - oc = items[2] - ih = items[3] - iw = items[4] - kh = items[7] - kw = items[8] - ph = items[14] - pw = items[15] - s = items[9] - output += "# if defined(SSD_VGG16_" + conv_name.upper() + "_" + kh + "X" + kw + ")\n" - output += " # define NUM_IFMs " + ic + "\n" - output += " # define NUM_OFMs " + oc + "\n" - output += " # define KERNEL_H " + kh + "\n" - output += " # define KERNEL_W " + kw + "\n" - output += " # define IFM_H_NOPAD " + ih + "\n" - output += " # define IFM_W_NOPAD " + iw + "\n" - output += " # define PAD_H " + ph + "\n" - output += " # define PAD_W " + pw + "\n" - output += " # define STRIDE_H " + s + "\n" - output += " # define STRIDE_W " + s + "\n" - # FIXME: enhance to detect whether RELU and RESIDUAL is after convolution - output += " # define RELU 1\n" - output += " # define RESIDUAL 0\n" - output += "#endif\n\n" - outputs.append(output) - - writeFile("header.h", outputs) - -if __name__ == '__main__': - if len(sys.argv) != 2: - print "Usgae: python gen_header.py input_file" - sys.exit(0) - - gen_header(sys.argv[1]) diff --git a/scripts/optimze_input_u8.diff b/scripts/optimze_input_u8.diff deleted file mode 100644 index 9f2b090f3..000000000 --- a/scripts/optimze_input_u8.diff +++ /dev/null @@ -1,117 +0,0 @@ -diff --git a/scripts/calibrator.py b/scripts/calibrator.py -index c79b1fd..9be289e 100644 ---- a/scripts/calibrator.py -+++ b/scripts/calibrator.py -@@ -109,6 +109,34 @@ def get_input_convolutions(l, net, end, interesting_layers): - - return all_input_layers - -+def is_convolution_input_u8(l, net, end, interesting_layers, convs_output_with_relu): -+ all_input_layers = [] -+ input_layers = get_input_layers(l, net, end) -+ while True: -+ if len(input_layers) == 0: -+ break -+ -+ for input_layer in input_layers: -+ if input_layer[2] == "Convolution" and (input_layer[1] not in convs_output_with_relu): -+ return False -+ -+ processed_layers = input_layers # sync inputLayers change -+ for lp in processed_layers: -+ if lp[2] not in int8_layers: -+ input_layers.remove(lp) -+ continue -+ if lp[2] in interesting_layers: -+ input_layers.remove(lp) -+ if lp not in all_input_layers: -+ all_input_layers.append(lp) -+ continue -+ -+ new_input_layers = get_input_layers(net.layer[lp[0]], net, lp[0]) -+ input_layers.remove(lp) -+ input_layers.extend(new_input_layers) -+ -+ return True -+ - def analyze_conv_output_with_relu(compiled_net): - convs_output_with_relu = [] - for _, layer in enumerate(compiled_net.layer): -@@ -120,6 +148,7 @@ def analyze_conv_output_with_relu(compiled_net): - - def analyze_conv_input_u8(conv_inputs, convs_output_with_relu): - for conv_input in conv_inputs: -+ print conv_input - if conv_input[1] not in convs_output_with_relu: - return False - return True -@@ -152,19 +181,9 @@ def transform_convolutions(model_path, compiled_model_path, use_unsigned_range, - u8_max = 255 - s8_max = 127 - for (l, index) in convolution_layers: -- for si in range(0, len(new_net.layer[index].quantization_param.scale_out)): -- if l.name in convs_output_with_relu: # u8 -- new_net.layer[index].quantization_param.scale_out[si] = u8_max / new_net.layer[index].quantization_param.scale_out[si] -- else: # s8 -- if use_unsigned_range: -- new_net.layer[index].quantization_param.scale_out[si] = u8_max / new_net.layer[index].quantization_param.scale_out[si] -- else: -- new_net.layer[index].quantization_param.scale_out[si] = s8_max / new_net.layer[index].quantization_param.scale_out[si] -- - index_in_compiled_net = find_index_by_name(l.name, compiled_convolution_layers) - assert(index_in_compiled_net >= 0) -- conv_inputs = get_input_convolutions(l, compiled_net, index_in_compiled_net, ["Convolution"]) -- conv_input_u8 = analyze_conv_input_u8(conv_inputs, convs_output_with_relu) -+ conv_input_u8 = is_convolution_input_u8(l, compiled_net, index_in_compiled_net, ["Convolution"], convs_output_with_relu) - for si in range(0, len(new_net.layer[index].quantization_param.scale_in)): - if conv_input_u8: # u8 - new_net.layer[index].quantization_param.scale_in[si] = u8_max / new_net.layer[index].quantization_param.scale_in[si] -@@ -185,48 +204,6 @@ def transform_convolutions(model_path, compiled_model_path, use_unsigned_range, - for si in range(0, len(new_net.layer[index_bottom_layer].quantization_param.scale_out)): - new_net.layer[index_bottom_layer].quantization_param.scale_out[si] = new_net.layer[index].quantization_param.scale_in[si] - -- concat_layers = [(value, index) for index, value in enumerate(net.layer) if value.type == 'Concat'] -- if len(concat_layers) > 0: -- compiled_concat_layers = [(value, index) for index, value in enumerate(compiled_net.layer) if value.type == 'Concat'] -- concat_layers.reverse() -- if unify_concat_scales: -- for (l, index) in concat_layers: -- index_in_compiled_net = find_index_by_name(l.name, compiled_concat_layers) -- assert(index_in_compiled_net >= 0) -- conv_inputs = get_input_convolutions(l, compiled_net, index_in_compiled_net, ["Convolution"]) -- min_concat_scale = sys.float_info.max -- concat_input_indexes = [] -- for conv_input in conv_inputs: -- index_in_net = find_index_by_name(conv_input[1], convolution_layers) -- assert(index_in_net >= 0) -- concat_input_indexes.append(index_in_net) -- if new_net.layer[index_in_net].quantization_param.scale_out[0] < min_concat_scale: -- min_concat_scale = new_net.layer[index_in_net].quantization_param.scale_out[0] -- -- for concat_input_index in concat_input_indexes: -- new_net.layer[concat_input_index].quantization_param.scale_out[0] = min_concat_scale -- else: -- if concat_use_fp32: -- for (l, index) in concat_layers: -- index_in_compiled_net = find_index_by_name(l.name, compiled_concat_layers) -- assert(index_in_compiled_net >= 0) -- conv_inputs = get_input_convolutions(l, compiled_net, index_in_compiled_net, ["Convolution"]) -- for conv_input in conv_inputs: -- index_in_net = find_index_by_name(conv_input[1], convolution_layers) -- assert(index_in_net >= 0) -- new_net.layer[index_in_net].quantization_param.bw_layer_out = 32 -- new_net.layer[index_in_net].quantization_param.scale_out[:] = [1.0] -- -- # Force FP32 output for convolution acting as FC -- fc_layers = [(value, index) for index, value in enumerate(net.layer) if value.type == 'InnerProduct'] -- if len(fc_layers) == 0 and convolution_layers[-1][0].convolution_param.num_output == 1000: -- new_net.layer[convolution_layers[-1][1]].quantization_param.bw_layer_out = 32 -- new_net.layer[convolution_layers[-1][1]].quantization_param.scale_out[:] = [1.0] -- -- with open(model_path, 'w') as f: -- f.write(str(new_net)) -- -- - def generate_sample_bak(sample_path, input_model, weights, - quantized_model, detection, scaling_mode, iterations=1, error_margin=1): - cmd = '{0} quantize -model {1} -weights {2} -model_quantized {3} -iterations {4} -error_margin {5} ' \ diff --git a/scripts/output.csv b/scripts/output.csv deleted file mode 100644 index 34d12fa64..000000000 --- a/scripts/output.csv +++ /dev/null @@ -1,525 +0,0 @@ -# if defined(SSD_VGG16_CONV1_1_3X3) - # define NUM_IFMs 3 - # define NUM_OFMs 64 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 300 - # define IFM_W_NOPAD 300 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV1_2_3X3) - # define NUM_IFMs 64 - # define NUM_OFMs 64 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 300 - # define IFM_W_NOPAD 300 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV2_1_3X3) - # define NUM_IFMs 64 - # define NUM_OFMs 128 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 150 - # define IFM_W_NOPAD 150 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV2_2_3X3) - # define NUM_IFMs 128 - # define NUM_OFMs 128 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 150 - # define IFM_W_NOPAD 150 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV3_1_3X3) - # define NUM_IFMs 128 - # define NUM_OFMs 256 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 75 - # define IFM_W_NOPAD 75 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV3_2_3X3) - # define NUM_IFMs 256 - # define NUM_OFMs 256 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 75 - # define IFM_W_NOPAD 75 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV3_3_3X3) - # define NUM_IFMs 256 - # define NUM_OFMs 256 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 75 - # define IFM_W_NOPAD 75 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV4_1_3X3) - # define NUM_IFMs 256 - # define NUM_OFMs 512 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 38 - # define IFM_W_NOPAD 38 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV4_2_3X3) - # define NUM_IFMs 512 - # define NUM_OFMs 512 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 38 - # define IFM_W_NOPAD 38 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV4_3_3X3) - # define NUM_IFMs 512 - # define NUM_OFMs 512 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 38 - # define IFM_W_NOPAD 38 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV5_1_3X3) - # define NUM_IFMs 512 - # define NUM_OFMs 512 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 19 - # define IFM_W_NOPAD 19 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV5_2_3X3) - # define NUM_IFMs 512 - # define NUM_OFMs 512 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 19 - # define IFM_W_NOPAD 19 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV5_3_3X3) - # define NUM_IFMs 512 - # define NUM_OFMs 512 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 19 - # define IFM_W_NOPAD 19 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_FC6_3X3) - # define NUM_IFMs 512 - # define NUM_OFMs 1024 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 19 - # define IFM_W_NOPAD 19 - # define PAD_H 6 - # define PAD_W 6 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_FC7_1X1) - # define NUM_IFMs 1024 - # define NUM_OFMs 1024 - # define KERNEL_H 1 - # define KERNEL_W 1 - # define IFM_H_NOPAD 19 - # define IFM_W_NOPAD 19 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV6_1_1X1) - # define NUM_IFMs 1024 - # define NUM_OFMs 256 - # define KERNEL_H 1 - # define KERNEL_W 1 - # define IFM_H_NOPAD 19 - # define IFM_W_NOPAD 19 - # define PAD_H 0 - # define PAD_W 0 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV6_2_3X3) - # define NUM_IFMs 256 - # define NUM_OFMs 512 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 19 - # define IFM_W_NOPAD 19 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 2 - # define STRIDE_W 2 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV7_1_1X1) - # define NUM_IFMs 512 - # define NUM_OFMs 128 - # define KERNEL_H 1 - # define KERNEL_W 1 - # define IFM_H_NOPAD 10 - # define IFM_W_NOPAD 10 - # define PAD_H 0 - # define PAD_W 0 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV7_2_3X3) - # define NUM_IFMs 128 - # define NUM_OFMs 256 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 10 - # define IFM_W_NOPAD 10 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 2 - # define STRIDE_W 2 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV8_1_1X1) - # define NUM_IFMs 256 - # define NUM_OFMs 128 - # define KERNEL_H 1 - # define KERNEL_W 1 - # define IFM_H_NOPAD 5 - # define IFM_W_NOPAD 5 - # define PAD_H 0 - # define PAD_W 0 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV8_2_3X3) - # define NUM_IFMs 128 - # define NUM_OFMs 256 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 5 - # define IFM_W_NOPAD 5 - # define PAD_H 0 - # define PAD_W 0 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV9_1_1X1) - # define NUM_IFMs 256 - # define NUM_OFMs 128 - # define KERNEL_H 1 - # define KERNEL_W 1 - # define IFM_H_NOPAD 3 - # define IFM_W_NOPAD 3 - # define PAD_H 0 - # define PAD_W 0 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV9_2_3X3) - # define NUM_IFMs 128 - # define NUM_OFMs 256 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 3 - # define IFM_W_NOPAD 3 - # define PAD_H 0 - # define PAD_W 0 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV4_3_NORM_MBOX_LOC_3X3) - # define NUM_IFMs 512 - # define NUM_OFMs 16 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 38 - # define IFM_W_NOPAD 38 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV4_3_NORM_MBOX_CONF_3X3) - # define NUM_IFMs 512 - # define NUM_OFMs 84 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 38 - # define IFM_W_NOPAD 38 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_FC7_MBOX_LOC_3X3) - # define NUM_IFMs 1024 - # define NUM_OFMs 24 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 19 - # define IFM_W_NOPAD 19 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_FC7_MBOX_CONF_3X3) - # define NUM_IFMs 1024 - # define NUM_OFMs 126 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 19 - # define IFM_W_NOPAD 19 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV6_2_MBOX_LOC_3X3) - # define NUM_IFMs 512 - # define NUM_OFMs 24 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 10 - # define IFM_W_NOPAD 10 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV6_2_MBOX_CONF_3X3) - # define NUM_IFMs 512 - # define NUM_OFMs 126 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 10 - # define IFM_W_NOPAD 10 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV7_2_MBOX_LOC_3X3) - # define NUM_IFMs 256 - # define NUM_OFMs 24 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 5 - # define IFM_W_NOPAD 5 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV7_2_MBOX_CONF_3X3) - # define NUM_IFMs 256 - # define NUM_OFMs 126 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 5 - # define IFM_W_NOPAD 5 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV8_2_MBOX_LOC_3X3) - # define NUM_IFMs 256 - # define NUM_OFMs 16 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 3 - # define IFM_W_NOPAD 3 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV8_2_MBOX_CONF_3X3) - # define NUM_IFMs 256 - # define NUM_OFMs 84 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 3 - # define IFM_W_NOPAD 3 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV9_2_MBOX_LOC_3X3) - # define NUM_IFMs 256 - # define NUM_OFMs 16 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 1 - # define IFM_W_NOPAD 1 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - -# if defined(SSD_VGG16_CONV9_2_MBOX_CONF_3X3) - # define NUM_IFMs 256 - # define NUM_OFMs 84 - # define KERNEL_H 3 - # define KERNEL_W 3 - # define IFM_H_NOPAD 1 - # define IFM_W_NOPAD 1 - # define PAD_H 1 - # define PAD_W 1 - # define STRIDE_H 1 - # define STRIDE_W 1 - # define RELU 1 - # define RESIDUAL 0 -#endif - diff --git a/scripts/result.txt b/scripts/result.txt deleted file mode 100644 index c68ff2e8b..000000000 --- a/scripts/result.txt +++ /dev/null @@ -1,75 +0,0 @@ - -../tr_logs/tr_fp32_ssd_vgg16_throughput_bs252.log -Layer Count msec %% -Normalize 1 135.009 0.0222822695775 -DetectionEvaluate 1 5.32736 0.00087924265535 -Convolution 35 5146.50372 0.849393620206 -Flatten 13 0.03591 5.92668859503e-06 -Reshape 1 0.00337 5.56194390567e-07 -DetectionOutput 1 553.417 0.0913375166303 -Softmax 1 8.2555 0.00136251121404 -PriorBox 6 0.18545 3.06071957658e-05 -Pooling 5 164.35504 0.0271256235339 -DummyData 2 0.00285 4.70372110717e-07 -Permute 12 39.43443 0.00650837055228 -Concat 3 6.46113 0.00106636328271 -Split 8 0.04194 6.9218969556e-06 -Total 6059.0327 - -../tr_logs/tr_int8_ssd_mobilenetv1_throughput_bs252.log -Layer Count msec %% -DetectionEvaluate 1 6.30355 0.0120020708097 -Convolution 47 348.43858 0.663433225718 -Reshape 1 0.00326 6.20709772104e-06 -DetectionOutput 1 158.455 0.301701125579 -Softmax 1 1.92074 0.00365712296832 -PriorBox 6 0.05314 0.000101179500888 -Split 7 0.02648 5.04183888507e-05 -Flatten 13 0.02424 4.61533891896e-05 -Permute 12 8.53202 0.0162451171466 -Concat 3 1.44396 0.00274932540653 -DummyData 2 0.00423 8.05399489571e-06 -Total 525.2052 - -/home/hshen14/ssd_int8.log -Layer Count msec %% -Normalize 1 164.555 0.0450713082986 -Convolution 35 3389.0968 0.928267307142 -Flatten 13 0.03861 1.05752071551e-05 -Reshape 1 0.00385 1.05450783598e-06 -Softmax 1 7.68872 0.00210592610095 -PriorBox 6 0.12256 3.35689559423e-05 -Pooling 5 39.45381 0.010806325144 -DummyData 2 0.00322 8.81952008275e-07 -Permute 12 43.33475 0.0118693073884 -Concat 3 6.65517 0.00182283867916 -Split 8 0.03982 1.09066239036e-05 -Total 3650.99231 - -/home/hshen14/ssd_int8.log -Layer Count msec %% -Normalize 1 163.488 0.0452009410172 -Convolution 35 3399.74266 0.939956250295 -Flatten 1 0.00546 1.50957341183e-06 -Reshape 1 4.19603 0.00116011269657 -Softmax 1 7.72603 0.00213608231997 -PriorBox 6 0.1521 4.20524021868e-05 -Pooling 5 39.98437 0.011054824513 -DummyData 2 0.00291 8.04552862351e-07 -Concat 3 1.57865 0.000436463015859 -Split 8 0.03964 1.09596135614e-05 -Total 3616.91585 - -/home/hshen14/ssd_int8.log -Layer Count msec %% -Normalize 1 163.535 0.0454561267921 -Convolution 35 3381.03186 0.939790337948 -Flatten 1 0.00476 1.32308780096e-06 -Reshape 1 4.15656 0.00115535584663 -Softmax 1 7.44192 0.00206855327053 -PriorBox 6 0.13238 3.67962947671e-05 -Pooling 5 39.74109 0.0110464183563 -DummyData 2 0.00304 8.44997251035e-07 -Concat 3 1.56386 0.000434689934541 -Split 8 0.03437 9.55347220989e-06 -Total 3597.64484 diff --git a/scripts/sampling.py b/scripts/sampling.py index b88213720..501e92585 100644 --- a/scripts/sampling.py +++ b/scripts/sampling.py @@ -9,7 +9,7 @@ sys.path.insert(0, pycaffe) import caffe -calibration_algos = ["DIRECT", "KL", "MAXP"] +calibration_algos = ["DIRECT", "KL", "MAXP", "MA"] scaling_modes = ["SINGLE", "MULTIPLE"] sampling_layers = ["Convolution", "InnerProduct"] @@ -49,7 +49,7 @@ def get_winograd_info(model, conv_bottom_blob_layer_map, winograd_algo = False): return (winograd_bottoms, winograd_convolutions) -def sample(model, weight, winograd_algo=False, itern=1, enable_first_conv=False): +def sample(model, weight, winograd_algo=False, itern=1, enable_first_conv=False, sampling_single=False): caffe.set_mode_cpu() test_net = caffe.Net(model, weight, caffe.TEST) (conv_layers, top_blobs_map, bottom_blobs_map, conv_top_blob_layer_map, conv_bottom_blob_layer_map) = get_blob_map(test_net, enable_first_conv) @@ -58,15 +58,13 @@ def sample(model, weight, winograd_algo=False, itern=1, enable_first_conv=False) for iter_index in range(0, itern): print "Iteration:", (iter_index + 1) test_net.forward() + if sampling_single and iter_index < itern - 1: + continue for k, _ in test_net.blobs.items(): # top blob - output = test_net.blobs[k].data if k not in blobs.keys(): - blobs[k] = [output] + blobs[k] = [test_net.blobs[k].data.copy()] else: - new_outputs = blobs[k] - new_outputs.append(output) - blobs[k] = new_outputs - + blobs[k].append(test_net.blobs[k].data.copy()) params = {} for k, _ in test_net.params.items(): if k not in conv_layers: @@ -124,8 +122,10 @@ def get_optimal_scaling_factor(activation_blob, num_quantized_bins = 255): hist, hist_edeges = np.histogram(activation_blob, bins=2048, range=(min_val, max_val)) ending_iter = 2047 starting_iter = int(ending_iter * 0.7) + min_range = min_val else: th = max(abs(max_val), abs(min_val)) + min_range = -th hist, hist_edeges = np.histogram(activation_blob, bins=2048, range=(-th, th)) starting_iter = 0 ending_iter = 2047 @@ -188,7 +188,7 @@ def get_optimal_scaling_factor(activation_blob, num_quantized_bins = 255): else: break min_kl_index = starting_iter - return (min_kl_index+0.5)*bin_width + return (min_kl_index+0.5)*bin_width + min_range # calibrator info: data, algo, scaling_mode, max_p INDEX_DATA = 0 @@ -245,9 +245,23 @@ def calibrate_max(calibrator_info): iteration_output_wino = wino_transform_param(iteration_output) else: iteration_output_wino = iteration_output - iteration_max = np.max(iteration_output_wino) + iteration_max = np.max(np.abs(iteration_output_wino)) if iteration_max > layer_max: layer_max = iteration_max + elif calibration_algo == "MA": + iteration_output_maxs = [] + for iteration_output in iteration_outputs: + if is_wino_conv: + if is_activation: + iteration_output_wino = wino_transform_data(iteration_output) + else: + iteration_output_wino = wino_transform_param(iteration_output) + else: + iteration_output_wino = iteration_output + iteration_output_maxs.append(np.max(np.abs(iteration_output_wino))) + layer_max = iteration_output_maxs[0] + for i in range(1, len(iteration_output_maxs)): + layer_max = 0.5 * layer_max + 0.5 * iteration_output_maxs[i] elif calibration_algo == "MAXP": iteration_sum = 0 for iteration_output in iteration_outputs: @@ -285,9 +299,25 @@ def calibrate_max(calibrator_info): else: iteration_output_wino = iteration_output for i in range(0, iteration_output_wino.shape[0]): - oc_max = np.max(iteration_output_wino[i]) + oc_max = np.max(np.abs(iteration_output_wino[i])) if oc_max > layer_max_oc[i]: layer_max_oc[i] = float(oc_max) + elif calibration_algo == "MA": + iteration_output_maxs = [] + for iteration_output in iteration_outputs: + if is_wino_conv: + if is_activation: + iteration_output_wino = wino_transform_data(iteration_output) + else: + iteration_output_wino = wino_transform_param(iteration_output) + else: + iteration_output_wino = iteration_output + oc_max = [np.max(np.abs(output_oc)) for output_oc in iteration_output_wino] + iteration_output_maxs.append(oc_max) + layer_max_oc = iteration_output_maxs[0] + for i in range(len(layer_max_oc)): + for j in range(1, len(iteration_output_maxs)): + layer_max_oc[i] = 0.5 * layer_max_oc[i] + 0.5 * iteration_output_maxs[j][i] elif calibration_algo == "MAXP": for i in range(0, iteration_outputs[0].shape[0]): layer_max_oc.append(0) @@ -334,15 +364,15 @@ def calibrate_activations(blobs, conv_top_blob_layer_map, conv_bottom_blob_layer print "Calibrate activation for", k, v[0].shape if is_wino_conv: if k in winograd_bottoms: - v_max = calibrate_max((np_abs(v), calibration_algo, scaling_mode, maxp, 1, True)) + v_max = calibrate_max((v, calibration_algo, scaling_mode, maxp, 1, True)) conv_blobs_max[k] = v_max else: - v_max = calibrate_max((np_abs(v), calibration_algo, scaling_mode, maxp, 0, False)) + v_max = calibrate_max((v, calibration_algo, scaling_mode, maxp, 0, False)) conv_blobs_max[k] = v_max else: print "-----------------" - v_max = calibrate_max((np_abs(v), calibration_algo, scaling_mode, maxp, 0, False)) - v_min = calibrate_min((v, calibration_algo, scaling_mode, maxp, 0, False)) + v_max = calibrate_max((v, calibration_algo, scaling_mode, maxp, 1, False)) + v_min = calibrate_min((v, calibration_algo, scaling_mode, maxp, 1, False)) conv_blobs_max[k] = v_max conv_blobs_min[k] = v_min diff --git a/src/caffe/CMakeLists.txt b/src/caffe/CMakeLists.txt index ba2f0c32d..2a211ae3c 100644 --- a/src/caffe/CMakeLists.txt +++ b/src/caffe/CMakeLists.txt @@ -3,9 +3,9 @@ file(GLOB proto_files proto/*.proto) caffe_protobuf_generate_cpp_py(${proto_gen_folder} proto_srcs proto_hdrs proto_python ${proto_files}) # include python files either to force generation -add_library(proto STATIC ${proto_hdrs} ${proto_srcs} ${proto_python}) -set(Caffe_LINKER_LIBS proto ${Caffe_LINKER_LIBS}) # note, crucial to prepend! -caffe_default_properties(proto) +add_library(caffeproto STATIC ${proto_hdrs} ${proto_srcs} ${proto_python}) +set(Caffe_LINKER_LIBS caffeproto ${Caffe_LINKER_LIBS}) # note, crucial to prepend! +caffe_default_properties(caffeproto) # --[ Caffe library @@ -18,16 +18,29 @@ if(HAVE_CUDA) endif() add_library(caffe ${srcs}) +if(MSVC) + # Disable Boost autolinking for consuming projects + target_compile_definitions(caffe PUBLIC -DBOOST_ALL_NO_LIB) +endif() + # Add dependency to force building MKLDNN when not given by ENV var if(NOT DEFINED ENV{MKLDNNROOT}) add_dependencies(caffe mkldnn) endif() -target_link_libraries(caffe proto ${Caffe_LINKER_LIBS}) +target_link_libraries(caffe caffeproto ${Caffe_LINKER_LIBS}) caffe_default_properties(caffe) -set_target_properties(caffe PROPERTIES +if (BUILD_SHARED_LIBS) + set_target_properties(caffe PROPERTIES + VERSION ${CAFFE_TARGET_VERSION} + SOVERSION ${CAFFE_TARGET_SOVERSION} + WINDOWS_EXPORT_ALL_SYMBOLS TRUE + ) +else() + set_target_properties(caffe PROPERTIES VERSION ${CAFFE_TARGET_VERSION} SOVERSION ${CAFFE_TARGET_SOVERSION} ) +endif() # ---[ Tests add_subdirectory(test) @@ -35,7 +48,7 @@ set_target_properties(caffe PROPERTIES # ---[ Install install(DIRECTORY ${Caffe_INCLUDE_DIR}/caffe DESTINATION include) install(FILES ${proto_hdrs} DESTINATION include/caffe/proto) -install(TARGETS caffe proto EXPORT CaffeTargets DESTINATION lib) +install(TARGETS caffe caffeproto EXPORT CaffeTargets DESTINATION lib) file(WRITE ${PROJECT_BINARY_DIR}/__init__.py) list(APPEND proto_python ${PROJECT_BINARY_DIR}/__init__.py) diff --git a/src/caffe/common.cpp b/src/caffe/common.cpp index 3d1a48325..23bca0b85 100644 --- a/src/caffe/common.cpp +++ b/src/caffe/common.cpp @@ -41,6 +41,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#if defined(_MSC_EXTENSIONS) +#include +#define getpid() _getpid() +#endif + #include "caffe/common.hpp" #include "caffe/util/rng.hpp" diff --git a/src/caffe/data_transformer.cpp b/src/caffe/data_transformer.cpp index c92efb581..d53d4b7c1 100644 --- a/src/caffe/data_transformer.cpp +++ b/src/caffe/data_transformer.cpp @@ -1019,6 +1019,8 @@ void DataTransformer::Transform(const cv::Mat& cv_img_in, const Dtype scale = param_.scale(); + const int pad = param_.pad(); + CHECK_GT(img_channels, 0); Dtype* mean = NULL; @@ -1061,8 +1063,8 @@ void DataTransformer::Transform(const cv::Mat& cv_img_in, int w_off = 0; cv::Mat cv_cropped_img = *cv_img; if (crop_size) { - CHECK_EQ(crop_size, height); - CHECK_EQ(crop_size, width); + CHECK_EQ(crop_size + pad * 2, height); + CHECK_EQ(crop_size + pad * 2, width); // We only do random crop when we do training. if (phase_ == TRAIN) { h_off = rand_num(img_height - crop_size + 1); @@ -1077,11 +1079,16 @@ void DataTransformer::Transform(const cv::Mat& cv_img_in, cv_cropped_img = cv_noised_img; } + // Pad zero to image for first convolution. + if(pad != 0) { + cv::copyMakeBorder(cv_cropped_img, cv_cropped_img, pad, pad, pad, pad, cv::BORDER_CONSTANT, 0); + } + // Return the normalized crop bbox. crop_bbox->set_xmin(Dtype(w_off) / img_width); crop_bbox->set_ymin(Dtype(h_off) / img_height); - crop_bbox->set_xmax(Dtype(w_off + width) / img_width); - crop_bbox->set_ymax(Dtype(h_off + height) / img_height); + crop_bbox->set_xmax(Dtype(w_off + width - pad * 2) / img_width); + crop_bbox->set_ymax(Dtype(h_off + height - pad * 2) / img_height); CHECK(cv_cropped_img.data); @@ -1099,16 +1106,20 @@ void DataTransformer::Transform(const cv::Mat& cv_img_in, } // int top_index = (c * height + h) * width + w; Dtype pixel = static_cast(ptr[img_index++]); - if (has_mean_file) { - int mean_index = (c * img_height + h_off + h) * img_width + w_off + w; - transformed_data[top_index] = - (pixel - mean[mean_index]) * scale; + if(h < pad || w < pad || h > (height - pad) || w > (width - pad)) { + transformed_data[top_index] = pixel; } else { - if (has_mean_values) { + if (has_mean_file) { + int mean_index = (c * img_height + h_off + h) * img_width + w_off + w; transformed_data[top_index] = - (pixel - mean_values_[c]) * scale; + (pixel - mean[mean_index]) * scale; } else { - transformed_data[top_index] = pixel * scale; + if (has_mean_values) { + transformed_data[top_index] = pad == 0 ? + (pixel - mean_values_[c]) * scale : nearbyint((pixel - mean_values_[c]) * scale); + } else { + transformed_data[top_index] = pixel * scale; + } } } } @@ -1571,6 +1582,7 @@ vector DataTransformer::InferBlobShape( template vector DataTransformer::InferBlobShape(const cv::Mat& cv_img) { const int crop_size = param_.crop_size(); + const int pad = param_.pad(); const int img_channels = cv_img.channels(); int img_height = cv_img.rows; int img_width = cv_img.cols; @@ -1593,8 +1605,8 @@ vector DataTransformer::InferBlobShape(const cv::Mat& cv_img) { vector shape(4); shape[0] = 1; shape[1] = img_channels; - shape[2] = (crop_size)? crop_size: img_height; - shape[3] = (crop_size)? crop_size: img_width; + shape[2] = ((crop_size)? crop_size: img_height) + pad * 2; + shape[3] = ((crop_size)? crop_size: img_width) + pad * 2; return shape; } diff --git a/src/caffe/internal_thread.cpp b/src/caffe/internal_thread.cpp index e97c4d797..e71c4b9f5 100644 --- a/src/caffe/internal_thread.cpp +++ b/src/caffe/internal_thread.cpp @@ -157,6 +157,14 @@ void InternalThread::SetThreadAffinity( if (ncores > 0) { int pin_core_id = count % ncores; +#if defined(_MSC_EXTENSIONS) + HANDLE handle = GetCurrentThread(); + GROUP_AFFINITY groupAffinity; + ZeroMemory(&groupAffinity, sizeof(GROUP_AFFINITY)); + groupAffinity.Mask = 1 << pin_core_id; + groupAffinity.Group = count / ncores; + SetThreadGroupAffinity(handle, &groupAffinity, NULL); +#else cpu_set_t set; CPU_ZERO(&set); CPU_SET(affinity_cores[pin_core_id], &set); @@ -170,6 +178,7 @@ void InternalThread::SetThreadAffinity( LOG(INFO) << "Internal thread is affinitized to core " << j; } } +#endif } count++; } diff --git a/src/caffe/layers/annotated_data_layer.cpp b/src/caffe/layers/annotated_data_layer.cpp index c53f5126e..7245b5749 100644 --- a/src/caffe/layers/annotated_data_layer.cpp +++ b/src/caffe/layers/annotated_data_layer.cpp @@ -204,7 +204,9 @@ void AnnotatedDataLayer::load_batch(Batch* batch) { string* data = reader_.full().pop("Waiting for data"); timer.Stop(); read_time += timer.MicroSeconds(); +#if !defined(_MSC_EXTENSIONS) #pragma omp task firstprivate(item_id, data) shared(all_anno, expand_data, sampled_bboxes, have_samples) +#endif { std::unique_ptr anno_datum(new AnnotatedDatum()); anno_datum->ParseFromString(*data); @@ -242,7 +244,9 @@ void AnnotatedDataLayer::load_batch(Batch* batch) { have_samples[item_id] = has_sampled; } } +#if !defined(_MSC_EXTENSIONS) #pragma omp taskwait +#endif // RNG needs to be reinitialized because in some cases, when transform params are not set // RNG is a NULL. this->data_transformer_->ReinitRand(); @@ -250,8 +254,9 @@ void AnnotatedDataLayer::load_batch(Batch* batch) { for (int item_id = 0; item_id < batch_size; ++item_id) { PreclcRandomNumbers precalculated_rand_numbers; this->data_transformer_->GenerateRandNumbers(precalculated_rand_numbers, /* sample_bboxes */ have_samples[item_id]); - +#if !defined(_MSC_EXTENSIONS) #pragma omp task firstprivate(precalculated_rand_numbers, item_id) shared(num_bboxes, all_anno, expand_data, sampled_bboxes, have_samples) +#endif { boost::shared_ptr sampled_datum; bool has_sampled = have_samples[item_id]; diff --git a/src/caffe/layers/batch_norm_layer.cpp b/src/caffe/layers/batch_norm_layer.cpp index 8331dd7d7..8588ae3f6 100644 --- a/src/caffe/layers/batch_norm_layer.cpp +++ b/src/caffe/layers/batch_norm_layer.cpp @@ -125,10 +125,14 @@ void BatchNormLayer::replicate(Dtype* buffer_to_write, unsigned int channel_offset_incr, const Dtype* data_to_be_replicated) { #ifdef _OPENMP - #pragma omp parallel for collapse(2) + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else + #pragma omp parallel for collapse(2) + #endif #endif - for (unsigned int j = 0; j< channels_; ++j) { - for (unsigned int n = 0; n < num_batches; ++n) { + for (int j = 0; j< channels_; ++j) { + for (int n = 0; n < num_batches; ++n) { caffe_set(channel_offset_incr, data_to_be_replicated[j], buffer_to_write + j * channel_offset_incr + n * batch_offset_incr); } @@ -144,14 +148,18 @@ void BatchNormLayer::replicate_to_op(Dtype* buffer_to_write, const Dtype* data_to_be_replicated, FuncTy op_func) { #ifdef _OPENMP - #pragma omp parallel for collapse(2) + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else + #pragma omp parallel for collapse(2) + #endif #endif - for (unsigned int j = 0; j< channels_; ++j) { - for (unsigned int n = 0; n < num_batches; ++n) { + for (int j = 0; j< channels_; ++j) { + for (int n = 0; n < num_batches; ++n) { Dtype value = data_to_be_replicated[j]; Dtype* buffer_offsetted = buffer_to_write + j * channel_offset_incr + n * batch_offset_incr; - for (unsigned int k = 0; k < channel_offset_incr; ++k) { + for (int k = 0; k < channel_offset_incr; ++k) { buffer_offsetted[k] = op_func(buffer_offsetted[k], value); } } diff --git a/src/caffe/layers/data_layer.cpp b/src/caffe/layers/data_layer.cpp index e889ca51f..5eaeb4dab 100644 --- a/src/caffe/layers/data_layer.cpp +++ b/src/caffe/layers/data_layer.cpp @@ -143,7 +143,9 @@ void DataLayer::load_batch(Batch* batch) { #ifdef _OPENMP PreclcRandomNumbers precalculated_rand_numbers; this->data_transformer_->GenerateRandNumbers(precalculated_rand_numbers); + #if !defined(_MSC_EXTENSIONS) #pragma omp task firstprivate(offset, precalculated_rand_numbers, data, item_id) + #endif #endif { Datum datum; diff --git a/src/caffe/layers/image_data_layer.cpp b/src/caffe/layers/image_data_layer.cpp index b4fd48468..746df6fd6 100644 --- a/src/caffe/layers/image_data_layer.cpp +++ b/src/caffe/layers/image_data_layer.cpp @@ -227,8 +227,10 @@ void ImageDataLayer::load_batch(Batch* batch) { std::string img_file_name = lines_[lines_id_].first; PreclcRandomNumbers precalculated_rand_numbers; this->data_transformer_->GenerateRandNumbers(precalculated_rand_numbers); + #if !defined(_MSC_EXTENSIONS) #pragma omp task firstprivate(offset, img_file_name, \ precalculated_rand_numbers) + #endif { cv::Mat cv_img = ReadImageToCVMat(root_folder + img_file_name, new_height, new_width, is_color); diff --git a/src/caffe/layers/lrn_layer.cpp b/src/caffe/layers/lrn_layer.cpp index 75ba4c347..ecb813e3f 100644 --- a/src/caffe/layers/lrn_layer.cpp +++ b/src/caffe/layers/lrn_layer.cpp @@ -168,7 +168,11 @@ void LRNLayer::CrossChannelForward_cpu( caffe_set(num_ * channels_ * height_ * width_, Dtype(k_), scale_data); #ifdef _OPENMP -#pragma omp parallel for collapse(2) + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else + #pragma omp parallel for collapse(2) + #endif #endif for (int n = 0; n < num_; n++) { for (int c = 0; c < channels_; c++) { diff --git a/src/caffe/layers/mkldnn_convolution_layer.cpp b/src/caffe/layers/mkldnn_convolution_layer.cpp index 81d7b86b4..b46235e04 100644 --- a/src/caffe/layers/mkldnn_convolution_layer.cpp +++ b/src/caffe/layers/mkldnn_convolution_layer.cpp @@ -43,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "caffe/filler.hpp" #include "caffe/layer.hpp" #include "caffe/layers/mkldnn_layers.hpp" -//#include "mkl_service.h" +#include "caffe/util/cpu_info.hpp" // TODO: Correct process case if there are no bias // TODO: Exception handling - mkl-dnn produces exceptions on errors @@ -140,10 +140,10 @@ void MKLDNNConvolutionLayer::init_properties(const vector*>& { conv_algorithm = algorithm::convolution_winograd; } - //else if(_conv_algorithm == "auto") - //{ - // conv_algorithm = algorithm::convolution_auto; - //} + else if(_conv_algorithm == "auto") + { + conv_algorithm = algorithm::convolution_auto; + } else { LOG(ERROR) << "Unsupported convolution algorithm."; @@ -483,7 +483,7 @@ void MKLDNNConvolutionLayer::InitConvolutionFwd(const vector* // --- init primitive and prv_memory descriptors ---------------------- if (this->need_quantize_){ - std::vector scale_bottom(1, this->scale_in_[0]); + std::vector scale_bottom(1, this->layer_param_.quantization_param().force_u8_input()? 1.0f : this->scale_in_[0] ); fwd_bottom_data.reset(new MKLDNNData(usr_bottom_data_memory_pd, prv_fwd_bottom_data_memory_pd, bottom[0], this, scale_bottom)); } else { fwd_bottom_data.reset(new MKLDNNData(usr_bottom_data_memory_pd, prv_fwd_bottom_data_memory_pd, bottom[0], this)); @@ -501,7 +501,13 @@ void MKLDNNConvolutionLayer::InitConvolutionFwd(const vector* fwd_top_data_memory = fwd_top_data->create_output_memory(); bool is_wino = (prv_fwd_weights_data_memory_pd->desc().data.format == memory::format::wino_fmt); + #ifdef _OPENMP + int node = caffe::cpu::OpenMpManager::getNumaNode(); + #else + int node = 0; + #endif if (fwd_weights_data == NULL) { + std::string name = "numa" + std::to_string(node) + "@fwd_weights_data@" + this->layer_param_.name(); if (this->need_quantize_){ int count = 1; //single channel int reorder_mask = 0; @@ -516,17 +522,18 @@ void MKLDNNConvolutionLayer::InitConvolutionFwd(const vector* for(int i=0; iscale_params_[i]; } - fwd_weights_data.reset(new MKLDNNData(usr_weights_data_memory_pd, prv_fwd_weights_data_memory_pd, this->blobs_[0].get(), this, scale_weight, reorder_mask, false, false, true)); + fwd_weights_data.reset(new MKLDNNData(usr_weights_data_memory_pd, prv_fwd_weights_data_memory_pd, this->blobs_[0].get(), this, scale_weight, reorder_mask, false, false, true, name)); } else{ - fwd_weights_data.reset(new MKLDNNData(usr_weights_data_memory_pd, prv_fwd_weights_data_memory_pd, this->blobs_[0].get(), this, {1.}, 0, is_sum, is_wino, true)); + fwd_weights_data.reset(new MKLDNNData(usr_weights_data_memory_pd, prv_fwd_weights_data_memory_pd, this->blobs_[0].get(), this, {1.}, 0, is_sum, is_wino, false, name)); } - fwd_weights_data->name = "fwd_weights_data @ " + this->layer_param_.name(); + fwd_weights_data->name.assign(name); fwd_weights_data_primitive = fwd_weights_data->create_input(true); } if (this->bias_term_) { if (fwd_bias_data == NULL) { shared_ptr prv_fwd_bias_data_memory_pd(new MemPD(convFwd_pd->bias_primitive_desc())); + std::string name = "numa" + std::to_string(node) + "@fwd_bias_data@" + this->layer_param_.name(); if (this->need_quantize_){ int count = 1; //single channel int reorder_mask = 0; @@ -544,11 +551,11 @@ void MKLDNNConvolutionLayer::InitConvolutionFwd(const vector* else scale_bias[i] = this->scale_in_[0] * this->scale_params_[i]; } - fwd_bias_data.reset(new MKLDNNData(usr_bias_data_memory_pd, prv_fwd_bias_data_memory_pd, this->blobs_[1].get(), this, scale_bias, reorder_mask, false, false, true)); + fwd_bias_data.reset(new MKLDNNData(usr_bias_data_memory_pd, prv_fwd_bias_data_memory_pd, this->blobs_[1].get(), this, scale_bias, reorder_mask, false, false, false, name)); } else{ - fwd_bias_data.reset(new MKLDNNData(usr_bias_data_memory_pd, prv_fwd_bias_data_memory_pd, this->blobs_[1].get(), this, {1.}, 0, false, false, true)); + fwd_bias_data.reset(new MKLDNNData(usr_bias_data_memory_pd, prv_fwd_bias_data_memory_pd, this->blobs_[1].get(), this, {1.}, 0, false, false, false, name)); } - fwd_bias_data->name = "fwd_bias_data @ " + this->layer_param_.name(); + fwd_bias_data->name.assign(name); fwd_bias_data_primitive = fwd_bias_data->create_input(true); } convFwd.reset(new convolution_forward(*convFwd_pd @@ -586,20 +593,19 @@ void MKLDNNConvolutionLayer::Forward_cpu(const vector*>& bott bool _mkldnn_primitive = false; if( convFwd_pd == NULL || this->reshape){ InitConvolutionFwd(bottom, top); - if(this->phase_ == TEST){ - fwd_weights_data->sync_before_read(); - if (this->bias_term_) - fwd_bias_data->sync_before_read(); - _mkldnn_primitive = true; - } + if(getenv("CAFFE_INFERENCE_MEM_OPT")){ + fwd_weights_data->sync_before_read(); + if (this->bias_term_) + fwd_bias_data->sync_before_read(); + _mkldnn_primitive = true; + } } - fwd_bottom_data->sync_before_read(); - if(this->phase_ != TEST){ + if(!getenv("CAFFE_INFERENCE_MEM_OPT")){ fwd_weights_data->sync_before_read(); if (this->bias_term_) fwd_bias_data->sync_before_read(); - } + } // update top that head at prv fwd_top_data->sync_before_write(); diff --git a/src/caffe/layers/mkldnn_inner_product_layer.cpp b/src/caffe/layers/mkldnn_inner_product_layer.cpp index 5f9aff809..651da5aa7 100644 --- a/src/caffe/layers/mkldnn_inner_product_layer.cpp +++ b/src/caffe/layers/mkldnn_inner_product_layer.cpp @@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "caffe/filler.hpp" #include "caffe/layer.hpp" #include "caffe/layers/mkldnn_layers.hpp" +#include "caffe/util/cpu_info.hpp" #if 0 #include "mkldnn_types.h" @@ -148,7 +149,9 @@ void MKLDNNInnerProductLayer::InitInnerProductFwd(const vector::value) NOT_IMPLEMENTED; auto propagation = this->phase_ == TEST ? prop_kind::forward_scoring : prop_kind::forward_training; + bool relu = this->layer_param_.inner_product_param().relu(); + Dtype negative_slope = 0; int32_t n = this->M_; int32_t w = this->w_; int32_t h = this->h_; @@ -179,25 +182,13 @@ void MKLDNNInnerProductLayer::InitInnerProductFwd(const vectorneed_quantize_) { - bool bottom_data_is_prv = (const_cast(bottom[0]->prv_data()) != NULL); - bool top_data_is_prv = (const_cast(top[0]->prv_data()) != NULL); - if (bottom_data_is_prv || top_data_is_prv) { - shared_ptr > mem_descr - = get_mkldnn_prv_descriptor(bottom[0]); - src_dt = static_cast(mem_descr->prv_memory_pd()->desc().data.data_type); - } - } - memory::data_type top_dt = memory::data_type::f32; + if (this->need_quantize_) { - if(this->bw_layer_in_ == 8 && src_dt == mkldnn::memory::data_type::s8) - src_dt = memory::data_type::u8; //mkldnn don't surpport s8 input by current version. + if(this->bw_layer_in_ == 8) + src_dt = this->layer_param_.quantization_param().is_negative_input() ? memory::data_type::s8 : memory::data_type::u8; if (this->bw_layer_out_ == 8) { - top_dt = memory::data_type::s8; //TODO: enable s8 / u8 output after mkldnn implementation - } - else { - top_dt = memory::data_type::f32; + top_dt = relu ? memory::data_type::u8 : memory::data_type::s8; } } @@ -231,6 +222,7 @@ void MKLDNNInnerProductLayer::InitInnerProductFwd(const vector scales(count); float scale; + #ifdef _OPENMP #pragma omp parallel for if (count > 1) #endif @@ -245,6 +237,16 @@ void MKLDNNInnerProductLayer::InitInnerProductFwd(const vectorlayer_param_.inner_product_param().negative_slope(); + ops.append_eltwise(scale, eltwise_relu, negative_slope, beta); + attr.set_post_ops(ops); + } + // ---- Determining engine to use ----------------------- std::string subengines = this->layer_param_.engine(); if (subengines.find("MKLDNN") == std::string::npos || subengines == "MKLDNN") @@ -254,11 +256,11 @@ void MKLDNNInnerProductLayer::InitInnerProductFwd(const vectorneed_quantize_){ + if(this->need_quantize_ || relu){ ipFwd_pd.reset(new inner_product_forward::primitive_desc(*ipFwd_desc, attr, ep.getMKLDNNSubEngine(subEngineIndex))); } else{ - ipFwd_pd.reset(new inner_product_forward::primitive_desc(*ipFwd_desc, + ipFwd_pd.reset(new inner_product_forward::primitive_desc(*ipFwd_desc, ep.getMKLDNNSubEngine(subEngineIndex))); } } @@ -305,6 +307,11 @@ void MKLDNNInnerProductLayer::InitInnerProductFwd(const vectorname = "fwd_top_data @ " + this->layer_param_.name(); fwd_top_data_memory = fwd_top_data->create_output_memory(); + #ifdef _OPENMP + int node = caffe::cpu::OpenMpManager::getNumaNode(); + #else + int node = 0; + #endif if (fwd_weights_data == NULL) { std::vector scale_weight(1); int reorder_mask = 0; @@ -325,8 +332,9 @@ void MKLDNNInnerProductLayer::InitInnerProductFwd(const vector(usr_weights_data_memory_pd, prv_fwd_weights_data_memory_pd, this->blobs_[0].get(), this, scale_weight, reorder_mask, false, false, true)); - fwd_weights_data->name = "fwd_weights_data @ " + this->layer_param_.name(); + std::string name = "numa" + std::to_string(node) + "@fwd_weights_data@" + this->layer_param_.name(); + fwd_weights_data.reset(new MKLDNNData(usr_weights_data_memory_pd, prv_fwd_weights_data_memory_pd, this->blobs_[0].get(), this, scale_weight, reorder_mask, false, false, false, name)); + fwd_weights_data->name.assign(name); fwd_weights_data_primitive = fwd_weights_data->create_input(true); } @@ -354,8 +362,9 @@ void MKLDNNInnerProductLayer::InitInnerProductFwd(const vector(usr_bias_data_memory_pd, prv_fwd_bias_data_memory_pd, this->blobs_[1].get(), this, scale_bias, reorder_mask, false, false, true)); - fwd_bias_data ->name = "fwd_bias_data @ " + this->layer_param_.name(); + std::string name = "numa" + std::to_string(node) + "@fwd_bias_data@" + this->layer_param_.name(); + fwd_bias_data.reset(new MKLDNNData(usr_bias_data_memory_pd, prv_fwd_bias_data_memory_pd, this->blobs_[1].get(), this, scale_bias, reorder_mask, false, false, false, name)); + fwd_bias_data->name.assign(name); fwd_bias_data_primitive = fwd_bias_data->create_input(true); } ipFwd.reset(new inner_product_forward(*ipFwd_pd @@ -400,7 +409,7 @@ void MKLDNNInnerProductLayer::Forward_cpu(const vector*>& bot bool _mkldnn_primitive = false; if( ipFwd_pd == NULL || this->reshape){ InitInnerProductFwd(bottom, top); - if(this->phase_ == TEST){ + if(getenv("CAFFE_INFERENCE_MEM_OPT")){ fwd_weights_data->sync_before_read(); if (this->bias_term_) fwd_bias_data->sync_before_read(); @@ -410,7 +419,7 @@ void MKLDNNInnerProductLayer::Forward_cpu(const vector*>& bot // making reorders if needed. fwd_bottom_data->sync_before_read(); // update top that head at prv - if(this->phase_ != TEST){ + if(!getenv("CAFFE_INFERENCE_MEM_OPT")){ fwd_weights_data->sync_before_read(); if (this->bias_term_) fwd_bias_data->sync_before_read(); diff --git a/src/caffe/layers/mkldnn_relu_layer.cpp b/src/caffe/layers/mkldnn_relu_layer.cpp index 362df62bd..69862ffa2 100644 --- a/src/caffe/layers/mkldnn_relu_layer.cpp +++ b/src/caffe/layers/mkldnn_relu_layer.cpp @@ -119,7 +119,7 @@ void MKLDNNReLULayer::InitReLUFwd(const vector*>& bottom, con top_data_mpd.reset(new memory::primitive_desc({dim, top_dt, src_mfmt}, cpu_engine)); // ---- Initialize relu primitive descriptor ------------- - //eltwise_forward::desc reluFwd_desc(propagation, *bottom_data_md, negative_slope); + //relu_forward::desc reluFwd_desc(propagation, *bottom_data_md, negative_slope); // MKLDNN is deprecating standalone relu primitive in MKL-DNN. // Now MKLDNN has eltwise primitive with eltwise_relu algorithm inside. eltwise_forward::desc eltwise_reluFwd_desc(propagation, eltwise_relu, *bottom_data_md, negative_slope); @@ -301,7 +301,7 @@ void MKLDNNReLULayer::InitReLUBwd(const vector*>& top bottom_diff_md = top_diff_md; // ---- Initialize relu primitive descriptor ------------- - //eltwise_backward::desc reluBwd_desc(*top_diff_md, *top_data_md, negative_slope); + //relu_backward::desc reluBwd_desc(*top_diff_md, *top_data_md, negative_slope); // MKLDNN is deprecating standalone relu primitive in MKL-DNN. // Now MKLDNN has eltwise primitive with eltwise_relu algorithm inside. eltwise_backward::desc eltwise_reluBwd_desc(eltwise_relu, *top_diff_md, *top_data_md, negative_slope); diff --git a/src/caffe/layers/pooling_layer.cpp b/src/caffe/layers/pooling_layer.cpp index 96613af14..84e13a0bd 100644 --- a/src/caffe/layers/pooling_layer.cpp +++ b/src/caffe/layers/pooling_layer.cpp @@ -398,7 +398,11 @@ void PoolingLayer::Forward_cpu(const vector*>& bottom, const int num_channels = bottom[0]->channels(); #ifdef _OPENMP - #pragma omp parallel for collapse(2) + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else + #pragma omp parallel for collapse(2) + #endif #endif for (int image = 0; image < batch_size; ++image) for (int channel = 0; channel < num_channels; ++channel) @@ -438,7 +442,11 @@ void PoolingLayer::Forward_cpu(const vector*>& bottom, caffe_set(top_count, Dtype(-FLT_MAX), top_data); #ifdef _OPENMP - #pragma omp parallel for collapse(2) + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else + #pragma omp parallel for collapse(2) + #endif #endif for (int n = 0; n < num_; ++n) { for (int c = 0; c < channels_; ++c) { @@ -492,7 +500,11 @@ void PoolingLayer::Forward_cpu(const vector*>& bottom, case PoolingParameter_PoolMethod_AVE: caffe_set(top_count, Dtype(0), top_data); #ifdef _OPENMP - #pragma omp parallel for collapse(2) + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else + #pragma omp parallel for collapse(2) + #endif #endif for (int n = 0; n < num_; ++n) { for (int c = 0; c < channels_; ++c) { @@ -581,7 +593,11 @@ void PoolingLayer::Backward_cpu(const vector*>& top, const int num_channels = bottom[0]->channels(); #ifdef _OPENMP - #pragma omp parallel for collapse(2) + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else + #pragma omp parallel for collapse(2) + #endif #endif for (int image = 0; image < batch_size; ++image) for (int channel = 0; channel < num_channels; ++channel) @@ -611,7 +627,11 @@ void PoolingLayer::Backward_cpu(const vector*>& top, switch (this->layer_param_.pooling_param().pool()) { case PoolingParameter_PoolMethod_MAX: #ifdef _OPENMP - #pragma omp parallel for collapse(2) + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else + #pragma omp parallel for collapse(2) + #endif #endif for (int n = 0; n < top_num; ++n) { for (int c = 0; c < channels_; ++c) { @@ -640,7 +660,11 @@ void PoolingLayer::Backward_cpu(const vector*>& top, break; case PoolingParameter_PoolMethod_AVE: #ifdef _OPENMP - #pragma omp parallel for collapse(2) + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else + #pragma omp parallel for collapse(2) + #endif #endif for (int n = 0; n < top_num; ++n) { for (int c = 0; c < channels_; ++c) { diff --git a/src/caffe/layers/prelu_layer.cpp b/src/caffe/layers/prelu_layer.cpp index 3e9a5f594..8c334e578 100644 --- a/src/caffe/layers/prelu_layer.cpp +++ b/src/caffe/layers/prelu_layer.cpp @@ -158,7 +158,7 @@ void PReLULayer::Backward_cpu(const vector*>& top, // openmp array reduction is supported from openmp 4.5. GCC 6.1 and later // fully support this feature. ICC less than 19.01 has bug on openmp array // reduction support, that's why we have ICC version check here. -#if !defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1900 +#if !defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1901 #if defined(_OPENMP) && _OPENMP >= 201511 long reduce = channel_shared_ ? 1 : channels; #pragma omp parallel for private(i) reduction(+: slope_diff[:reduce]) diff --git a/src/caffe/layers/reshape_layer.cpp b/src/caffe/layers/reshape_layer.cpp index 0a2e3329e..ba0edf2b9 100644 --- a/src/caffe/layers/reshape_layer.cpp +++ b/src/caffe/layers/reshape_layer.cpp @@ -181,7 +181,11 @@ void ReshapeLayer::Forward_cpu(const vector*>& bottom, Dtype* top_data = top[0]->mutable_cpu_data(); #ifdef _OPENMP - #pragma omp parallel for collapse(2) + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else + #pragma omp parallel for collapse(2) + #endif #endif for(int n = 0; n < bn; n++) { for(int c = 0; c < bc; c++) { @@ -224,7 +228,11 @@ void ReshapeLayer::Backward_cpu(const vector*>& top, const Dtype* top_diff = top[0]->cpu_diff(); #ifdef _OPENMP - #pragma omp parallel for collapse(2) + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else + #pragma omp parallel for collapse(2) + #endif #endif for(int n = 0; n < tn; n++) { for(int c = 0; c < tc; c++) { diff --git a/src/caffe/layers/smooth_L1_loss_ohem_layer.cpp b/src/caffe/layers/smooth_L1_loss_ohem_layer.cpp index 383f4ed6d..7b168f888 100644 --- a/src/caffe/layers/smooth_L1_loss_ohem_layer.cpp +++ b/src/caffe/layers/smooth_L1_loss_ohem_layer.cpp @@ -177,7 +177,11 @@ void SmoothL1LossOHEMLayer::Forward_cpu( // Output per-instance loss if (top.size() >= 2) { #ifdef _OPENMP -#pragma omp parallel for collapse(2) + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else + #pragma omp parallel for collapse(2) + #endif #endif for (int i = 0; i < outer_num_; ++i) { for (int j = 0; j < inner_num_; j++) { diff --git a/src/caffe/layers/softmax_layer.cpp b/src/caffe/layers/softmax_layer.cpp index 4e492b70d..1d34eed51 100644 --- a/src/caffe/layers/softmax_layer.cpp +++ b/src/caffe/layers/softmax_layer.cpp @@ -66,10 +66,13 @@ void SoftmaxLayer::Forward_cpu_fast_case( const vector*>& top) { int channels = bottom[0]->shape(softmax_axis_); int dim = bottom[0]->count() / outer_num_; - +#if defined(_MSC_EXTENSIONS) + const Dtype* __restrict bottom_ = bottom[0]->cpu_data(); + Dtype* __restrict top_ = top[0]->mutable_cpu_data(); +#else const Dtype* __restrict__ bottom_ = bottom[0]->cpu_data(); Dtype* __restrict__ top_ = top[0]->mutable_cpu_data(); - +#endif #ifdef _OPENMP #pragma omp parallel for #endif diff --git a/src/caffe/layers/spatial_dropout_layer.cpp b/src/caffe/layers/spatial_dropout_layer.cpp index ef79760f2..32116483e 100644 --- a/src/caffe/layers/spatial_dropout_layer.cpp +++ b/src/caffe/layers/spatial_dropout_layer.cpp @@ -77,7 +77,11 @@ void SpatialDropoutLayer::Forward_cpu(const vector*>& bottom, // Create random numbers caffe_rng_bernoulli(num * channel, 1. - threshold_, mask); #ifdef _OPENMP + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else #pragma omp parallel for collapse(2) + #endif #endif for (int i = 0; i < num; ++i) { for (int j = 0; j < channel; j++) { @@ -107,7 +111,11 @@ void SpatialDropoutLayer::Backward_cpu(const vector*>& top, if (this->phase_ == TRAIN) { const unsigned int* mask = rand_vec_.cpu_data(); #ifdef _OPENMP + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else #pragma omp parallel for collapse(2) + #endif #endif for (int i = 0; i < num; ++i) { for (int j = 0; j < channel; j++) { diff --git a/src/caffe/mkldnn_memory.cpp b/src/caffe/mkldnn_memory.cpp index 8a12f9f9e..7987db5a9 100644 --- a/src/caffe/mkldnn_memory.cpp +++ b/src/caffe/mkldnn_memory.cpp @@ -51,9 +51,9 @@ MKLDNNMemoryDescriptorBase::MKLDNNMemoryDescriptorBase(shared_ptr::MKLDNNMemoryDescriptorBase(shared_ptrset_scale(scale); this->set_sum(is_sum); this->_blob = blob; + this->name.assign(_name); } template @@ -110,6 +111,8 @@ void MKLDNNMemoryDescriptorBase::create_reorder_descriptors(std::vector( new reorder::primitive_desc(*_prv_memory_pd, *_usr_memory_pd, attri)); @@ -147,8 +150,9 @@ template , int mask , bool is_sum , bool is_wino - , bool is_weight) - : MKLDNNMemoryDescriptorBase(usr_memory_pd, prv_memory_pd, blob, mkldnn_layer, scale, mask, is_sum, is_wino, is_weight) + , bool is_weight + , std::string name) + : MKLDNNMemoryDescriptorBase(usr_memory_pd, prv_memory_pd, blob, mkldnn_layer, scale, mask, is_sum, is_wino, is_weight, name) { const Dtype* prv_ptr = is_diff ? blob->prv_diff() : blob->prv_data(); @@ -462,7 +466,7 @@ void MKLDNNMemoryDescriptor::sync_before_read() if (*blob_prv_mkldnn_mem_descr->prv_memory_pd() != *this->prv_memory_pd() || blob_prv_mkldnn_mem_descr->get_scale() != this->get_scale()) { // prv in blob and in this descrptor may have different layouts -#ifdef D +#ifdef DEBUG LOG(INFO) << "Convert from extprv"; #endif this->convert_from_extprv(blob_prv_mkldnn_mem_descr->aprimitive()); diff --git a/src/caffe/net.cpp b/src/caffe/net.cpp index 9676930ad..be20f20e0 100644 --- a/src/caffe/net.cpp +++ b/src/caffe/net.cpp @@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "hdf5.h" @@ -58,7 +59,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "caffe/util/performance.hpp" #include "caffe/util/upgrade_proto.hpp" -#include "caffe/test/test_caffe_main.hpp" #include "caffe/multinode/mlsl.hpp" #include "caffe/multinode/apply_mn_param.hpp" #include "caffe/util/remove_batch_norm.hpp" @@ -539,12 +539,13 @@ void Net::CompileNet(const NetParameter& param, #define COMPILE_BN_RELU_FUSION_INDEX 3 #define COMPILE_SPARSE_INDEX 5 #define COMPILE_CONV_SUM_FUSION_INDEX 6 + #define COMPILE_FC_RELU_FUSION_INDEX 7 int i, current = 0; NetParameter param_temp[2]; void (*CompileRules[]) (const NetParameter& param, NetParameter* param_compiled) = {RemoveBNScale, CompilationRuleRemoveScale, CompilationRuleConvReluFusion, CompilationRuleFuseBnRelu, CompilationRuleBNInplace, CompilationRuleSparse, - CompilationRuleConvSumFusion}; + CompilationRuleConvSumFusion, CompilationRuleFuseFCRelu}; bool disabled[NUM_OF_RULES] = {false}; @@ -563,6 +564,9 @@ void Net::CompileNet(const NetParameter& param, #ifdef DISABLE_SPARSE disabled[COMPILE_SPARSE_INDEX] = true; #endif +#ifdef DISABLE_FC_RELU_FUSION + disabled[COMPILE_FC_RELU_FUSION_INDEX] = true; +#endif param_temp[current].CopyFrom(param); for (i = 0; i < NUM_OF_RULES; i++) @@ -579,6 +583,7 @@ void Net::CompileNet(const NetParameter& param, #undef COMPILE_BN_RELU_FUSION_INDEX #undef COMPILE_SPARSE_INDEX #undef COMPILE_CONV_SUM_FUSION_INDEX + #undef COMPILE_FC_RELU_FUSION_INDEX } template @@ -1200,7 +1205,7 @@ void Net::CompilationRuleSparse(const NetParameter& param, template void Net::CompilationRuleFuseBnRelu(const NetParameter& param, NetParameter* param_compiled) { - std::set layers_to_drop; + std::set layers_to_drop; for (int i = 0; i < param.layer_size(); ++i) { LayerParameter* layer_param = (const_cast(param)).mutable_layer(i); @@ -1284,6 +1289,93 @@ void Net::CompilationRuleFuseBnRelu(const NetParameter& param, } } +template +void Net::CompilationRuleFuseFCRelu(const NetParameter& param, + NetParameter* param_compiled) { + std::set layers_to_drop; + for (int i = 0; i < param.layer_size(); ++i) { + LayerParameter* layer_param = + (const_cast(param)).mutable_layer(i); + bool layer_included = true; + + // Optimization rule 2: + // - If we are having engine MKLDNN and ReLU layer within a model + // and input bottom comes from InnerProduct of engine MKLDNN + // then we can remove ReLU layer + // and rename InnerProduct top blob after deleted ReLU's top + // Note: Currently merging of InnerProduct and relu layers is feasible + // If current layer is InnerProduct of MKLDNN engine.. + if ((layer_param->type().compare("InnerProduct") == 0) && + ((layer_param->convolution_param().engine() == ConvolutionParameter_Engine_MKLDNN) || + ((layer_param->convolution_param().engine() == ConvolutionParameter_Engine_DEFAULT) && + (layer_param->engine().compare(0, 6, "MKLDNN") == 0) && + (layer_param->engine().find(":DLA", 6) == string::npos)) || + ((layer_param->convolution_param().engine() == ConvolutionParameter_Engine_DEFAULT) && + (layer_param->engine() == "") && + (param.engine().compare(0, 6, "MKLDNN") == 0 && + param.engine().find(":DLA", 6) == string::npos)))) { + std::vector consumer_layer_params; + GetBlobConsumers(consumer_layer_params, layer_param->top(0), + param, i+1 < param.layer_size() ? i+1 : i); + const LayerParameter& consumer_layer_param = + consumer_layer_params.size() > 0 ? + *(consumer_layer_params[0]) : *layer_param; + + // Consumer layer of blob produced by Conv + // has to be ReLU layer with one Input Blob + if ((consumer_layer_param.type().compare("ReLU") == 0) && + ((consumer_layer_param.relu_param().engine() == ReLUParameter_Engine_MKLDNN) || + ((consumer_layer_param.relu_param().engine() == ReLUParameter_Engine_DEFAULT) && + (consumer_layer_param.engine().compare(0, 6, "MKLDNN") == 0 && + consumer_layer_param.engine().find(":DLA", 6) == string::npos)) || + ((consumer_layer_param.relu_param().engine() == ReLUParameter_Engine_DEFAULT) && + (consumer_layer_param.engine() == "") && + (param.engine().compare(0, 6, "MKLDNN") == 0 && + param.engine().find(":DLA", 6) == string::npos)))) { + string& convolution_top_blob_name = + const_cast(layer_param->top(0)); + + float negative_slope = + consumer_layer_param.relu_param().negative_slope(); + layer_param->mutable_inner_product_param()->set_relu(true); + layer_param->mutable_inner_product_param()->set_negative_slope(negative_slope); + if(param.state().phase() == TEST) { + const string& scale_top_blob_name = consumer_layer_param.top(0); + // Mark Consumer layer (its name) as the one marked for dropping + layers_to_drop.insert(consumer_layer_param.name()); + + // Replace Convolution top name with ReLU top name + convolution_top_blob_name.resize(scale_top_blob_name.size()); + convolution_top_blob_name.replace(0, + scale_top_blob_name.size(), + scale_top_blob_name); + } + if(param.state().phase() == TRAIN) { + if(i+1 < param.layer_size()) { + LayerParameter* relu_layer_param = + (const_cast(param)).mutable_layer(i+1); + relu_layer_param->mutable_relu_param()->set_fuse(true); + } + } + } + } + + if(param.state().phase() == TEST) { + if (layers_to_drop.find(layer_param->name()) != layers_to_drop.end()) { + LOG_IF(INFO, Caffe::root_solver()) << "Dropped layer: " + << layer_param->name() << std::endl; + layer_included = false; + // Remove dropped layer from the list of layers to be dropped + layers_to_drop.erase(layers_to_drop.find(layer_param->name())); + } + } + + if (layer_included) { + param_compiled->add_layer()->CopyFrom(*layer_param); + } + } +} + template void Net::GetBlobConsumers( std::vector& consumer_blobs, diff --git a/src/caffe/proto/caffe.proto b/src/caffe/proto/caffe.proto index 6dc0f4fa4..d04f9bf20 100755 --- a/src/caffe/proto/caffe.proto +++ b/src/caffe/proto/caffe.proto @@ -708,6 +708,7 @@ message QuantizationParameter{ repeated float scale_out = 21; repeated float scale_params = 22; optional bool is_negative_input = 23 [default = false]; + optional bool force_u8_input = 24 [default = false]; } message MnParamGradCompressParameter { @@ -756,6 +757,8 @@ message TransformationParameter { optional bool flow = 17 [default = false]; optional bool bgr2rgb = 18 [ default = false ]; + + optional uint32 pad = 19 [default = 0]; } message RandomResizeParameter { @@ -1478,6 +1481,9 @@ message InnerProductParameter { MKLDNN = 3; } optional Engine engine = 7 [default = DEFAULT]; + optional bool relu = 8 [default = false]; + optional float negative_slope = 9 [default = 0]; + } message InputParameter { diff --git a/src/caffe/solvers/sgd_solver.cpp b/src/caffe/solvers/sgd_solver.cpp index 193a0ab7f..31958630d 100644 --- a/src/caffe/solvers/sgd_solver.cpp +++ b/src/caffe/solvers/sgd_solver.cpp @@ -300,13 +300,15 @@ void SGDSolver::ApplyUpdate(int param_id) { LOG_PARAM_BLOB(this->net_->learnable_params()[param_id], diff, param_id, "ApplyUpdate: delwt after Normalize:"); - Regularize(param_id); - - LOG_PARAM_BLOB(this->net_->learnable_params()[param_id], diff, param_id, "ApplyUpdate: delwt after Regularize:"); + // In original intel-caffe code, only SGD(Not NESTEROV, ADAGRAD, RMSPROP, ADADELTA, ADAM) adapted LARS. So, we change only the flow of SGD. + // We execute Regularize process after GetLocalRate(LARS) when solver_type is "SGD". + if (strcmp(this->type(), "SGD")) { + Regularize(param_id); + LOG_PARAM_BLOB(this->net_->learnable_params()[param_id], diff, param_id, "ApplyUpdate: delwt after Regularize:"); + } ComputeUpdateValue(param_id, rate); - LOG_PARAM_BLOB(this->net_->learnable_params()[param_id], diff, param_id, "ApplyUpdate: wtinc:"); LOG_PARAM_BLOB(this->net_->learnable_params()[param_id], data, param_id, "ApplyUpdate: weight before update:"); @@ -413,7 +415,6 @@ void SGDSolver::SGDFusion(int param_id, Dtype rate) { //ComputeUpdateValue initialization Dtype momentum = this->param_.momentum(); - Dtype local_rate = rate * GetLocalRate(param_id); //#pragma endregion //#pragma region 2. Common condition judgement @@ -452,6 +453,8 @@ void SGDSolver::SGDFusion(int param_id, Dtype rate) { } } //#pragma endregion +//execute GetLocalRate after Normalize stage + Dtype local_rate = rate * GetLocalRate(param_id); //For most common topologies from BVLC, all skipped the Normalize stage, and use L2 regularization //If prv_diff_condition_flag == true, then prv_data_condition_flag == true (1) @@ -673,6 +676,9 @@ void SGDSolver::ComputeUpdateValue(int param_id, Dtype rate) { Dtype momentum = this->param_.momentum(); Dtype local_rate = rate * GetLocalRate(param_id); + Regularize(param_id); + LOG_PARAM_BLOB(this->net_->learnable_params()[param_id], diff, param_id, "ApplyUpdate: delwt after Regularize:"); + if (this->param_.warmup_iter() > 0 && this->iter_ < this->param_.warmup_iter()) { // Momentum correction during warmup stage diff --git a/src/caffe/test/test_engine_selection.cpp b/src/caffe/test/test_engine_selection.cpp index 3156efc89..131cd81e8 100644 --- a/src/caffe/test/test_engine_selection.cpp +++ b/src/caffe/test/test_engine_selection.cpp @@ -429,12 +429,6 @@ TYPED_TEST(TestEngineSelection, TestEngineParserNetMKLDNN) { dynamic_cast* >(relu1_layer); EXPECT_EQ(null_ptr, relu1_mkldnn); - // relu2 verification - Layer* relu2_layer = net->layer_by_name("relu2").get(); - MKLDNNReLULayer* relu2_mkldnn = - dynamic_cast* >(relu2_layer); - EXPECT_NE(null_ptr, relu2_mkldnn); - // pool1 verification Layer* pool1_layer = net->layer_by_name("pool1").get(); MKLDNNPoolingLayer* pool1_mkldnn = diff --git a/src/caffe/util/bbox_util.cpp b/src/caffe/util/bbox_util.cpp index 27f62bb42..886813d33 100644 --- a/src/caffe/util/bbox_util.cpp +++ b/src/caffe/util/bbox_util.cpp @@ -1634,7 +1634,11 @@ void GetLocPredictions(const Dtype* loc_data, const int num, } } #ifdef _OPENMP - #pragma omp parallel for collapse(3) + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else + #pragma omp parallel for collapse(3) + #endif #endif for (int i = 0; i < num; ++i) { for (int p = 0; p < num_preds_per_class; ++p) { @@ -1832,7 +1836,11 @@ void GetConfidenceScores(const Dtype* conf_data, const int num, conf_preds->resize(num); Dtype* buffer = new Dtype[num * num_preds_per_class * num_classes]; #ifdef _OPENMP - #pragma omp parallel for collapse(3) + #if defined(_MSC_EXTENSIONS) + #pragma omp parallel for + #else + #pragma omp parallel for collapse(3) + #endif #endif for (int i = 0; i < num; ++i) { for (int c = 0; c < num_classes; ++c) { @@ -2259,12 +2267,22 @@ void GetMaxScoreIndex(const vector& scores, const float threshold, const int top_k, vector >* score_index_vec) { // Generate index score pairs. #ifdef _OPENMP - #pragma omp parallel for + #pragma omp parallel #endif - for (int i = 0; i < scores.size(); ++i) { - if (scores[i] > threshold) { - score_index_vec->at(i) = std::make_pair(scores[i], i); + { + vector > prv; +#ifdef _OPENMP + #pragma omp for nowait +#endif + for (int i = 0; i < scores.size(); ++i) { + if (scores[i] > threshold) { + prv.push_back(std::make_pair(scores[i], i)); + } } +#ifdef _OPENMP + #pragma omp critical +#endif + score_index_vec->insert(score_index_vec->end(), prv.begin(), prv.end()); } // Sort the score pair according to the scores in descending order @@ -2424,7 +2442,7 @@ void ApplyNMSFast(const vector& bboxes, CHECK_EQ(bboxes.size(), scores.size()) << "bboxes and scores have different size."; // Get top_k scores (with corresponding indices). - vector > score_index_vec(scores.size()); + vector > score_index_vec; GetMaxScoreIndex(scores, score_threshold, top_k, &score_index_vec); // Do nms. float adaptive_threshold = nms_threshold; diff --git a/src/caffe/util/cpu_info.cpp b/src/caffe/util/cpu_info.cpp index 603000854..1652fd298 100644 --- a/src/caffe/util/cpu_info.cpp +++ b/src/caffe/util/cpu_info.cpp @@ -14,14 +14,14 @@ For the list of contributors go to https://github.com/BVLC/caffe/blob/master/CON Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Intel Corporation nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Intel Corporation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -44,6 +44,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "caffe/util/cpu_info.hpp" +#if defined(_MSC_EXTENSIONS) +#include +#pragma comment(lib, "Powrprof.lib") +#endif + namespace caffe { namespace cpu { @@ -54,10 +59,13 @@ Processor::Processor() { coreId = 0; cpuCores = 0; speedMHz = 0; + mask = 0; } CpuInfo::CpuInfo() { +#if !defined(_MSC_EXTENSIONS) loadContentFromFile("/proc/cpuinfo"); +#endif } CpuInfo::CpuInfo(const char *content) { @@ -87,7 +95,9 @@ void CpuInfo::loadContent(std::string &content) { } CpuInfo::~CpuInfo() { - delete [] fileContentBegin; +#if !defined(_MSC_EXTENSIONS) + delete[] fileContentBegin; +#endif } void CpuInfo::parseLines(char *content) { @@ -119,37 +129,131 @@ const char *CpuInfo::getNextLine() { return savedCurrentLine; } -Collection::Collection(CpuInfoInterface *cpuInfo) : cpuInfo(*cpuInfo) { - totalNumberOfSockets = 0; - totalNumberOfCpuCores = 0; - currentProcessor = NULL; - - processors.reserve(96); +#if defined(_MSC_EXTENSIONS) +typedef BOOL(WINAPI *LPFN_GLPI)( + LOGICAL_PROCESSOR_RELATIONSHIP, + PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, + PDWORD); + +typedef struct _PROCESSOR_POWER_INFORMATION { + ULONG Number; + ULONG MaxMhz; + ULONG CurrentMhz; + ULONG MhzLimit; + ULONG MaxIdleState; + ULONG CurrentIdleState; +} PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION; + +// Helper function to count set bits in the processor mask. +DWORD CountSetBits(ULONG_PTR bitMask) +{ + DWORD LSHIFT = sizeof(ULONG_PTR) * 8 - 1; + DWORD bitSetCount = 0; + ULONG_PTR bitTest = (ULONG_PTR)1 << LSHIFT; + DWORD i; + + for (i = 0; i <= LSHIFT; ++i) { + bitSetCount += ((bitMask & bitTest) ? 1 : 0); + bitTest /= 2; + } - parseCpuInfo(); - collectBasicCpuInformation(); + return bitSetCount; } -unsigned Collection::getProcessorSpeedMHz() { - return processors.size() ? processors[0].speedMHz : 0; -} +void Collection::parseCpuInfo() { + LPFN_GLPI glpi; + BOOL done = FALSE; + PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX buffer = NULL; + PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX ptr = NULL; + DWORD returnLength = 0; + DWORD logicalProcessorCount = 0; + DWORD numaNodeCount = 0; + DWORD processorCoreCount = 0; + DWORD processorPackageCount = 0; + DWORD byteOffset = 0; + + glpi = (LPFN_GLPI)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "GetLogicalProcessorInformationEx"); + if (NULL == glpi) { + _tprintf(TEXT("\nGetLogicalProcessorInformation is not supported.\n")); + return; + } -unsigned Collection::getTotalNumberOfSockets() { - return totalNumberOfSockets; -} + while (!done) { + DWORD rc = glpi(RelationAll, buffer, &returnLength); + if (FALSE == rc) { + if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { + if (buffer) + free(buffer); + buffer = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX)malloc(returnLength); + if (NULL == buffer) { + _tprintf(TEXT("\nError: Allocation failure\n")); + return; + } + } + else { + _tprintf(TEXT("\nError %d\n"), GetLastError()); + return; + } + } + else { + done = TRUE; + } + } -unsigned Collection::getTotalNumberOfCpuCores() { - return totalNumberOfCpuCores; -} + ptr = buffer; + while (byteOffset + sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) <= returnLength) { + switch (ptr->Relationship) { + case RelationNumaNode: + // Non-NUMA systems report a single record of this type. + numaNodeCount++; + break; + case RelationProcessorCore: + processorCoreCount++; + // A hyperthreaded core supplies more than one logical processor. + logicalProcessorCount += CountSetBits(ptr->Processor.GroupMask[0].Mask); + + for (unsigned size = 0; size < CountSetBits(ptr->Processor.GroupMask[0].Mask); size++) { + processors.push_back(Processor()); + Processor *processor = &processors.back(); + processor->processor = logicalProcessorCount - CountSetBits(ptr->Processor.GroupMask[0].Mask) + size; + processor->physicalId = ptr->Processor.GroupMask[0].Group; + processor->cpuCores = processorCoreCount - 1; + processor->mask = ptr->Processor.GroupMask[0].Mask; + } + break; + case RelationProcessorPackage: + // Logical processors share a physical package. + processorPackageCount++; + break; + default: + break; + } + byteOffset += ptr->Size; + ptr = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX)((LPBYTE)ptr + ptr->Size); + } + free(buffer); -unsigned Collection::getNumberOfProcessors() { - return processors.size(); -} + if (getNumberOfProcessors() == 0) { + _tprintf(TEXT("\nError: Get Processor Info fails\n")); + return; + } + DWORD dwSize = sizeof(PROCESSOR_POWER_INFORMATION) * getNumberOfProcessors(); + PPROCESSOR_POWER_INFORMATION powerInfo = NULL; -const Processor &Collection::getProcessor(unsigned processorId) { - return processors[processorId]; -} + powerInfo = (PPROCESSOR_POWER_INFORMATION)malloc(dwSize); + if (NULL == powerInfo) { + _tprintf(TEXT("\nError: Allocation PowerInfo failure\n")); + return; + } + while (!CallNtPowerInformation(ProcessorInformation, NULL, 0, powerInfo, dwSize)) { + processors[0].speedMHz = powerInfo->MaxMhz; + free(powerInfo); + return; + } + return; +} +#else void Collection::parseCpuInfo() { const char *cpuInfoLine = cpuInfo.getFirstLine(); for (; cpuInfoLine; cpuInfoLine = cpuInfo.getNextLine()) { @@ -162,7 +266,8 @@ void Collection::parseCpuInfoLine(const char *cpuInfoLine) { if (cpuInfoLine[delimiterPosition] == '\0') { currentProcessor = NULL; - } else { + } + else { parseValue(cpuInfoLine, &cpuInfoLine[delimiterPosition + 2]); } } @@ -237,10 +342,30 @@ unsigned Collection::extractSpeedFromModelName(const char *text) const { if (isGHz || (isGHzPossible && !isMHz)) { return 1000 * speed + 0.5; - } else { + } + else { return speed + 0.5; } } +#endif +Collection::Collection(CpuInfoInterface *cpuInfo) : cpuInfo(*cpuInfo) { + totalNumberOfSockets = 0; + totalNumberOfCpuCores = 0; + currentProcessor = NULL; + + processors.reserve(96); + + parseCpuInfo(); + collectBasicCpuInformation(); +} + +unsigned Collection::getNumberOfProcessors() { + return processors.size(); +} + +const Processor &Collection::getProcessor(unsigned processorId) { + return processors[processorId]; +} void Collection::collectBasicCpuInformation() { std::set uniquePhysicalId; @@ -252,15 +377,31 @@ void Collection::collectBasicCpuInformation() { } void Collection::updateCpuInformation(const Processor &processor, - unsigned numberOfUniquePhysicalId) { + unsigned numberOfUniquePhysicalId) { +#if !defined(_MSC_EXTENSIONS) if (totalNumberOfSockets == numberOfUniquePhysicalId) { return; } - +#endif totalNumberOfSockets = numberOfUniquePhysicalId; +#if !defined(_MSC_EXTENSIONS) totalNumberOfCpuCores += processor.cpuCores; +#else + totalNumberOfCpuCores = processor.cpuCores + 1; +#endif +} + +unsigned Collection::getTotalNumberOfSockets() { + return totalNumberOfSockets; +} + +unsigned Collection::getTotalNumberOfCpuCores() { + return totalNumberOfCpuCores; } +unsigned Collection::getProcessorSpeedMHz() { + return processors.size() ? processors[0].speedMHz : 0; +} #ifdef _OPENMP /* The OpenMpManager class is responsible for determining a set of all of @@ -272,7 +413,6 @@ void Collection::updateCpuInformation(const Processor &processor, be limited by system eg. when numactl was used. */ #include -#include static const char *openMpEnvVars[] = { "OMP_CANCELLATION", "OMP_DISPLAY_ENV", "OMP_DEFAULT_DEVICE", "OMP_DYNAMIC", @@ -290,8 +430,8 @@ static const unsigned numberOfOpenMpEnvVars = sizeof(openMpEnvVars) / sizeof(openMpEnvVars[0]); OpenMpManager::OpenMpManager(Collection *collection) : - mainThreadId(boost::this_thread::get_id()), - collection(*collection) { + mainThreadId(boost::this_thread::get_id()), + collection(*collection) { getOpenMpEnvVars(); getCurrentCpuSet(); getCurrentCoreSet(); @@ -324,7 +464,15 @@ bool OpenMpManager::isMajorThread(boost::thread::id currentThread) { void OpenMpManager::bindCurrentThreadToNonPrimaryCoreIfPossible() { OpenMpManager &openMpManager = getInstance(); if (openMpManager.isThreadsBindAllowed()) { +#if defined(_MSC_EXTENSIONS) + int totalNumberOfAvailableCores = 0; + totalNumberOfAvailableCores += CountSetBits(openMpManager.currentCoreSet.Mask[0]); + totalNumberOfAvailableCores += CountSetBits(openMpManager.currentCoreSet.Mask[1]); + totalNumberOfAvailableCores += CountSetBits(openMpManager.currentCoreSet.Mask[2]); + totalNumberOfAvailableCores += CountSetBits(openMpManager.currentCoreSet.Mask[3]); +#else int totalNumberOfAvailableCores = CPU_COUNT(&openMpManager.currentCoreSet); +#endif int logicalCoreToBindTo = totalNumberOfAvailableCores > 1 ? 1 : 0; openMpManager.bindCurrentThreadToLogicalCoreCpus(logicalCoreToBindTo); } @@ -337,7 +485,7 @@ void OpenMpManager::bindOpenMpThreads() { return; openMpManager.setOpenMpThreadNumberLimit(); - #pragma omp parallel +#pragma omp parallel { unsigned logicalCoreId = omp_get_thread_num(); openMpManager.bindCurrentThreadToLogicalCoreCpu(logicalCoreId); @@ -354,17 +502,32 @@ void OpenMpManager::getOpenMpEnvVars() { } void OpenMpManager::getCurrentCpuSet() { +#if defined(_MSC_EXTENSIONS) + // unlike linux, the thread group affinity of windows is by default only allowed on the + // physical cores of one socket. + // To get the same behavior of linux, we have to avoid using GetThreadGroupAffinity() here + getDefaultCpuSet(¤tCpuSet); +#else if (sched_getaffinity(0, sizeof(currentCpuSet), ¤tCpuSet)) { getDefaultCpuSet(¤tCpuSet); } +#endif } void OpenMpManager::getDefaultCpuSet(cpu_set_t *defaultCpuSet) { +#if defined(_MSC_EXTENSIONS) + ZeroMemory(defaultCpuSet, sizeof(cpu_set_t)); + unsigned numberOfProcessors = collection.getNumberOfProcessors(); + for (unsigned processorId = 0; processorId < numberOfProcessors; processorId++) { + defaultCpuSet->Mask[collection.getProcessor(processorId).physicalId] |= collection.getProcessor(processorId).mask; + } +#else CPU_ZERO(defaultCpuSet); unsigned numberOfProcessors = collection.getNumberOfProcessors(); for (int processorId = 0; processorId < numberOfProcessors; processorId++) { CPU_SET(processorId, defaultCpuSet); } +#endif } /* Function getCurrentCoreSet() fills currentCoreSet variable with a set of @@ -376,6 +539,25 @@ void OpenMpManager::getCurrentCoreSet() { unsigned numberOfProcessors = collection.getNumberOfProcessors(); unsigned totalNumberOfCpuCores = collection.getTotalNumberOfCpuCores(); +#if defined(_MSC_EXTENSIONS) + CopyMemory(¤tCoreSet, ¤tCpuSet, sizeof(cpu_set_t)); + + int percore = numberOfProcessors / totalNumberOfCpuCores; + for (int idx = 0; idx < sizeof(cpu_set_t) / sizeof(size_t); idx++) { + size_t *mask = ¤tCoreSet.Mask[idx]; + size_t bit_mask = (pow(2, percore) - 1); + size_t bit_value = 1; + + for (int bit_idx = 0; bit_idx < sizeof(size_t) * 8 / percore; bit_idx++) { + if ((*mask) & bit_mask) { + *mask &= ~bit_mask; + *mask |= bit_value; + } + bit_mask <<= percore; + bit_value <<= percore; + } + } +#else cpu_set_t usedCoreSet; CPU_ZERO(&usedCoreSet); CPU_ZERO(¤tCoreSet); @@ -389,12 +571,14 @@ void OpenMpManager::getCurrentCoreSet() { } } } +#endif } void OpenMpManager::selectAllCoreCpus(cpu_set_t *set, unsigned physicalCoreId) { unsigned numberOfProcessors = collection.getNumberOfProcessors(); unsigned totalNumberOfCpuCores = collection.getTotalNumberOfCpuCores(); +#if !defined(_MSC_EXTENSIONS) int processorId = physicalCoreId % totalNumberOfCpuCores; while (processorId < numberOfProcessors) { if (CPU_ISSET(processorId, ¤tCpuSet)) { @@ -403,11 +587,29 @@ void OpenMpManager::selectAllCoreCpus(cpu_set_t *set, unsigned physicalCoreId) { processorId += totalNumberOfCpuCores; } +#endif } unsigned OpenMpManager::getPhysicalCoreId(unsigned logicalCoreId) { +#if defined(_MSC_EXTENSIONS) + size_t mask = 0; + int processorId = 0; + int persocket = collection.getNumberOfProcessors() / collection.getTotalNumberOfSockets(); + do { + for (int idx = 0; idx < sizeof(cpu_set_t) / sizeof(size_t); idx++) { + mask = currentCoreSet.Mask[idx]; + for (int bit = 0; bit < persocket; bit++) { + if ((mask >> bit) & 0x1) { + if (!logicalCoreId--) { + return processorId; + } + } + processorId++; + } + } + } while (logicalCoreId); +#else unsigned numberOfProcessors = collection.getNumberOfProcessors(); - for (int processorId = 0; processorId < numberOfProcessors; processorId++) { if (CPU_ISSET(processorId, ¤tCoreSet)) { if (!logicalCoreId--) { @@ -415,7 +617,7 @@ unsigned OpenMpManager::getPhysicalCoreId(unsigned logicalCoreId) { } } } - +#endif LOG(FATAL) << "This should never happen!"; return 0; } @@ -426,25 +628,56 @@ bool OpenMpManager::isThreadsBindAllowed() { // Limit of threads to number of logical cores available void OpenMpManager::setOpenMpThreadNumberLimit() { +#if defined(_MSC_EXTENSIONS) + unsigned short num = 0; + for (int idx = 0; idx < sizeof(cpu_set_t) / sizeof(size_t); idx++) { + num += CountSetBits(currentCoreSet.Mask[idx]); + } + omp_set_num_threads(collection.getTotalNumberOfCpuCores()); +#else omp_set_num_threads(CPU_COUNT(¤tCoreSet)); +#endif } void OpenMpManager::bindCurrentThreadToLogicalCoreCpu(unsigned logicalCoreId) { +#if defined(_MSC_EXTENSIONS) + HANDLE handle = GetCurrentThread(); + GROUP_AFFINITY groupAffinity; + ZeroMemory(&groupAffinity, sizeof(GROUP_AFFINITY)); + unsigned physicalCoreId = getPhysicalCoreId(logicalCoreId); + int persocket = collection.getNumberOfProcessors() / collection.getTotalNumberOfSockets(); + groupAffinity.Mask = 1ull << (physicalCoreId % persocket); + groupAffinity.Group = physicalCoreId / persocket; +#pragma omp critical + SetThreadGroupAffinity(handle, &groupAffinity, NULL); +#else unsigned physicalCoreId = getPhysicalCoreId(logicalCoreId); cpu_set_t set; CPU_ZERO(&set); CPU_SET(physicalCoreId, &set); sched_setaffinity(0, sizeof(set), &set); +#endif } void OpenMpManager::bindCurrentThreadToLogicalCoreCpus(unsigned logicalCoreId) { +#if defined(_MSC_EXTENSIONS) + HANDLE handle = GetCurrentThread(); + GROUP_AFFINITY groupAffinity; + ZeroMemory(&groupAffinity, sizeof(GROUP_AFFINITY)); + unsigned physicalCoreId = getPhysicalCoreId(logicalCoreId); + int persocket = collection.getNumberOfProcessors() / collection.getTotalNumberOfSockets(); + int percore = collection.getNumberOfProcessors() / collection.getTotalNumberOfCpuCores(); + groupAffinity.Mask = (size_t)(pow(2, percore) - 1) << (physicalCoreId % persocket); + groupAffinity.Group = physicalCoreId / persocket; + SetThreadGroupAffinity(handle, &groupAffinity, NULL); +#else unsigned physicalCoreId = getPhysicalCoreId(logicalCoreId); - cpu_set_t set; CPU_ZERO(&set); selectAllCoreCpus(&set, physicalCoreId); sched_setaffinity(0, sizeof(set), &set); +#endif } void OpenMpManager::printVerboseInformation() { @@ -480,6 +713,22 @@ unsigned OpenMpManager::getProcessorSpeedMHz() { return openMpManager.collection.getProcessorSpeedMHz(); } +unsigned OpenMpManager::getNumaNode() { +#if defined(_MSC_EXTENSIONS) + PROCESSOR_NUMBER num; + USHORT node; + BOOL success; + GetCurrentProcessorNumberEx(&num); + success = GetNumaProcessorNodeEx(&num, &node); + assert(success != 0); + return node; +#else + OpenMpManager &openMpManager = getInstance(); + int cpu = sched_getcpu(); + assert(cpu >= 0); + return openMpManager.collection.getProcessor(cpu).physicalId; +#endif +} #endif // _OPENMP } // namespace cpu diff --git a/src/caffe/util/db_lmdb.cpp b/src/caffe/util/db_lmdb.cpp index 9d2e11340..00029dafe 100644 --- a/src/caffe/util/db_lmdb.cpp +++ b/src/caffe/util/db_lmdb.cpp @@ -42,6 +42,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#if defined(_MSC_EXTENSIONS) +#include +#define mkdir(str, ...) _mkdir(str) +#endif + namespace caffe { namespace db { void LMDB::Open(const string& source, Mode mode) { diff --git a/src/caffe/util/hdf5.cpp b/src/caffe/util/hdf5.cpp index 63de1dce1..9b2b8a1f2 100644 --- a/src/caffe/util/hdf5.cpp +++ b/src/caffe/util/hdf5.cpp @@ -66,31 +66,40 @@ void hdf5_load_nd_dataset_helper( CHECK_GE(status, 0) << "Failed to get dataset info for " << dataset_name_; switch (class_) { case H5T_FLOAT: - LOG_FIRST_N(INFO, 1) << "Datatype class: H5T_FLOAT"; + {LOG_FIRST_N(INFO, 1) << "Datatype class: H5T_FLOAT";} break; case H5T_INTEGER: - LOG_FIRST_N(INFO, 1) << "Datatype class: H5T_INTEGER"; + {LOG_FIRST_N(INFO, 1) << "Datatype class: H5T_INTEGER";} break; case H5T_TIME: LOG(FATAL) << "Unsupported datatype class: H5T_TIME"; + break; case H5T_STRING: LOG(FATAL) << "Unsupported datatype class: H5T_STRING"; + break; case H5T_BITFIELD: LOG(FATAL) << "Unsupported datatype class: H5T_BITFIELD"; + break; case H5T_OPAQUE: LOG(FATAL) << "Unsupported datatype class: H5T_OPAQUE"; + break; case H5T_COMPOUND: LOG(FATAL) << "Unsupported datatype class: H5T_COMPOUND"; + break; case H5T_REFERENCE: LOG(FATAL) << "Unsupported datatype class: H5T_REFERENCE"; + break; case H5T_ENUM: LOG(FATAL) << "Unsupported datatype class: H5T_ENUM"; case H5T_VLEN: LOG(FATAL) << "Unsupported datatype class: H5T_VLEN"; + break; case H5T_ARRAY: LOG(FATAL) << "Unsupported datatype class: H5T_ARRAY"; + break; default: LOG(FATAL) << "Datatype class unknown"; + break; } vector blob_dims(dims.size()); diff --git a/src/caffe/util/io.cpp b/src/caffe/util/io.cpp index ba70dc744..fa06d64f6 100644 --- a/src/caffe/util/io.cpp +++ b/src/caffe/util/io.cpp @@ -59,7 +59,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include - +#if defined(_MSC_EXTENSIONS) +#include +#endif #include "caffe/common.hpp" #include "caffe/proto/caffe.pb.h" #include "caffe/util/io.hpp" @@ -78,25 +80,45 @@ using google::protobuf::io::CodedOutputStream; using google::protobuf::Message; bool ReadProtoFromTextFile(const char* filename, Message* proto) { +#if defined(_MSC_EXTENSIONS) + int fd = _open(filename, O_RDONLY); +#else int fd = open(filename, O_RDONLY); +#endif CHECK_NE(fd, -1) << "File not found: " << filename; FileInputStream* input = new FileInputStream(fd); bool success = google::protobuf::TextFormat::Parse(input, proto); delete input; +#if defined(_MSC_EXTENSIONS) + _close(fd); +#else close(fd); +#endif return success; } void WriteProtoToTextFile(const Message& proto, const char* filename) { +#if defined(_MSC_EXTENSIONS) + int fd = _open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); +#else int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); +#endif FileOutputStream* output = new FileOutputStream(fd); CHECK(google::protobuf::TextFormat::Print(proto, output)); delete output; +#if defined(_MSC_EXTENSIONS) + _close(fd); +#else close(fd); +#endif } bool ReadProtoFromBinaryFile(const char* filename, Message* proto) { +#if defined(_MSC_EXTENSIONS) + int fd = _open(filename, O_RDONLY); +#else int fd = open(filename, O_RDONLY); +#endif CHECK_NE(fd, -1) << "File not found: " << filename; ZeroCopyInputStream* raw_input = new FileInputStream(fd); CodedInputStream* coded_input = new CodedInputStream(raw_input); @@ -106,7 +128,11 @@ bool ReadProtoFromBinaryFile(const char* filename, Message* proto) { delete coded_input; delete raw_input; +#if defined(_MSC_EXTENSIONS) + _close(fd); +#else close(fd); +#endif return success; } diff --git a/src/caffe/util/math_functions.cpp b/src/caffe/util/math_functions.cpp index 3052c09a2..457159a1d 100644 --- a/src/caffe/util/math_functions.cpp +++ b/src/caffe/util/math_functions.cpp @@ -126,7 +126,7 @@ void caffe_set(const size_t N, const Dtype alpha, Dtype* Y) { if (run_parallel) { #pragma omp parallel for - for (size_t i = 0; i < N; ++i) { + for (long long i = 0; i < N; ++i) { Y[i] = alpha; } @@ -179,7 +179,7 @@ void caffe_cpu_copy(const size_t N, const Dtype* X, Dtype* Y) { const int block_mem_size = 256 * 1024; const int block_size = block_mem_size / sizeof(Dtype); #pragma omp parallel for - for (size_t i = 0; i < N; i += block_size) + for (long long i = 0; i < N; i += block_size) memcpy(Y + i, X + i, (i + block_size > N) ? (N - i) * sizeof(Dtype) : block_mem_size); diff --git a/src/caffe/util/signal_handler.cpp b/src/caffe/util/signal_handler.cpp index 8be5fa79a..112209e02 100644 --- a/src/caffe/util/signal_handler.cpp +++ b/src/caffe/util/signal_handler.cpp @@ -50,9 +50,15 @@ namespace { void handle_signal(int signal) { switch (signal) { +#ifdef _MSC_EXTENSIONS + case SIGBREAK: // there is no SIGHUP in windows, take SIGBREAK instead. + got_sighup = true; + break; +#else case SIGHUP: got_sighup = true; break; +#endif case SIGINT: got_sigint = true; break; @@ -64,7 +70,14 @@ namespace { LOG(FATAL) << "Tried to hookup signal handlers more than once."; } already_hooked_up = true; - +#ifdef _MSC_EXTENSIONS + if (signal(SIGBREAK, handle_signal) == SIG_ERR) { + LOG(FATAL) << "Cannot install SIGBREAK handler."; + } + if (signal(SIGINT, handle_signal) == SIG_ERR) { + LOG(FATAL) << "Cannot install SIGINT handler."; + } +#else struct sigaction sa; // Setup the handler sa.sa_handler = &handle_signal; @@ -79,11 +92,20 @@ namespace { if (sigaction(SIGINT, &sa, NULL) == -1) { LOG(FATAL) << "Cannot install SIGINT handler."; } +#endif } // Set the signal handlers to the default. void UnhookHandler() { if (already_hooked_up) { +#ifdef _MSC_EXTENSIONS + if (signal(SIGBREAK, SIG_DFL) == SIG_ERR) { + LOG(FATAL) << "Cannot uninstall SIGBREAK handler."; + } + if (signal(SIGINT, SIG_DFL) == SIG_ERR) { + LOG(FATAL) << "Cannot uninstall SIGINT handler."; + } +#else struct sigaction sa; // Setup the sighub handler sa.sa_handler = SIG_DFL; @@ -98,7 +120,7 @@ namespace { if (sigaction(SIGINT, &sa, NULL) == -1) { LOG(FATAL) << "Cannot uninstall SIGINT handler."; } - +#endif already_hooked_up = false; } } diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 02fbd5cad..401aa8a20 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -12,9 +12,11 @@ foreach(source ${srcs}) # target add_executable(${name} ${source}) - target_link_libraries(${name} ${Caffe_LINK}) + target_link_libraries(${name} PRIVATE ${Caffe_LINK}) caffe_default_properties(${name}) - + if(MSVC) + set_target_properties(${name} PROPERTIES LINK_FLAGS "/WHOLEARCHIVE:${Caffe_LINK}") + endif() # set back RUNTIME_OUTPUT_DIRECTORY caffe_set_runtime_directory(${name} "${PROJECT_BINARY_DIR}/tools") caffe_set_solution_folder(${name} tools) @@ -22,6 +24,11 @@ foreach(source ${srcs}) # restore output name without suffix if(name MATCHES "caffe.bin") set_target_properties(${name} PROPERTIES OUTPUT_NAME caffe) + if(MSVC) + # the exectuable will have an import library with the same name as the caffe lib + # so change the import library to avoid name clashes + set_target_properties(${name} PROPERTIES IMPORT_SUFFIX ".bin.lib") + endif() endif() # Install