|
|
|
@ -37,7 +37,13 @@ class Unpool2dMaxFunctor<platform::CPUDeviceContext, T> {
|
|
|
|
|
for (int c = 0; c < output_channels; ++c) {
|
|
|
|
|
for (int i = 0; i < input_feasize; ++i) {
|
|
|
|
|
int index = indices_data[i];
|
|
|
|
|
PADDLE_ENFORCE(index < output_feasize, "err index in unpooling!");
|
|
|
|
|
PADDLE_ENFORCE_LT(
|
|
|
|
|
index, output_feasize,
|
|
|
|
|
platform::errors::InvalidArgument(
|
|
|
|
|
"index should less than output tensor height * output tensor "
|
|
|
|
|
"width. Expected %ld < %ld, but got "
|
|
|
|
|
"%ld >= %ld. Please check input value.",
|
|
|
|
|
index, output_feasize, index, output_feasize));
|
|
|
|
|
output_data[index] = input_data[i];
|
|
|
|
|
}
|
|
|
|
|
input_data += input_feasize;
|
|
|
|
@ -72,7 +78,13 @@ class Unpool2dMaxGradFunctor<platform::CPUDeviceContext, T> {
|
|
|
|
|
for (int c = 0; c < output_channels; ++c) {
|
|
|
|
|
for (int i = 0; i < input_feasize; ++i) {
|
|
|
|
|
int index = indices_data[i];
|
|
|
|
|
PADDLE_ENFORCE(index < output_feasize, "err index in unpooling!");
|
|
|
|
|
PADDLE_ENFORCE_LT(
|
|
|
|
|
index, output_feasize,
|
|
|
|
|
platform::errors::InvalidArgument(
|
|
|
|
|
"index should less than output tensor height * output tensor "
|
|
|
|
|
"width. Expected %ld < %ld, but got "
|
|
|
|
|
"%ld >= %ld. Please check input value.",
|
|
|
|
|
index, output_feasize, index, output_feasize));
|
|
|
|
|
input_grad_data[i] = output_grad_data[index];
|
|
|
|
|
}
|
|
|
|
|
input_grad_data += input_feasize;
|
|
|
|
|