From 4f244e48d59ab8a970b8cc17b52d73d5886508c7 Mon Sep 17 00:00:00 2001 From: tvkai <97374290+tvkai@users.noreply.github.com> Date: Mon, 29 Aug 2022 22:53:58 +0530 Subject: [PATCH] fix CalculateHash for Big Endian platforms. (#12752) * fix CalculateHash for Big Endian platforms. --- onnxruntime/core/framework/kernel_def_builder.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/onnxruntime/core/framework/kernel_def_builder.cc b/onnxruntime/core/framework/kernel_def_builder.cc index 3c773248e0..b3fffe602f 100644 --- a/onnxruntime/core/framework/kernel_def_builder.cc +++ b/onnxruntime/core/framework/kernel_def_builder.cc @@ -45,7 +45,16 @@ void KernelDef::CalculateHash() { // kernel definition) hash_str(op_name_); - hash_int(op_since_version_start_); + + if constexpr (onnxruntime::endian::native == onnxruntime::endian::little) { + hash_int(op_since_version_start_); + } else { + const uint8_t* c = (const uint8_t*)&op_since_version_start_; + hash_int((uint32_t)c[0] | + (uint32_t)c[1] << 8 | + (uint32_t)c[2] << 16 | + (uint32_t)c[3] << 24); + } // If we include op_since_version_end_ the hash of an existing op changes when it's superseded. // e.g. Unsqueeze 11 had no end version until Unsqueeze 13, at which point the existing op is changed to have