Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save emfomenk/0386c529c5df21ae308b00d16454c48e to your computer and use it in GitHub Desktop.
Save emfomenk/0386c529c5df21ae308b00d16454c48e to your computer and use it in GitHub Desktop.
a fix for #106?
From b4ad9810802cf93b736481a0dfa3dbdf1b5a6fde Mon Sep 17 00:00:00 2001
From: "Fomenko, Evarist M" <evarist.m.fomenko@intel.com>
Date: Fri, 24 Aug 2018 17:47:47 +0000
Subject: [PATCH] cpu: softmax: initialize max with -FLT_MAX instead of 0
this fixes #106
---
src/cpu/ref_softmax.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/cpu/ref_softmax.cpp b/src/cpu/ref_softmax.cpp
index 0152501f..f2327796 100644
--- a/src/cpu/ref_softmax.cpp
+++ b/src/cpu/ref_softmax.cpp
@@ -15,6 +15,7 @@
*******************************************************************************/
#include <assert.h>
+#include <float.h>
#include <math.h>
#include "c_types_map.hpp"
@@ -59,7 +60,7 @@ void ref_softmax_fwd_t<data_type>::execute_forward_generic() {
const size_t dim = channels_ * inner_size_;
for (int ou = 0; ou < outer_size_; ou++) {
- utils::array_set(max_, 0, inner_size_);
+ utils::array_set(max_, -FLT_MAX, inner_size_);
utils::array_set(denom_, 0, inner_size_);
for (int c = 0; c < channels_; c++) {
--
2.11.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment