|
|
@ -33,22 +33,14 @@ class Im2SequenceOp : public framework::OperatorWithKernel {
|
|
|
|
|
|
|
|
|
|
|
|
PADDLE_ENFORCE_EQ(in_dim.size(), 4,
|
|
|
|
PADDLE_ENFORCE_EQ(in_dim.size(), 4,
|
|
|
|
"Input(X) format must be 4D tensor, eg., NCHW.");
|
|
|
|
"Input(X) format must be 4D tensor, eg., NCHW.");
|
|
|
|
int batch_size = in_dim[0];
|
|
|
|
|
|
|
|
int img_channels = in_dim[1];
|
|
|
|
int img_channels = in_dim[1];
|
|
|
|
int img_height = in_dim[2];
|
|
|
|
|
|
|
|
int img_width = in_dim[3];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto kernels = ctx->Attrs().Get<std::vector<int>>("kernels");
|
|
|
|
auto kernels = ctx->Attrs().Get<std::vector<int>>("kernels");
|
|
|
|
auto strides = ctx->Attrs().Get<std::vector<int>>("strides");
|
|
|
|
auto strides = ctx->Attrs().Get<std::vector<int>>("strides");
|
|
|
|
auto paddings = ctx->Attrs().Get<std::vector<int>>("paddings");
|
|
|
|
auto paddings = ctx->Attrs().Get<std::vector<int>>("paddings");
|
|
|
|
|
|
|
|
|
|
|
|
int output_height = Im2SeqOutputSize(img_height, kernels[0], paddings[0],
|
|
|
|
ctx->SetOutputDim("Out",
|
|
|
|
paddings[2], strides[0]);
|
|
|
|
{in_dim[0], img_channels * kernels[0] * kernels[1]});
|
|
|
|
int output_width = Im2SeqOutputSize(img_width, kernels[1], paddings[1],
|
|
|
|
|
|
|
|
paddings[3], strides[1]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx->SetOutputDim("Out", {batch_size * output_height * output_width,
|
|
|
|
|
|
|
|
img_channels * kernels[0] * kernels[1]});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|