提交 c1ad52f7 编写于 作者: D dzhwinter

pre-commit

上级 89f95ea2
../../v2/dev/contribute_to_paddle_cn.md ../../v2/dev/contribute_to_paddle_cn.md
\ No newline at end of file
../../v2/dev/contribute_to_paddle_en.md ../../v2/dev/contribute_to_paddle_en.md
\ No newline at end of file
../../../dev/contribute_to_paddle_cn.md ../../../dev/contribute_to_paddle_cn.md
\ No newline at end of file
../../../howto/optimization/cpu_profiling_cn.md ../../../howto/optimization/cpu_profiling_cn.md
\ No newline at end of file
../../../howto/optimization/host_memory_profiling_cn.md ../../../howto/optimization/host_memory_profiling_cn.md
\ No newline at end of file
../../../dev/new_op_cn.md ../../../dev/new_op_cn.md
\ No newline at end of file
../../../howto/optimization/timeline_cn.md ../../../howto/optimization/timeline_cn.md
\ No newline at end of file
../../../CONTRIBUTING.md ../../../CONTRIBUTING.md
\ No newline at end of file
...@@ -58,7 +58,7 @@ inline void VisitDataType(proto::VarType::Type type, Visitor visitor) { ...@@ -58,7 +58,7 @@ inline void VisitDataType(proto::VarType::Type type, Visitor visitor) {
PADDLE_THROW("Not supported %d", type); PADDLE_THROW("Not supported %d", type);
} }
} }
#else #else
// the msvc compiler do not implement two-stage name lookup correctly. // the msvc compiler do not implement two-stage name lookup correctly.
template <typename Visitor> template <typename Visitor>
inline void VisitDataType(proto::VarType::Type type, Visitor visitor) { inline void VisitDataType(proto::VarType::Type type, Visitor visitor) {
...@@ -91,7 +91,7 @@ inline void VisitDataType(proto::VarType::Type type, Visitor visitor) { ...@@ -91,7 +91,7 @@ inline void VisitDataType(proto::VarType::Type type, Visitor visitor) {
PADDLE_THROW("Not supported %d", type); PADDLE_THROW("Not supported %d", type);
} }
} }
#endif // _WIN32 #endif // _WIN32
extern std::string DataTypeToString(const proto::VarType::Type type); extern std::string DataTypeToString(const proto::VarType::Type type);
extern size_t SizeOfType(std::type_index type); extern size_t SizeOfType(std::type_index type);
......
// Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
data_type_transform.cc data_type_transform.cc
\ No newline at end of file
...@@ -28,7 +28,7 @@ limitations under the License. */ ...@@ -28,7 +28,7 @@ limitations under the License. */
#if defined(_WIN32) #if defined(_WIN32)
#include "paddle/fluid/recordio/scanner.h" #include "paddle/fluid/recordio/scanner.h"
#include "paddle/fluid/recordio/writer.h" #include "paddle/fluid/recordio/writer.h"
#endif // _WIN32 #endif // _WIN32
namespace paddle { namespace paddle {
namespace framework { namespace framework {
...@@ -337,14 +337,14 @@ class Writer {}; ...@@ -337,14 +337,14 @@ class Writer {};
class Scanner {}; class Scanner {};
void WriteToRecordIO(recordio::Writer *writer, void WriteToRecordIO(recordio::Writer *writer,
const std::vector<LoDTensor> &tensor, const std::vector<LoDTensor> &tensor,
const platform::DeviceContext &dev_ctx) { const platform::DeviceContext &dev_ctx) {}
}
bool ReadFromRecordIO(recordio::Scanner *scanner, bool ReadFromRecordIO(recordio::Scanner *scanner,
const platform::DeviceContext &dev_ctx, const platform::DeviceContext &dev_ctx,
std::vector<LoDTensor> *result_ptr) { std::vector<LoDTensor> *result_ptr) {
PADDLE_ENFORCE("windows didn't supported recordio!."); PADDLE_ENFORCE("windows didn't supported recordio!.");
return true;} return true;
#endif // _WIN32 }
#endif // _WIN32
std::vector<LoDTensor> LoDTensor::SplitLoDTensor( std::vector<LoDTensor> LoDTensor::SplitLoDTensor(
const std::vector<platform::Place> places) const { const std::vector<platform::Place> places) const {
check_memory_size(); check_memory_size();
......
...@@ -321,7 +321,7 @@ TEST(LoDTensor, RecordIO) { ...@@ -321,7 +321,7 @@ TEST(LoDTensor, RecordIO) {
TestRecordIO<float>(); TestRecordIO<float>();
TestRecordIO<double>(); TestRecordIO<double>();
} }
#endif // !defined(_WIN32) #endif // !defined(_WIN32)
} // namespace framework } // namespace framework
} // namespace paddle } // namespace paddle
...@@ -16,7 +16,7 @@ limitations under the License. */ ...@@ -16,7 +16,7 @@ limitations under the License. */
#if !defined(_WIN32) #if !defined(_WIN32)
#include <pthread.h> #include <pthread.h>
#endif // !_WIN32 #endif // !_WIN32
#include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/enforce.h"
......
// Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
tensor_util.cc tensor_util.cc
\ No newline at end of file
...@@ -16,13 +16,13 @@ limitations under the License. */ ...@@ -16,13 +16,13 @@ limitations under the License. */
#include "paddle/fluid/memory/detail/system_allocator.h" #include "paddle/fluid/memory/detail/system_allocator.h"
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h>
#include <malloc.h> #include <malloc.h>
#include <windows.h>
#else #else
#include <sys/mman.h> // for mlock and munlock #include <sys/mman.h> // for mlock and munlock
#endif #endif
#include <stdlib.h> // for malloc and free #include <stdlib.h> // for malloc and free
#include <algorithm> // for std::max #include <algorithm> // for std::max
#include "gflags/gflags.h" #include "gflags/gflags.h"
#include "paddle/fluid/platform/assert.h" #include "paddle/fluid/platform/assert.h"
...@@ -44,15 +44,15 @@ namespace detail { ...@@ -44,15 +44,15 @@ namespace detail {
void* AlignedMalloc(size_t size) { void* AlignedMalloc(size_t size) {
void* p = nullptr; void* p = nullptr;
size_t alignment = 32ul; size_t alignment = 32ul;
#ifdef PADDLE_WITH_MKLDNN #ifdef PADDLE_WITH_MKLDNN
// refer to https://github.com/01org/mkl-dnn/blob/master/include/mkldnn.hpp // refer to https://github.com/01org/mkl-dnn/blob/master/include/mkldnn.hpp
// memory alignment // memory alignment
alignment = 4096ul; alignment = 4096ul;
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
p = _aligned_malloc(size, alignment); p = _aligned_malloc(size, alignment);
#else #else
PADDLE_ENFORCE_EQ(posix_memalign(&p, alignment, size), 0, "Alloc %ld error!", PADDLE_ENFORCE_EQ(posix_memalign(&p, alignment, size), 0, "Alloc %ld error!",
size); size);
#endif #endif
PADDLE_ENFORCE(p, "Fail to allocate CPU memory: size = %d .", size); PADDLE_ENFORCE(p, "Fail to allocate CPU memory: size = %d .", size);
......
...@@ -17,7 +17,6 @@ limitations under the License. */ ...@@ -17,7 +17,6 @@ limitations under the License. */
#include "paddle/fluid/platform/dynload/mklml.h" #include "paddle/fluid/platform/dynload/mklml.h"
#endif #endif
#ifdef PADDLE_USE_OPENBLAS #ifdef PADDLE_USE_OPENBLAS
#include <cblas.h> #include <cblas.h>
#endif #endif
......
...@@ -24,8 +24,8 @@ limitations under the License. */ ...@@ -24,8 +24,8 @@ limitations under the License. */
#include <sys/types.h> #include <sys/types.h>
#elif defined(_WIN32) #elif defined(_WIN32)
#define NOMINMAX #define NOMINMAX
#include <windows.h>
#include <psapi.h> #include <psapi.h>
#include <windows.h>
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
...@@ -47,8 +47,9 @@ DEFINE_uint64(initial_cpu_memory_in_mb, ...@@ -47,8 +47,9 @@ DEFINE_uint64(initial_cpu_memory_in_mb,
#endif #endif
"Initial CPU memory for PaddlePaddle, in MD unit."); "Initial CPU memory for PaddlePaddle, in MD unit.");
#else #else
DEFINE_uint64(initial_cpu_memory_in_mb, 500ul, "Initial CPU memory for PaddlePaddle, in MD unit."); DEFINE_uint64(initial_cpu_memory_in_mb, 500ul,
#endif // !defined(_WIN32) "Initial CPU memory for PaddlePaddle, in MD unit.");
#endif // !defined(_WIN32)
DEFINE_double( DEFINE_double(
fraction_of_cuda_pinned_memory_to_use, 0.5, fraction_of_cuda_pinned_memory_to_use, 0.5,
...@@ -68,10 +69,10 @@ inline size_t CpuTotalPhysicalMemory() { ...@@ -68,10 +69,10 @@ inline size_t CpuTotalPhysicalMemory() {
if (sysctl(mib, 2, &size, &len, NULL, 0) == 0) return (size_t)size; if (sysctl(mib, 2, &size, &len, NULL, 0) == 0) return (size_t)size;
return 0L; return 0L;
#elif defined(_WIN32) #elif defined(_WIN32)
MEMORYSTATUSEX sMeminfo; MEMORYSTATUSEX sMeminfo;
sMeminfo.dwLength = sizeof(sMeminfo); sMeminfo.dwLength = sizeof(sMeminfo);
GlobalMemoryStatusEx(&sMeminfo); GlobalMemoryStatusEx(&sMeminfo);
return sMeminfo.ullTotalPhys; return sMeminfo.ullTotalPhys;
#else #else
int64_t pages = sysconf(_SC_PHYS_PAGES); int64_t pages = sysconf(_SC_PHYS_PAGES);
int64_t page_size = sysconf(_SC_PAGE_SIZE); int64_t page_size = sysconf(_SC_PAGE_SIZE);
......
...@@ -17,7 +17,7 @@ limitations under the License. */ ...@@ -17,7 +17,7 @@ limitations under the License. */
#include <sys/time.h> #include <sys/time.h>
#else #else
#include <windows.h> #include <windows.h>
#endif // !_WIN32 #endif // !_WIN32
#include <time.h> #include <time.h>
#include <chrono> // NOLINT #include <chrono> // NOLINT
...@@ -36,13 +36,11 @@ namespace platform { ...@@ -36,13 +36,11 @@ namespace platform {
inline uint64_t PosixInNsec() { inline uint64_t PosixInNsec() {
struct timeval tv; struct timeval tv;
gettimeofday(&tv, nullptr); gettimeofday(&tv, nullptr);
return 1000 * (static_cast<uint64_t>(tv.tv_sec) * 1000000 + tv.tv_usec); return 1000 * (static_cast<uint64_t>(tv.tv_sec) * 1000000 + tv.tv_usec);
} }
#else #else
inline uint64_t PosixInNsec() { inline uint64_t PosixInNsec() { return static_cast<uint64_t>(0); }
return static_cast<uint64_t>(0); #endif // !_WIN32
}
#endif // !_WIN32
// DeviceTracer performs the following tasks: // DeviceTracer performs the following tasks:
// 1. Register cuda callbacks for various events: kernel, memcpy, etc. // 1. Register cuda callbacks for various events: kernel, memcpy, etc.
......
...@@ -33,9 +33,9 @@ limitations under the License. */ ...@@ -33,9 +33,9 @@ limitations under the License. */
#include <string> #include <string>
#include "glog/logging.h" #include "glog/logging.h"
#include "paddle/fluid/platform/port.h"
#include "paddle/fluid/platform/macros.h" #include "paddle/fluid/platform/macros.h"
#include "paddle/fluid/platform/port.h" #include "paddle/fluid/platform/port.h"
#include "paddle/fluid/platform/port.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/fluid/string/to_string.h" #include "paddle/fluid/string/to_string.h"
...@@ -261,20 +261,21 @@ inline void throw_on_error(T e) { ...@@ -261,20 +261,21 @@ inline void throw_on_error(T e) {
throw ::paddle::platform::EOFException("There is no next data.", __FILE__, \ throw ::paddle::platform::EOFException("There is no next data.", __FILE__, \
__LINE__); \ __LINE__); \
} while (false) } while (false)
#else #else
#define PADDLE_ENFORCE(...) ::paddle::platform::throw_on_error(__VA_ARGS__); #define PADDLE_ENFORCE(...) ::paddle::platform::throw_on_error(__VA_ARGS__);
#endif #endif
#else // !_WIN32 #else // !_WIN32
#define GLOG_NO_ABBREVIATED_SEVERITIES #define GLOG_NO_ABBREVIATED_SEVERITIES
// disable enforce, caused by the varardic macro exception error // disable enforce, caused by the varardic macro exception error
#define PADDLE_THROW(x) \ #define PADDLE_THROW(x) \
do { \ do { \
throw std::make_exception_ptr(std::runtime_error("Windows disable the enforce.")); \ throw std::make_exception_ptr( \
std::runtime_error("Windows disable the enforce.")); \
} while (false) } while (false)
#define PADDLE_ENFORCE(x) x #define PADDLE_ENFORCE(x) x
#endif // !_WIN32 #endif // !_WIN32
/* /*
* Some enforce helpers here, usage: * Some enforce helpers here, usage:
......
<<<<<<< HEAD
#pragma once
#include <string>
#include <stdexcept>
#if !defined(_WIN32)
#include <dlfcn.h> // for dladdr
#include <execinfo.h> // for backtrace
#else
#define NOMINMAX // windows min(), max() macro will mess std::min,max
#include <Shlwapi.h>
#include <Windows.h>
namespace {
static void* dlsym(void *handle, const char* symbol_name) {
FARPROC found_symbol;
found_symbol = GetProcAddress((HMODULE)handle, symbol_name);
if (found_symbol == NULL) {
throw std::runtime_error(std::string(symbol_name) + " not found.");
}
return (void*)found_symbol;
}
} // namespace anoymous
#endif
=======
// Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. // Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
...@@ -63,4 +35,3 @@ static void* dlsym(void* handle, const char* symbol_name) { ...@@ -63,4 +35,3 @@ static void* dlsym(void* handle, const char* symbol_name) {
} }
#endif #endif
>>>>>>> origin/develop
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册