From 694d5eb97b7bd4c2c213e46c2fd09911e1de4777 Mon Sep 17 00:00:00 2001 From: Peilin Wang Date: Mon, 5 Jul 2021 18:20:03 -0400 Subject: [PATCH] add general float16 support initial commit --- .../backend/kernel_compiler/gpu/arrays/topk_gpu_kernel.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/topk_gpu_kernel.h b/mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/topk_gpu_kernel.h index 4b6d8021c5d..b07a37f621d 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/topk_gpu_kernel.h +++ b/mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/topk_gpu_kernel.h @@ -41,7 +41,13 @@ class TopKGpuKernel : public GpuKernel { S *k = GetDeviceAddress(inputs, 1); T *output_addr = GetDeviceAddress(outputs, 0); S *indices = GetDeviceAddress(outputs, 1); - const T init_k = std::numeric_limits::lowest(); + + T init_k = std::numeric_limits::lowest(); + if (std::is_same::value) { + // min value representable by float16, std::numeric_limits doesn't support half + init_k = static_cast(-65504.); + } + S k_cut = 0; CHECK_CUDA_RET_WITH_EXCEPT( kernel_node_,