未验证 提交 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 {
} else if (max_token_length_ <= 512) {
padding_token_length = 512;
} else {
PADDLE_THROW(platform::errors::InvalidArgument(
"Token_prune'token_length(max) must <= 512"));
try {
PADDLE_THROW(platform::errors::InvalidArgument(
"Token_prune'token_length(max) must <= 512"));
} catch (std::exception& e) {
}
}
PADDLE_ENFORCE_GPU_SUCCESS(cudaMalloc(&pruned_token_lengths_,
(max_batchs_ + 1) * sizeof(int32_t)));
PADDLE_ENFORCE_GPU_SUCCESS(cudaMalloc(
&token_index_, max_batchs_ * padding_token_length * sizeof(int32_t)));
int32_t type_size = 4;
if (in[0].desc.type == nvinfer1::DataType::kHALF) {
type_size = 2;
} else {
type_size = 4;
try {
PADDLE_ENFORCE_GPU_SUCCESS(cudaMalloc(
&pruned_token_lengths_, (max_batchs_ + 1) * sizeof(int32_t)));
PADDLE_ENFORCE_GPU_SUCCESS(cudaMalloc(
&token_index_, max_batchs_ * padding_token_length * sizeof(int32_t)));
int32_t type_size = 4;
if (in[0].desc.type == nvinfer1::DataType::kHALF) {
type_size = 2;
} 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,
int nb_inputs,
const nvinfer1::PluginTensorDesc* outputs,
......
......@@ -115,11 +115,14 @@ bool TRTInt8Calibrator::getBatch(void** bindings,
for (int i = 0; i < num_bindings; i++) {
auto it = data_buffers_.find(names[i]);
if (it == data_buffers_.end()) {
PADDLE_THROW(
platform::errors::Fatal("Calibration engine asked for unknown tensor "
"name '%s' at position %d.",
names[i],
i));
try {
PADDLE_THROW(platform::errors::Fatal(
"Calibration engine asked for unknown tensor "
"name '%s' at position %d.",
names[i],
i));
} catch (std::exception& e) {
}
}
bindings[i] = it->second.first;
}
......
......@@ -44,13 +44,11 @@ class GPUContextAllocation : public Allocation {
underlying_allocation_(std::move(allocation)) {}
~GPUContextAllocation() {
try {
PADDLE_ENFORCE_NOT_NULL(
dev_ctx_,
platform::errors::PreconditionNotMet(
"Device context is not set for GPUContextAllocation"));
} catch (std::exception &e) {
}
PADDLE_WARN_NOT_NULL(
dev_ctx_,
platform::errors::PreconditionNotMet(
"Device context is not set for GPUContextAllocation"));
auto *p_allocation = underlying_allocation_.release();
VLOG(4) << "Adding callback to delete GPUContextAllocation at "
<< p_allocation;
......@@ -89,17 +87,14 @@ class GPUContextAllocator : public Allocator {
}
~GPUContextAllocator() {
try {
if (event_) {
platform::CUDADeviceGuard guard(place_.device);
if (event_) {
platform::CUDADeviceGuard guard(place_.device);
#ifdef PADDLE_WITH_HIP
PADDLE_ENFORCE_GPU_SUCCESS(hipEventDestroy(event_));
PADDLE_WARN_GPU_SUCCESS(hipEventDestroy(event_));
#else
PADDLE_ENFORCE_GPU_SUCCESS(cudaEventDestroy(event_));
PADDLE_WARN_GPU_SUCCESS(cudaEventDestroy(event_));
#endif
}
} catch (std::exception &e) {
}
}
......
......@@ -216,26 +216,18 @@ void RefcountedMemoryMapAllocation::close() {
}
MemoryMapWriterAllocation::~MemoryMapWriterAllocation() {
try {
PADDLE_ENFORCE_NE(
munmap(this->ptr(), this->size()),
-1,
platform::errors::Unavailable(
"could not unmap the shared memory file %s", this->ipc_name()));
} catch (std::exception &e) {
if (munmap(this->ptr(), this->size()) == -1) {
platform::errors::Unavailable("could not unmap the shared memory file %s",
this->ipc_name());
}
}
MemoryMapReaderAllocation::~MemoryMapReaderAllocation() {
try {
PADDLE_ENFORCE_NE(
munmap(this->ptr(), this->size()),
-1,
platform::errors::Unavailable(
"could not unmap the shared memory file %s", this->ipc_name()));
} catch (std::exception &e) {
if (munmap(this->ptr(), this->size()) == -1) {
platform::errors::Unavailable("could not unmap the shared memory file %s",
this->ipc_name());
}
/* Here we do not pay attention to the result of shm_unlink,
because the memory mapped file may have been cleared due to the
MemoryMapFdSet::Clear() */
......
......@@ -287,6 +287,11 @@ inline bool is_error(bool stat) { return !stat; }
END_HANDLE_THE_ERROR \
} while (0)
#define __THROW_WARN_INTERNAL__(__MSG__) \
do { \
LOG(WARNING) << "WARNING :" << __MSG__; \
} while (0)
/** ENFORCE EXCEPTION AND MACROS **/
struct EnforceNotMet : public std::exception {
......@@ -421,6 +426,17 @@ struct EnforceNotMet : public std::exception {
} \
} 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, ...) \
do { \
auto __val1 = (__VAL1); \
......@@ -883,6 +899,19 @@ inline std::string build_nvidia_error_msg(ncclResult_t nccl_result) {
} \
} 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) \
do { \
auto res = cudaGetLastError(); \
......@@ -1089,6 +1118,18 @@ DEFINE_EXTERNAL_API_TYPE(ncclResult_t, ncclSuccess);
} \
} 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) {
#ifdef _WIN32
Sleep(millisecond);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册