Skip to content
Snippets Groups Projects
Commit b9b5fa3a authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Fixed wrong offsets

parent 472e2c62
No related branches found
No related tags found
2 merge requests!166Update 0.5.0 -> 0.6.0,!158Added OpenMP
...@@ -210,8 +210,8 @@ void ConvDepthWiseImpl2D_cpu_forward_kernel(const std::array<DimSize_t, 2>& stri ...@@ -210,8 +210,8 @@ void ConvDepthWiseImpl2D_cpu_forward_kernel(const std::array<DimSize_t, 2>& stri
const std::size_t wIndex = ch; const std::size_t wIndex = ch;
if (strideDims[0] == 1 && strideDims[1] == 1) { if (strideDims[0] == 1 && strideDims[1] == 1) {
for (std::size_t i = iIndex; i < iIndex + oxSize*oySize; ++i) { for (std::size_t i = 0; i < oxSize*oySize; ++i) {
output[oIndex + i] = biasVal + weights[wIndex] * input[i]; output[oIndex + i] = biasVal + weights[wIndex] * input[iIndex + i];
} }
} else { } else {
for (std::size_t ox = 0; ox < oxSize; ++ox, oIndex+=oySize, iIndex+=strideDims[0]*inputDims[3]) { for (std::size_t ox = 0; ox < oxSize; ++ox, oIndex+=oySize, iIndex+=strideDims[0]*inputDims[3]) {
......
...@@ -486,13 +486,13 @@ void ConvImpl2D_cpu_forward_kernel(const array<DimSize_t, 2> &strideDims, ...@@ -486,13 +486,13 @@ void ConvImpl2D_cpu_forward_kernel(const array<DimSize_t, 2> &strideDims,
#endif #endif
for (int batch = 0; batch < static_cast<int>(inputDims[0]); ++batch) { for (int batch = 0; batch < static_cast<int>(inputDims[0]); ++batch) {
for (int outCh = 0; outCh < static_cast<int>(outChannels); ++outCh) { for (int outCh = 0; outCh < static_cast<int>(outChannels); ++outCh) {
std::size_t oIndex = (outCh + batch*inputDims[1]) * outChannels_s; std::size_t oIndex = (outCh + batch*outChannels) * outChannels_s;
// If bias = nullptr, set B(0) // If bias = nullptr, set B(0)
B biasVal = (biases != nullptr) ? biases[outCh] : B(0); B biasVal = (biases != nullptr) ? biases[outCh] : B(0);
std::fill(output + oIndex, output + oIndex + outChannels_s, biasVal); std::fill(output + oIndex, output + oIndex + outChannels_s, biasVal);
for (std::size_t inCh = 0; inCh < inputDims[1]; ++inCh) { for (std::size_t inCh = 0; inCh < inputDims[1]; ++inCh) {
oIndex = (outCh + batch*inputDims[1]) * outChannels_s; oIndex = (outCh + batch*outChannels) * outChannels_s;
std::size_t iIndex = (inCh + batch * inputDims[1]) * std::size_t iIndex = (inCh + batch * inputDims[1]) *
inputDims[2] * inputDims[3]; inputDims[2] * inputDims[3];
const std::size_t wIndex = const std::size_t wIndex =
...@@ -575,13 +575,13 @@ void ConvImpl2D_cpu_forward_kernel(const array<DimSize_t, 2> &strideDims, ...@@ -575,13 +575,13 @@ void ConvImpl2D_cpu_forward_kernel(const array<DimSize_t, 2> &strideDims,
#endif #endif
for (int batch = 0; batch < static_cast<int>(inputDims[0]); ++batch) { for (int batch = 0; batch < static_cast<int>(inputDims[0]); ++batch) {
for (int outCh = 0; outCh < static_cast<int>(outChannels); ++outCh) { for (int outCh = 0; outCh < static_cast<int>(outChannels); ++outCh) {
std::size_t oIndex = (outCh + batch*inputDims[1]) * outChannels_s; std::size_t oIndex = (outCh + batch*outChannels) * outChannels_s;
// If bias = nullptr, set B(0) // If bias = nullptr, set B(0)
B biasVal = (biases != nullptr) ? biases[outCh] : B(0); B biasVal = (biases != nullptr) ? biases[outCh] : B(0);
std::fill(output + oIndex, output + oIndex + outChannels_s, biasVal); std::fill(output + oIndex, output + oIndex + outChannels_s, biasVal);
for (std::size_t inCh = 0; inCh < inputDims[1]; ++inCh) { for (std::size_t inCh = 0; inCh < inputDims[1]; ++inCh) {
oIndex = (outCh + batch*inputDims[1]) * outChannels_s; oIndex = (outCh + batch*outChannels) * outChannels_s;
std::size_t iIndex = (inCh + batch * inputDims[1]) * std::size_t iIndex = (inCh + batch * inputDims[1]) *
inputDims[2] * inputDims[3]; inputDims[2] * inputDims[3];
const std::size_t wIndex = (inCh + outCh * inputDims[1]); const std::size_t wIndex = (inCh + outCh * inputDims[1]);
...@@ -611,13 +611,13 @@ void ConvImpl2D_cpu_forward_kernel(const array<DimSize_t, 2> &strideDims, ...@@ -611,13 +611,13 @@ void ConvImpl2D_cpu_forward_kernel(const array<DimSize_t, 2> &strideDims,
#endif #endif
for (int batch = 0; batch < static_cast<int>(inputDims[0]); ++batch) { for (int batch = 0; batch < static_cast<int>(inputDims[0]); ++batch) {
for (int outCh = 0; outCh < static_cast<int>(outChannels); ++outCh) { for (int outCh = 0; outCh < static_cast<int>(outChannels); ++outCh) {
std::size_t oIndex = (outCh + batch*inputDims[1]) * outChannels_s; std::size_t oIndex = (outCh + batch*outChannels) * outChannels_s;
// If bias = nullptr, set B(0) // If bias = nullptr, set B(0)
B biasVal = (biases != nullptr) ? biases[outCh] : B(0); B biasVal = (biases != nullptr) ? biases[outCh] : B(0);
std::fill(output + oIndex, output + oIndex + outChannels_s, biasVal); std::fill(output + oIndex, output + oIndex + outChannels_s, biasVal);
for (std::size_t inCh = 0; inCh < inputDims[1]; ++inCh) { for (std::size_t inCh = 0; inCh < inputDims[1]; ++inCh) {
oIndex = (outCh + batch*inputDims[1]) * outChannels_s; oIndex = (outCh + batch*outChannels) * outChannels_s;
std::size_t iIndex_channel = std::size_t iIndex_channel =
(inCh + batch * inputDims[1]) * inputDims[2] * (inCh + batch * inputDims[1]) * inputDims[2] *
inputDims[3]; inputDims[3];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment