From: Parichay Kapoor Date: Mon, 20 Jul 2020 04:49:09 +0000 (+0900) Subject: [activation] Update input arguments of softmax X-Git-Tag: accepted/tizen/unified/20200721.042553~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5cd56b0e9a50fbf74bff229ddba17fa68e940834;p=platform%2Fcore%2Fml%2Fnntrainer.git [activation] Update input arguments of softmax Update input arguments of softmax to Tensor const & from Tensor to match activation function signature Signed-off-by: Parichay Kapoor --- diff --git a/nntrainer/include/util_func.h b/nntrainer/include/util_func.h index d913bac..66a606f 100644 --- a/nntrainer/include/util_func.h +++ b/nntrainer/include/util_func.h @@ -40,14 +40,14 @@ unsigned int getSeed(); * @param[in] x Tensor * @retVal Tensor */ -Tensor softmaxPrime(Tensor x); +Tensor softmaxPrime(Tensor const &x); /** * @brief Calculate softmax for Tensor Type * @param[in] t Tensor * @retval Tensor */ -Tensor softmax(Tensor t); +Tensor softmax(Tensor const &t); /** * @brief random function diff --git a/nntrainer/src/util_func.cpp b/nntrainer/src/util_func.cpp index f570d64..97e032d 100644 --- a/nntrainer/src/util_func.cpp +++ b/nntrainer/src/util_func.cpp @@ -37,7 +37,7 @@ static std::uniform_real_distribution dist(-0.5, 0.5); unsigned int getSeed() { return 0; } -Tensor softmaxPrime(Tensor x) { +Tensor softmaxPrime(Tensor const &x) { /** @todo Fix this to use derivative */ int batch = x.getBatch(); int channel = x.getChannel(); @@ -47,7 +47,7 @@ Tensor softmaxPrime(Tensor x) { Tensor PI = Tensor(x.getDim()); - float *xp = x.getData(); + const float *xp = x.getData(); float *pp = PI.getData(); for (int k = 0; k < batch; ++k) { @@ -73,7 +73,7 @@ Tensor softmaxPrime(Tensor x) { return PI; } -Tensor softmax(Tensor t) { +Tensor softmax(Tensor const &t) { /** * shiftx_logit = logit - max_batch(logit) * softmax = exp(shiftx_logit) / (sum(exp(shiftx_logit))) @@ -84,7 +84,7 @@ Tensor softmax(Tensor t) { int width = t.getWidth(); float *dp; float *rp; - float *tp; + const float *tp; Tensor result(t.getDim()); Tensor divisor(t.getDim());