提交 f1a94e3f 编写于 作者: H hedaoyuan

follow comments

上级 bf324111
...@@ -20,7 +20,7 @@ namespace paddle { ...@@ -20,7 +20,7 @@ namespace paddle {
template <> template <>
void CrossMapNormal<DEVICE_TYPE_CPU>(real* outputs, void CrossMapNormal<DEVICE_TYPE_CPU>(real* outputs,
real* denoms, real* denoms,
real* inputs, const real* inputs,
size_t numSamples, size_t numSamples,
size_t channels, size_t channels,
size_t height, size_t height,
...@@ -32,7 +32,7 @@ void CrossMapNormal<DEVICE_TYPE_CPU>(real* outputs, ...@@ -32,7 +32,7 @@ void CrossMapNormal<DEVICE_TYPE_CPU>(real* outputs,
size_t oneSample = channels * oneImage; size_t oneSample = channels * oneImage;
CpuVector outputsV(numSamples * oneSample, outputs); CpuVector outputsV(numSamples * oneSample, outputs);
CpuVector inputsV(numSamples * oneSample, inputs); CpuVector inputsV(numSamples * oneSample, const_cast<real*>(inputs));
CpuVector denomsV(numSamples * oneSample, denoms); CpuVector denomsV(numSamples * oneSample, denoms);
// f(x) = x * ( 1 + scale * SUM((x)^2) )^(-pow) // f(x) = x * ( 1 + scale * SUM((x)^2) )^(-pow)
...@@ -44,7 +44,7 @@ void CrossMapNormal<DEVICE_TYPE_CPU>(real* outputs, ...@@ -44,7 +44,7 @@ void CrossMapNormal<DEVICE_TYPE_CPU>(real* outputs,
const int end = (int)size + start; const int end = (int)size + start;
for (size_t i = 0; i < numSamples; i++) { for (size_t i = 0; i < numSamples; i++) {
real* oneDenom = denoms + i * oneSample; real* oneDenom = denoms + i * oneSample;
real* oneInput = inputs + i * oneSample; real* oneInput = const_cast<real*>(inputs) + i * oneSample;
for (int c = 0; c < (int)channels; c++) { for (int c = 0; c < (int)channels; c++) {
CpuVector denom(oneImage, oneDenom + c * oneImage); CpuVector denom(oneImage, oneDenom + c * oneImage);
for (int s = start; s < end; s++) { for (int s = start; s < end; s++) {
...@@ -61,10 +61,10 @@ void CrossMapNormal<DEVICE_TYPE_CPU>(real* outputs, ...@@ -61,10 +61,10 @@ void CrossMapNormal<DEVICE_TYPE_CPU>(real* outputs,
template <> template <>
void CrossMapNormalGrad<DEVICE_TYPE_CPU>(real* inputsGrad, void CrossMapNormalGrad<DEVICE_TYPE_CPU>(real* inputsGrad,
real* inputsValue, const real* inputsValue,
real* outputsValue, const real* outputsValue,
real* outputsGrad, const real* outputsGrad,
real* denoms, const real* denoms,
size_t numSamples, size_t numSamples,
size_t channels, size_t channels,
size_t height, size_t height,
...@@ -84,10 +84,10 @@ void CrossMapNormalGrad<DEVICE_TYPE_CPU>(real* inputsGrad, ...@@ -84,10 +84,10 @@ void CrossMapNormalGrad<DEVICE_TYPE_CPU>(real* inputsGrad,
for (size_t i = 0; i < numSamples; i++) { for (size_t i = 0; i < numSamples; i++) {
size_t sOffset = i * oneSample; size_t sOffset = i * oneSample;
real* oneInputGrad = inputsGrad + sOffset; real* oneInputGrad = inputsGrad + sOffset;
real* oneInputValue = inputsValue + sOffset; real* oneInputValue = const_cast<real*>(inputsValue) + sOffset;
real* oneDenom = denoms + sOffset; real* oneDenom = const_cast<real*>(denoms) + sOffset;
real* oneOutputGrad = outputsGrad + sOffset; real* oneOutputGrad = const_cast<real*>(outputsGrad) + sOffset;
real* oneOutputValue = outputsValue + sOffset; real* oneOutputValue = const_cast<real*>(outputsValue) + sOffset;
for (int c = 0; c < (int)channels; c++) { for (int c = 0; c < (int)channels; c++) {
size_t cOffset = c * height * width; size_t cOffset = c * height * width;
......
...@@ -37,7 +37,7 @@ namespace paddle { ...@@ -37,7 +37,7 @@ namespace paddle {
template <DeviceType Device> template <DeviceType Device>
void CrossMapNormal(real* outputs, void CrossMapNormal(real* outputs,
real* denoms, real* denoms,
real* inputs, const real* inputs,
size_t numSamples, size_t numSamples,
size_t channels, size_t channels,
size_t height, size_t height,
...@@ -66,10 +66,10 @@ void CrossMapNormal(real* outputs, ...@@ -66,10 +66,10 @@ void CrossMapNormal(real* outputs,
*/ */
template <DeviceType Device> template <DeviceType Device>
void CrossMapNormalGrad(real* inputsGrad, void CrossMapNormalGrad(real* inputsGrad,
real* inputsValue, const real* inputsValue,
real* outputsValue, const real* outputsValue,
real* outputsGrad, const real* outputsGrad,
real* denoms, const real* denoms,
size_t numSamples, size_t numSamples,
size_t channels, size_t channels,
size_t height, size_t height,
......
...@@ -63,7 +63,7 @@ __global__ void KeCMRNormOutput(size_t inputSize, const real* in, ...@@ -63,7 +63,7 @@ __global__ void KeCMRNormOutput(size_t inputSize, const real* in,
template <> template <>
void CrossMapNormal<DEVICE_TYPE_GPU>(real* outputs, void CrossMapNormal<DEVICE_TYPE_GPU>(real* outputs,
real* denoms, real* denoms,
real* inputs, const real* inputs,
size_t numSamples, size_t numSamples,
size_t channels, size_t channels,
size_t height, size_t height,
...@@ -132,10 +132,10 @@ __global__ void KeCMRNormDiff(size_t imageSize, const real* bottom_data, ...@@ -132,10 +132,10 @@ __global__ void KeCMRNormDiff(size_t imageSize, const real* bottom_data,
template <> template <>
void CrossMapNormalGrad<DEVICE_TYPE_GPU>(real* inputsGrad, void CrossMapNormalGrad<DEVICE_TYPE_GPU>(real* inputsGrad,
real* inputsValue, const real* inputsValue,
real* outputsValue, const real* outputsValue,
real* outputsGrad, const real* outputsGrad,
real* denoms, const real* denoms,
size_t numSamples, size_t numSamples,
size_t channels, size_t channels,
size_t height, size_t height,
......
...@@ -18,7 +18,6 @@ limitations under the License. */ ...@@ -18,7 +18,6 @@ limitations under the License. */
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "TensorCheck.h" #include "TensorCheck.h"
#include "paddle/function/Function.h"
#include "paddle/gserver/tests/TestUtil.h" #include "paddle/gserver/tests/TestUtil.h"
#include "paddle/math/Matrix.h" #include "paddle/math/Matrix.h"
#include "paddle/math/SparseMatrix.h" #include "paddle/math/SparseMatrix.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册