Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix windows build fails #321

Merged
merged 2 commits into from
Mar 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,21 @@ if(NCNN_OPENMP)
endif()
endif()

add_definitions(-Wall -Wextra -Wno-unused-function)
if(WIN32)
add_definitions(-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
else()
add_definitions(-Wall -Wextra -Wno-unused-function)

add_definitions(-fPIC)
add_definitions(-Ofast)
add_definitions(-fPIC)
add_definitions(-Ofast)

add_definitions(-ffast-math)
# add_definitions(-march=native)
add_definitions(-ffast-math)
# add_definitions(-march=native)

# add_definitions(-flto)
# add_definitions(-flto)

add_definitions(-fvisibility=hidden -fvisibility-inlines-hidden)
add_definitions(-fvisibility=hidden -fvisibility-inlines-hidden)
endif()

if(ANDROID)
# disable shared library on android
Expand Down
16 changes: 8 additions & 8 deletions src/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.

#include "benchmark.h"

#if NCNN_BENCHMARK
#include <stdio.h>
#include "layer/convolution.h"
#endif // NCNN_BENCHMARK

#ifdef _WIN32

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <stdint.h> // portable: uint64_t MSVC: __int64
#else // _WIN32
#include <sys/time.h>
#endif // _WIN32

#include "benchmark.h"

#if NCNN_BENCHMARK
#include <stdio.h>
#include "layer/convolution.h"
#endif // NCNN_BENCHMARK


namespace ncnn {

#ifdef _WIN32
Expand Down
4 changes: 4 additions & 0 deletions src/layer/convolutiondepthwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ int ConvolutionDepthWise::forward(const Mat& bottom_blob, Mat& top_blob) const
const int channels_g = channels / group;
const int num_output_g = num_output / group;

#ifdef _WIN32
#pragma omp parallel for
#else // _WIN32
#pragma omp parallel for collapse(2)
#endif // _WIN32
for (int g=0; g<group; g++)
{
for (int p=0; p<num_output_g; p++)
Expand Down
16 changes: 9 additions & 7 deletions tools/caffe/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

find_package(Protobuf REQUIRED)

include_directories(${PROTOBUF_INCLUDE_DIR})
if(PROTOBUF_FOUND)
include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
protobuf_generate_cpp(CAFFE_PROTO_SRCS CAFFE_PROTO_HDRS caffe.proto)
add_executable(caffe2ncnn caffe2ncnn.cpp ${CAFFE_PROTO_SRCS} ${CAFFE_PROTO_HDRS})
target_link_libraries(caffe2ncnn ${PROTOBUF_LIBRARIES})
else()
MESSAGE(WARNING "Protobuf not found, caffe model convert tools won't build")
endif()

include_directories(${CMAKE_CURRENT_BINARY_DIR})
protobuf_generate_cpp(CAFFE_PROTO_SRCS CAFFE_PROTO_HDRS caffe.proto)

add_executable(caffe2ncnn caffe2ncnn.cpp ${CAFFE_PROTO_SRCS} ${CAFFE_PROTO_HDRS})

target_link_libraries(caffe2ncnn ${PROTOBUF_LIBRARIES})