Skip to content

Commit

Permalink
change is_pod tp is_trivial (#21071)
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
jchen351 authored Jun 19, 2024
1 parent be42374 commit 8448f31
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions onnxruntime/contrib_ops/cuda/math/cufft_plan_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ struct CufftPlanInfo {
// see https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
template <typename T>
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<T>::value, "Params is not POD");
static_assert(std::is_trivial<T>::value, "Params is not a trivial type");
size_t operator()(const T& params) const {
auto ptr = reinterpret_cast<const uint8_t*>(&params);
uint32_t value = 0x811C9DC5;
Expand All @@ -50,10 +50,10 @@ struct ParamsHash {

template <typename T>
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<T>::value, "Params is not POD");
static_assert(std::is_trivial<T>::value, "Params is not a trivial type");

bool operator()(const T& a, const T& b) const {
auto ptr1 = reinterpret_cast<const uint8_t*>(&a);
Expand Down
8 changes: 4 additions & 4 deletions orttraining/orttraining/training_ops/cuda/nn/conv_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConvParams>::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<ConvParams>::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<ConvParams>::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<ConvParams>::value, "ConvParams is not a trivial type");

bool operator()(const ConvParams& a, const ConvParams& b) const;
};
Expand Down
8 changes: 4 additions & 4 deletions orttraining/orttraining/training_ops/rocm/nn/conv_grad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ std::vector<T_Perf> 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<ConvParams>::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<ConvParams>::value, "ConvParams is not a trivial type");
size_t operator()(const ConvParams& conv_params) const {
auto ptr = reinterpret_cast<const uint8_t*>(&conv_params);
uint32_t value = 0x811C9DC5;
Expand All @@ -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<ConvParams>::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<ConvParams>::value, "ConvParams is not a trivial type");
bool operator()(const ConvParams& a, const ConvParams& b) const {
auto ptr1 = reinterpret_cast<const uint8_t*>(&a);
auto ptr2 = reinterpret_cast<const uint8_t*>(&b);
Expand Down

0 comments on commit 8448f31

Please sign in to comment.