From 9ba5cdbaa481550f86c53826c83bc094eafc2594 Mon Sep 17 00:00:00 2001 From: zhangsibo1129 <134488188+zhangsibo1129@users.noreply.github.com> Date: Tue, 18 Jul 2023 14:24:51 +0800 Subject: [PATCH] [CANN EP] Fix Float16 support for CANN EP (#16733) ### Description Replace the constructor function `MLFloat16()` with the public member function `FromBits()` in the file `onnxruntime/core/providers/cann/cann_common.cc` ### Motivation and Context PR [#16506](https://github.com/microsoft/onnxruntime/pull/16506) changed the public constructor function `MLFloat16(uint16_t x)` to private, and added a public function `MLFloat16::FromBits(uint16_t x)` in the file `include/onnxruntime/core/framework/float16.h`, which broke the CANN CI. This PR aligns the CANN behavior with the modified class `MLFloat16`. --- onnxruntime/core/providers/cann/cann_common.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onnxruntime/core/providers/cann/cann_common.cc b/onnxruntime/core/providers/cann/cann_common.cc index e30ddba3e0..f1e2e970c4 100644 --- a/onnxruntime/core/providers/cann/cann_common.cc +++ b/onnxruntime/core/providers/cann/cann_common.cc @@ -8,9 +8,9 @@ namespace onnxruntime { namespace cann { template <> -const MLFloat16 Constants::Zero = MLFloat16(static_cast(0)); +const MLFloat16 Constants::Zero = MLFloat16::FromBits(static_cast(0)); template <> -const MLFloat16 Constants::One = MLFloat16(static_cast(0x3C00)); +const MLFloat16 Constants::One = MLFloat16::FromBits(static_cast(0x3C00)); template <> const float Constants::Zero = 0;