mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
windows build: getting there
Summary: This clears up a bunch of windows build errors, but there are still 12 errors mostly relating to - template keywords - initializer list - pthreadpool that are not readily available on windows. Also, cuda build is being disabled right now. Current error can be found here: https://ci.appveyor.com/project/Yangqing/caffe2-w2ucm Closes https://github.com/caffe2/caffe2/pull/151 Reviewed By: bwasti Differential Revision: D4564591 Pulled By: Yangqing fbshipit-source-id: adacad5fa2d6d52d586700947972e3674e3b6e60
This commit is contained in:
committed by
Facebook Github Bot
parent
81d932b161
commit
c7c4b00a50
@ -82,8 +82,10 @@ endif()
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "binaries")
|
||||
|
||||
# ---[ Build flags
|
||||
if (WIN32)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
||||
message(WARNING "Develop note: when all errors are addressed, turn on warning.")
|
||||
message(STATUS "Adding no warning argument to the compiler")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing")
|
||||
|
@ -15,6 +15,12 @@
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace caffe2 {
|
||||
|
||||
// Data type for caffe2 Index/Size. We use size_t to be safe here as well as for
|
||||
|
@ -6,9 +6,14 @@
|
||||
#endif // _OPENMP
|
||||
|
||||
// Macro to abstract out basic omp parallel loops
|
||||
// Note(jiayq): it seems that VS2015 does not support _Pragma yet, so we
|
||||
// disable it here.
|
||||
#ifdef _OPENMP
|
||||
#if defined(_MSC_VER)
|
||||
#define CAFFE2_OMP_PARALLEL_FOR() __pragma("omp parallel for")
|
||||
#else
|
||||
#define CAFFE2_OMP_PARALLEL_FOR() _Pragma("omp parallel for")
|
||||
// _Pragma( STRINGIFY( CONCATENATE( omp parallel for ) ) )
|
||||
#endif // _MSC_VER
|
||||
#else
|
||||
// empty macro, do nothing
|
||||
#define CAFFE2_OMP_PARALLEL_FOR()
|
||||
|
@ -35,15 +35,15 @@ class OperatorBase {
|
||||
// argument name to a specific type of argument that we are trying to access.
|
||||
template <typename T>
|
||||
inline T GetSingleArgument(const string& name, const T& default_value) const {
|
||||
return arg_helper_.GetSingleArgument<T>(name, default_value);
|
||||
return arg_helper_.template GetSingleArgument<T>(name, default_value);
|
||||
}
|
||||
template <typename T>
|
||||
inline bool HasSingleArgumentOfType(const string& name) const {
|
||||
return arg_helper_.HasSingleArgumentOfType<T>(name);
|
||||
return arg_helper_.template HasSingleArgumentOfType<T>(name);
|
||||
}
|
||||
template <typename T>
|
||||
inline vector<T> GetRepeatedArgument(const string& name) const {
|
||||
return arg_helper_.GetRepeatedArgument<T>(name);
|
||||
return arg_helper_.template GetRepeatedArgument<T>(name);
|
||||
}
|
||||
|
||||
// Get the inputs and outputs as specific types.
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
@ -23,9 +22,14 @@ FileStoreHandler::FileStoreHandler(std::string& path) {
|
||||
FileStoreHandler::~FileStoreHandler() {}
|
||||
|
||||
std::string FileStoreHandler::realPath(const std::string& path) {
|
||||
#if defined(_MSC_VER)
|
||||
std::array<char, _MAX_PATH> buf;
|
||||
auto ret = _fullpath(buf.data(), path.c_str(), buf.size());
|
||||
#else
|
||||
std::array<char, PATH_MAX> buf;
|
||||
CHECK_EQ(buf.data(), realpath(path.c_str(), buf.data())) << "realpath: "
|
||||
<< strerror(errno);
|
||||
auto ret = realpath(path.c_str(), buf.data());
|
||||
#endif
|
||||
CHECK_EQ(buf.data(), ret) << "realpath: " << strerror(errno);
|
||||
return std::string(buf.data());
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "caffe2/operators/elementwise_op.h"
|
||||
#include "caffe2/utils/math.h"
|
||||
|
||||
namespace caffe2 {
|
||||
|
||||
@ -8,7 +7,7 @@ struct ExpCPUFunctor {
|
||||
template <typename T>
|
||||
inline void
|
||||
operator()(const int n, const T* x, T* y, CPUContext* device_context) {
|
||||
std::transform(x, x + n, y, exp);
|
||||
math::Exp<T, CPUContext>(n, x, y, device_context);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -35,7 +35,7 @@ class ExtendTensorOp final : public Operator<Context> {
|
||||
|
||||
auto extendSize = (TIndex)maxElem - oldSize;
|
||||
if (extendSize > 0) {
|
||||
new_tensor->template Extend(extendSize, growthPct_, &context_);
|
||||
new_tensor->Extend(extendSize, growthPct_, &context_);
|
||||
if (!new_tensor->meta().ctor()) {
|
||||
auto oldSizeBytes = oldSize * new_tensor->meta().itemsize();
|
||||
auto* dst = (char*)new_tensor->raw_mutable_data() + oldSizeBytes;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "caffe2/operators/elementwise_op.h"
|
||||
#include "caffe2/utils/math.h"
|
||||
|
||||
|
||||
namespace caffe2 {
|
||||
|
||||
@ -8,7 +8,7 @@ struct LogCPUFunctor {
|
||||
template <typename T>
|
||||
inline void
|
||||
operator()(const int n, const T* x, T* y, CPUContext* device_context) {
|
||||
std::transform(x, x + n, y, log);
|
||||
math::Log<T, CPUContext>(n, x, y, device_context);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -102,7 +102,10 @@ class TextFileReaderReadOp : public Operator<CPUContext> {
|
||||
to_string(instance->fieldTypes.size()) + " got " +
|
||||
to_string(numFields));
|
||||
|
||||
char* datas[numFields];
|
||||
// char* datas[numFields];
|
||||
// MSVC does not allow using const int, so we will need to dynamically allocate
|
||||
// it.
|
||||
std::vector<char*> datas(numFields);
|
||||
for (int i = 0; i < numFields; ++i) {
|
||||
Output(i)->Resize(batchSize_);
|
||||
datas[i] = (char*)Output(i)->raw_mutable_data(instance->fieldMetas[i]);
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "caffe2/operators/text_file_reader_utils.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "caffe2/core/common.h"
|
||||
|
||||
namespace caffe2 {
|
||||
|
||||
struct Token {
|
||||
|
@ -11,7 +11,6 @@
|
||||
// platforms, it allows one to quickly port Caffe2 to different platforms
|
||||
// where BLAS may not be present.
|
||||
|
||||
#include <unistd.h>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <random>
|
||||
@ -27,6 +26,10 @@
|
||||
#include "Eigen/Core"
|
||||
#include "Eigen/Dense"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
namespace caffe2 {
|
||||
namespace math {
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "caffe2/utils/proto_utils.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <cerrno>
|
||||
#include <fstream>
|
||||
|
||||
|
@ -35,3 +35,9 @@ else()
|
||||
message(STATUS "This compiler does not have builtin_cpu_supports feature.")
|
||||
add_definitions(-DCAFFE2_NO_BUILTIN_CPU_SUPPORTS)
|
||||
endif()
|
||||
|
||||
# ---[ If we are using msvc, set no warning flags
|
||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
||||
message(STATUS "Adding no warning argument to the compiler")
|
||||
|
||||
endif()
|
Reference in New Issue
Block a user