You need to sign in or sign up before continuing.
未验证 提交 6e29c2da 编写于 作者: J Jack Zhou 提交者: GitHub

Error description optimize for the math dir

Error description optimize for the math dir
上级 e25bcc98
...@@ -226,8 +226,8 @@ TEST(math_funciton, set_constant) { ...@@ -226,8 +226,8 @@ TEST(math_funciton, set_constant) {
for (int64_t i = 0; i < t.numel(); ++i) { for (int64_t i = 0; i < t.numel(); ++i) {
PADDLE_ENFORCE_EQ(10, t.data<int>()[i], PADDLE_ENFORCE_EQ(10, t.data<int>()[i],
paddle::platform::errors::InvalidArgument( paddle::platform::errors::InvalidArgument(
"Each value of input" "Each value of input tensor should be 10, "
"tensor should be 10, but received %d.", "but received %d.",
t.data<int>()[i])); t.data<int>()[i]));
} }
delete ctx; delete ctx;
......
...@@ -33,10 +33,10 @@ namespace math { ...@@ -33,10 +33,10 @@ namespace math {
class Sampler { class Sampler {
public: public:
explicit Sampler(int64_t range, unsigned int seed = 0UL) : range_(range) { explicit Sampler(int64_t range, unsigned int seed = 0UL) : range_(range) {
PADDLE_ENFORCE_GT(range, 0, platform::errors::InvalidArgument( PADDLE_ENFORCE_GT(
"Range should be" range, 0,
" greater than 0, but recevied %d.", platform::errors::InvalidArgument(
range)); "Range should be greater than 0, but recevied %d.", range));
if (seed == 0) { if (seed == 0) {
std::random_device r; std::random_device r;
seed_ = r(); seed_ = r();
......
...@@ -34,15 +34,14 @@ class Vol2ColFunctor<platform::CPUDeviceContext, T> { ...@@ -34,15 +34,14 @@ class Vol2ColFunctor<platform::CPUDeviceContext, T> {
const std::vector<int>& strides, const std::vector<int>& strides,
const std::vector<int>& paddings, framework::Tensor* col, const std::vector<int>& paddings, framework::Tensor* col,
const DataLayout data_layout) const { const DataLayout data_layout) const {
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(vol.dims().size(), 4,
vol.dims().size(), 4, platform::errors::InvalidArgument(
platform::errors::InvalidArgument("The dimension of" "The dimension of vol should be 4, but received %d.",
" vol should be 4, but received %d.",
vol.dims().size())); vol.dims().size()));
PADDLE_ENFORCE_EQ(
col->dims().size(), 7, PADDLE_ENFORCE_EQ(col->dims().size(), 7,
platform::errors::InvalidArgument("The dimension of" platform::errors::InvalidArgument(
"col should be 7, but received %d.", "The dimension of col should be 7, but received %d.",
col->dims().size())); col->dims().size()));
int input_channels = int input_channels =
...@@ -152,15 +151,14 @@ class Col2VolFunctor<platform::CPUDeviceContext, T> { ...@@ -152,15 +151,14 @@ class Col2VolFunctor<platform::CPUDeviceContext, T> {
const std::vector<int>& strides, const std::vector<int>& strides,
const std::vector<int>& paddings, framework::Tensor* vol, const std::vector<int>& paddings, framework::Tensor* vol,
const DataLayout data_layout) const { const DataLayout data_layout) const {
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(vol->dims().size(), 4,
vol->dims().size(), 4, platform::errors::InvalidArgument(
platform::errors::InvalidArgument("The dimension of vol" "The dimension of vol should be 4, but received %d.",
" should be 4, but received %d.",
vol->dims().size())); vol->dims().size()));
PADDLE_ENFORCE_EQ(
col.dims().size(), 7, PADDLE_ENFORCE_EQ(col.dims().size(), 7,
platform::errors::InvalidArgument("The dimension of col" platform::errors::InvalidArgument(
" should be 7, but received %d.", "The dimension of col should be 7, but received %d.",
col.dims().size())); col.dims().size()));
int input_channels = int input_channels =
...@@ -192,28 +190,28 @@ class Col2VolFunctor<platform::CPUDeviceContext, T> { ...@@ -192,28 +190,28 @@ class Col2VolFunctor<platform::CPUDeviceContext, T> {
((dilations[0] * (filter_depth - 1) + 1))) / ((dilations[0] * (filter_depth - 1) + 1))) /
strides[0] + strides[0] +
1; 1;
PADDLE_ENFORCE_EQ(input_depth_tmp, output_depth, PADDLE_ENFORCE_EQ(
input_depth_tmp, output_depth,
platform::errors::InvalidArgument( platform::errors::InvalidArgument(
"input_depth(%d)" "input_depth(%d) and output_depth(%d) are mismatching.",
" and output_depth(%d) are mismatching.",
input_depth_tmp, output_depth)); input_depth_tmp, output_depth));
auto input_height_tmp = (input_height + pad_h_up + pad_h_down - auto input_height_tmp = (input_height + pad_h_up + pad_h_down -
((dilations[1] * (filter_height - 1) + 1))) / ((dilations[1] * (filter_height - 1) + 1))) /
strides[1] + strides[1] +
1; 1;
PADDLE_ENFORCE_EQ(input_height_tmp, output_height, PADDLE_ENFORCE_EQ(
input_height_tmp, output_height,
platform::errors::InvalidArgument( platform::errors::InvalidArgument(
"input_height(%d)" "input_height(%d) and output_height(%d) are mismatching.",
" and output_height(%d) are mismatching.",
input_height_tmp, output_height)); input_height_tmp, output_height));
auto input_width_tmp = (input_width + pad_w_left + pad_w_right - auto input_width_tmp = (input_width + pad_w_left + pad_w_right -
((dilations[2] * (filter_width - 1) + 1))) / ((dilations[2] * (filter_width - 1) + 1))) /
strides[2] + strides[2] +
1; 1;
PADDLE_ENFORCE_EQ(input_width_tmp, output_width, PADDLE_ENFORCE_EQ(
input_width_tmp, output_width,
platform::errors::InvalidArgument( platform::errors::InvalidArgument(
"input_width(%d)" "input_width(%d) and output_width(%d) are mismatching.",
" and output_width(%d) are mismatching.",
input_width_tmp, output_width)); input_width_tmp, output_width));
T* vol_data = vol->data<T>(); T* vol_data = vol->data<T>();
const T* col_data = col.data<T>(); const T* col_data = col.data<T>();
......
...@@ -90,15 +90,13 @@ class Vol2ColFunctor<platform::CUDADeviceContext, T> { ...@@ -90,15 +90,13 @@ class Vol2ColFunctor<platform::CUDADeviceContext, T> {
const std::vector<int>& strides, const std::vector<int>& strides,
const std::vector<int>& paddings, framework::Tensor* col, const std::vector<int>& paddings, framework::Tensor* col,
const DataLayout data_layout) const { const DataLayout data_layout) const {
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(vol.dims().size(), 4,
vol.dims().size(), 4, platform::errors::InvalidArgument(
platform::errors::InvalidArgument("The dimension of" "The dimension of vol should be 4, but received %d.",
" vol should be 4, but received %d.",
vol.dims().size())); vol.dims().size()));
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(col->dims().size(), 7,
col->dims().size(), 7, platform::errors::InvalidArgument(
platform::errors::InvalidArgument("The dimension of" "The dimension of col should be 7, but received %d.",
"col should be 7, but received %d.",
col->dims().size())); col->dims().size()));
int input_channels = int input_channels =
...@@ -253,15 +251,13 @@ class Col2VolFunctor<platform::CUDADeviceContext, T> { ...@@ -253,15 +251,13 @@ class Col2VolFunctor<platform::CUDADeviceContext, T> {
const std::vector<int>& strides, const std::vector<int>& strides,
const std::vector<int>& paddings, framework::Tensor* vol, const std::vector<int>& paddings, framework::Tensor* vol,
const DataLayout data_layout) const { const DataLayout data_layout) const {
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(vol->dims().size(), 4,
vol->dims().size(), 4, platform::errors::InvalidArgument(
platform::errors::InvalidArgument("The dimension of vol" "The dimension of vol should be 4, but received %d.",
" should be 4, but received %d.",
vol->dims().size())); vol->dims().size()));
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(col.dims().size(), 7,
col.dims().size(), 7, platform::errors::InvalidArgument(
platform::errors::InvalidArgument("The dimension of col" "The dimension of col should be 7, but received %d.",
" should be 7, but received %d.",
col.dims().size())); col.dims().size()));
int input_channels = int input_channels =
...@@ -291,28 +287,28 @@ class Col2VolFunctor<platform::CUDADeviceContext, T> { ...@@ -291,28 +287,28 @@ class Col2VolFunctor<platform::CUDADeviceContext, T> {
((dilations[0] * (filter_depth - 1) + 1))) / ((dilations[0] * (filter_depth - 1) + 1))) /
strides[0] + strides[0] +
1; 1;
PADDLE_ENFORCE_EQ(input_depth_tmp, output_depth, PADDLE_ENFORCE_EQ(
input_depth_tmp, output_depth,
platform::errors::InvalidArgument( platform::errors::InvalidArgument(
"input_depth(%d)" "input_depth(%d) and output_depth(%d) are mismatching.",
" and output_depth(%d) are mismatching.",
input_depth_tmp, output_depth)); input_depth_tmp, output_depth));
auto input_height_tmp = (input_height + pad_h_up + pad_h_down - auto input_height_tmp = (input_height + pad_h_up + pad_h_down -
((dilations[1] * (filter_height - 1) + 1))) / ((dilations[1] * (filter_height - 1) + 1))) /
strides[1] + strides[1] +
1; 1;
PADDLE_ENFORCE_EQ(input_height_tmp, output_height, PADDLE_ENFORCE_EQ(
input_height_tmp, output_height,
platform::errors::InvalidArgument( platform::errors::InvalidArgument(
"input_height(%d)" "input_height(%d) and output_height(%d) are mismatching.",
" and output_height(%d) are mismatching.",
input_height_tmp, output_height)); input_height_tmp, output_height));
auto input_width_tmp = (input_width + pad_w_left + pad_w_right - auto input_width_tmp = (input_width + pad_w_left + pad_w_right -
((dilations[2] * (filter_width - 1) + 1))) / ((dilations[2] * (filter_width - 1) + 1))) /
strides[2] + strides[2] +
1; 1;
PADDLE_ENFORCE_EQ(input_width_tmp, output_width, PADDLE_ENFORCE_EQ(
input_width_tmp, output_width,
platform::errors::InvalidArgument( platform::errors::InvalidArgument(
"input_width(%d)" "input_width(%d) and output_width(%d) are mismatching.",
" and output_width(%d) are mismatching.",
input_width_tmp, output_width)); input_width_tmp, output_width));
int num_kernels = input_channels * input_depth * input_height * input_width; int num_kernels = input_channels * input_depth * input_height * input_width;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册