未验证 提交 ffff133b 编写于 作者: G Galaxy1458 提交者: GitHub

FIX_LINUX_Wternimate (#52307)

* this is a test pr, test=develop

* solve the four [-Wterminate] warning, test=develop

* solve the four [-Wterminate] warning, test=develop

* new fix [-Wterminate], test=delelop

* new fix [-Wterminate], test=delelop

* new fix [-Wterminate], test=delelop

* new , test = develop

* new , test = develop

* new , test = develop

* new , test = develop

* new , test = develop

* new , test = develop
上级 ea5e1ebb
...@@ -105,23 +105,28 @@ class FusedTokenPrunePluginDynamic : public DynamicPluginTensorRT { ...@@ -105,23 +105,28 @@ class FusedTokenPrunePluginDynamic : public DynamicPluginTensorRT {
} else if (max_token_length_ <= 512) { } else if (max_token_length_ <= 512) {
padding_token_length = 512; padding_token_length = 512;
} else { } else {
PADDLE_THROW(platform::errors::InvalidArgument( try {
"Token_prune'token_length(max) must <= 512")); PADDLE_THROW(platform::errors::InvalidArgument(
"Token_prune'token_length(max) must <= 512"));
} catch (std::exception& e) {
}
} }
PADDLE_ENFORCE_GPU_SUCCESS(cudaMalloc(&pruned_token_lengths_, try {
(max_batchs_ + 1) * sizeof(int32_t))); PADDLE_ENFORCE_GPU_SUCCESS(cudaMalloc(
PADDLE_ENFORCE_GPU_SUCCESS(cudaMalloc( &pruned_token_lengths_, (max_batchs_ + 1) * sizeof(int32_t)));
&token_index_, max_batchs_ * padding_token_length * sizeof(int32_t))); PADDLE_ENFORCE_GPU_SUCCESS(cudaMalloc(
int32_t type_size = 4; &token_index_, max_batchs_ * padding_token_length * sizeof(int32_t)));
if (in[0].desc.type == nvinfer1::DataType::kHALF) { int32_t type_size = 4;
type_size = 2; if (in[0].desc.type == nvinfer1::DataType::kHALF) {
} else { type_size = 2;
type_size = 4; } else {
type_size = 4;
}
PADDLE_ENFORCE_GPU_SUCCESS(cudaMalloc(
&padding_scores_, max_batchs_ * padding_token_length * type_size));
} catch (std::exception& e) {
} }
PADDLE_ENFORCE_GPU_SUCCESS(cudaMalloc(
&padding_scores_, max_batchs_ * padding_token_length * type_size));
} }
size_t getWorkspaceSize(const nvinfer1::PluginTensorDesc* inputs, size_t getWorkspaceSize(const nvinfer1::PluginTensorDesc* inputs,
int nb_inputs, int nb_inputs,
const nvinfer1::PluginTensorDesc* outputs, const nvinfer1::PluginTensorDesc* outputs,
......
...@@ -115,11 +115,14 @@ bool TRTInt8Calibrator::getBatch(void** bindings, ...@@ -115,11 +115,14 @@ bool TRTInt8Calibrator::getBatch(void** bindings,
for (int i = 0; i < num_bindings; i++) { for (int i = 0; i < num_bindings; i++) {
auto it = data_buffers_.find(names[i]); auto it = data_buffers_.find(names[i]);
if (it == data_buffers_.end()) { if (it == data_buffers_.end()) {
PADDLE_THROW( try {
platform::errors::Fatal("Calibration engine asked for unknown tensor " PADDLE_THROW(platform::errors::Fatal(
"name '%s' at position %d.", "Calibration engine asked for unknown tensor "
names[i], "name '%s' at position %d.",
i)); names[i],
i));
} catch (std::exception& e) {
}
} }
bindings[i] = it->second.first; bindings[i] = it->second.first;
} }
......
...@@ -44,13 +44,11 @@ class GPUContextAllocation : public Allocation { ...@@ -44,13 +44,11 @@ class GPUContextAllocation : public Allocation {
underlying_allocation_(std::move(allocation)) {} underlying_allocation_(std::move(allocation)) {}
~GPUContextAllocation() { ~GPUContextAllocation() {
try { PADDLE_WARN_NOT_NULL(
PADDLE_ENFORCE_NOT_NULL( dev_ctx_,
dev_ctx_, platform::errors::PreconditionNotMet(
platform::errors::PreconditionNotMet( "Device context is not set for GPUContextAllocation"));
"Device context is not set for GPUContextAllocation"));
} catch (std::exception &e) {
}
auto *p_allocation = underlying_allocation_.release(); auto *p_allocation = underlying_allocation_.release();
VLOG(4) << "Adding callback to delete GPUContextAllocation at " VLOG(4) << "Adding callback to delete GPUContextAllocation at "
<< p_allocation; << p_allocation;
...@@ -89,17 +87,14 @@ class GPUContextAllocator : public Allocator { ...@@ -89,17 +87,14 @@ class GPUContextAllocator : public Allocator {
} }
~GPUContextAllocator() { ~GPUContextAllocator() {
try { if (event_) {
if (event_) { platform::CUDADeviceGuard guard(place_.device);
platform::CUDADeviceGuard guard(place_.device);
#ifdef PADDLE_WITH_HIP #ifdef PADDLE_WITH_HIP
PADDLE_ENFORCE_GPU_SUCCESS(hipEventDestroy(event_)); PADDLE_WARN_GPU_SUCCESS(hipEventDestroy(event_));
#else #else
PADDLE_ENFORCE_GPU_SUCCESS(cudaEventDestroy(event_)); PADDLE_WARN_GPU_SUCCESS(cudaEventDestroy(event_));
#endif #endif
}
} catch (std::exception &e) {
} }
} }
......
...@@ -216,26 +216,18 @@ void RefcountedMemoryMapAllocation::close() { ...@@ -216,26 +216,18 @@ void RefcountedMemoryMapAllocation::close() {
} }
MemoryMapWriterAllocation::~MemoryMapWriterAllocation() { MemoryMapWriterAllocation::~MemoryMapWriterAllocation() {
try { if (munmap(this->ptr(), this->size()) == -1) {
PADDLE_ENFORCE_NE( platform::errors::Unavailable("could not unmap the shared memory file %s",
munmap(this->ptr(), this->size()), this->ipc_name());
-1,
platform::errors::Unavailable(
"could not unmap the shared memory file %s", this->ipc_name()));
} catch (std::exception &e) {
} }
} }
MemoryMapReaderAllocation::~MemoryMapReaderAllocation() { MemoryMapReaderAllocation::~MemoryMapReaderAllocation() {
try { if (munmap(this->ptr(), this->size()) == -1) {
PADDLE_ENFORCE_NE( platform::errors::Unavailable("could not unmap the shared memory file %s",
this->ipc_name());
munmap(this->ptr(), this->size()),
-1,
platform::errors::Unavailable(
"could not unmap the shared memory file %s", this->ipc_name()));
} catch (std::exception &e) {
} }
/* Here we do not pay attention to the result of shm_unlink, /* Here we do not pay attention to the result of shm_unlink,
because the memory mapped file may have been cleared due to the because the memory mapped file may have been cleared due to the
MemoryMapFdSet::Clear() */ MemoryMapFdSet::Clear() */
......
...@@ -287,6 +287,11 @@ inline bool is_error(bool stat) { return !stat; } ...@@ -287,6 +287,11 @@ inline bool is_error(bool stat) { return !stat; }
END_HANDLE_THE_ERROR \ END_HANDLE_THE_ERROR \
} while (0) } while (0)
#define __THROW_WARN_INTERNAL__(__MSG__) \
do { \
LOG(WARNING) << "WARNING :" << __MSG__; \
} while (0)
/** ENFORCE EXCEPTION AND MACROS **/ /** ENFORCE EXCEPTION AND MACROS **/
struct EnforceNotMet : public std::exception { struct EnforceNotMet : public std::exception {
...@@ -421,6 +426,17 @@ struct EnforceNotMet : public std::exception { ...@@ -421,6 +426,17 @@ struct EnforceNotMet : public std::exception {
} \ } \
} while (0) } while (0)
#define PADDLE_WARN_NOT_NULL(__VAL, ...) \
do { \
if (UNLIKELY(nullptr == (__VAL))) { \
auto __summary__ = phi::ErrorSummary(__VA_ARGS__); \
auto __message__ = ::paddle::string::Sprintf( \
"%s\n [Hint: " #__VAL " should not be null.]", \
__summary__.error_message()); \
__THROW_WARN_INTERNAL__(__message__); \
} \
} while (0)
#define __PADDLE_BINARY_COMPARE(__VAL1, __VAL2, __CMP, __INV_CMP, ...) \ #define __PADDLE_BINARY_COMPARE(__VAL1, __VAL2, __CMP, __INV_CMP, ...) \
do { \ do { \
auto __val1 = (__VAL1); \ auto __val1 = (__VAL1); \
...@@ -883,6 +899,19 @@ inline std::string build_nvidia_error_msg(ncclResult_t nccl_result) { ...@@ -883,6 +899,19 @@ inline std::string build_nvidia_error_msg(ncclResult_t nccl_result) {
} \ } \
} while (0) } while (0)
#define PADDLE_WARN_GPU_SUCCESS(COND) \
do { \
auto __cond__ = (COND); \
using __CUDA_STATUS_TYPE__ = decltype(__cond__); \
constexpr auto __success_type__ = \
::phi::enforce::details::ExternalApiType< \
__CUDA_STATUS_TYPE__>::kSuccess; \
if (UNLIKELY(__cond__ != __success_type__)) { \
__THROW_WARN_INTERNAL__( \
::phi::enforce::build_nvidia_error_msg(__cond__)); \
} \
} while (0)
#define PADDLE_ENFORCE_CUDA_LAUNCH_SUCCESS(OP) \ #define PADDLE_ENFORCE_CUDA_LAUNCH_SUCCESS(OP) \
do { \ do { \
auto res = cudaGetLastError(); \ auto res = cudaGetLastError(); \
...@@ -1089,6 +1118,18 @@ DEFINE_EXTERNAL_API_TYPE(ncclResult_t, ncclSuccess); ...@@ -1089,6 +1118,18 @@ DEFINE_EXTERNAL_API_TYPE(ncclResult_t, ncclSuccess);
} \ } \
} while (0) } while (0)
#define PADDLE_WARN_GPU_SUCCESS(COND) \
do { \
auto __cond__ = (COND); \
using __CUDA_STATUS_TYPE__ = decltype(__cond__); \
constexpr auto __success_type__ = \
::phi::enforce::details::ExternalApiType< \
__CUDA_STATUS_TYPE__>::kSuccess; \
if (UNLIKELY(__cond__ != __success_type__)) { \
__THROW_WARN_INTERNAL__(::phi::enforce::build_rocm_error_msg(__cond__)); \
} \
} while (0)
inline void retry_sleep(unsigned millisecond) { inline void retry_sleep(unsigned millisecond) {
#ifdef _WIN32 #ifdef _WIN32
Sleep(millisecond); Sleep(millisecond);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册