From 8448f31d9042b6129886fb6cebfb23d6fe3293b8 Mon Sep 17 00:00:00 2001 From: Jian Chen Date: Wed, 19 Jun 2024 16:23:47 -0700 Subject: [PATCH] change is_pod tp is_trivial (#21071) ### Description change is_pod tp is_trivial ### Motivation and Context This is commonnly needed for both linux and win c++20 upgrade. is_trivial was introduced backed in C++11 --- onnxruntime/contrib_ops/cuda/math/cufft_plan_cache.h | 12 ++++++------ .../orttraining/training_ops/cuda/nn/conv_shared.h | 8 ++++---- .../orttraining/training_ops/rocm/nn/conv_grad.cc | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/onnxruntime/contrib_ops/cuda/math/cufft_plan_cache.h b/onnxruntime/contrib_ops/cuda/math/cufft_plan_cache.h index 9cd96d5c62c94..3d21b12f9b55c 100644 --- a/onnxruntime/contrib_ops/cuda/math/cufft_plan_cache.h +++ b/onnxruntime/contrib_ops/cuda/math/cufft_plan_cache.h @@ -33,10 +33,10 @@ struct CufftPlanInfo { // see https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function template struct ParamsHash { - // Params must be a POD because we read out its memory - // contenst as char* when hashing + // Params must be a trivial type because we read out its memory + // contents as char* when hashing - static_assert(std::is_pod::value, "Params is not POD"); + static_assert(std::is_trivial::value, "Params is not a trivial type"); size_t operator()(const T& params) const { auto ptr = reinterpret_cast(¶ms); uint32_t value = 0x811C9DC5; @@ -50,10 +50,10 @@ struct ParamsHash { template struct ParamsEqual { - // Params must be a POD because we read out its memory - // contenst as char* when comparing + // Params must be a trivial type because we read out its memory + // contents as char* when comparing - static_assert(std::is_pod::value, "Params is not POD"); + static_assert(std::is_trivial::value, "Params is not a trivial type"); bool operator()(const T& a, const T& b) const { auto ptr1 = reinterpret_cast(&a); diff --git a/orttraining/orttraining/training_ops/cuda/nn/conv_shared.h b/orttraining/orttraining/training_ops/cuda/nn/conv_shared.h index 3fdb4306bfbbb..ec227c4641766 100644 --- a/orttraining/orttraining/training_ops/cuda/nn/conv_shared.h +++ b/orttraining/orttraining/training_ops/cuda/nn/conv_shared.h @@ -54,15 +54,15 @@ struct ConvArgs { }; struct ConvParamsHash { - // ConvParams must be a POD because we read out its memory constant as char* when hashing. - static_assert(std::is_pod::value, "ConvParams is not POD"); + // ConvParams must be a trivial type because we read out its memory contents as char* when hashing. + static_assert(std::is_trivial::value, "ConvParams is not a trivial type"); size_t operator()(const ConvParams& conv_params) const; }; struct ConvParamsEqual { - // ConvParams must be a POD because we read out its memory constant as char* when hashing. - static_assert(std::is_pod::value, "ConvParams is not POD"); + // ConvParams must be a trivial type because we read out its memory contents as char* when hashing. + static_assert(std::is_trivial::value, "ConvParams is not a trivial type"); bool operator()(const ConvParams& a, const ConvParams& b) const; }; diff --git a/orttraining/orttraining/training_ops/rocm/nn/conv_grad.cc b/orttraining/orttraining/training_ops/rocm/nn/conv_grad.cc index 9da0725274641..22fa5b6f55a5d 100644 --- a/orttraining/orttraining/training_ops/rocm/nn/conv_grad.cc +++ b/orttraining/orttraining/training_ops/rocm/nn/conv_grad.cc @@ -71,8 +71,8 @@ std::vector GetValidAlgorithms(const T_Perf* perf_results, int n_algo) { } struct ConvParamsHash { - // ConvParams must be a POD because we read out its memory constant as char* when hashing. - static_assert(std::is_pod::value, "ConvParams is not POD"); + // ConvParams must be a trivial type because we read out its memory contents as char* when hashing. + static_assert(std::is_trivial::value, "ConvParams is not a trivial type"); size_t operator()(const ConvParams& conv_params) const { auto ptr = reinterpret_cast(&conv_params); uint32_t value = 0x811C9DC5; @@ -85,8 +85,8 @@ struct ConvParamsHash { }; struct ConvParamsEqual { - // ConvParams must be a POD because we read out its memory constant as char* when hashing. - static_assert(std::is_pod::value, "ConvParams is not POD"); + // ConvParams must be a trivial type because we read out its memory contents as char* when hashing. + static_assert(std::is_trivial::value, "ConvParams is not a trivial type"); bool operator()(const ConvParams& a, const ConvParams& b) const { auto ptr1 = reinterpret_cast(&a); auto ptr2 = reinterpret_cast(&b);