Skip to content

Commit

Permalink
[CodeStyle] Fix codestyle regression introduced in PaddlePaddle#66139 (
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo authored and inaomIIsfarell committed Jul 31, 2024
1 parent 9a28a6b commit e81b518
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion paddle/phi/kernels/cpu/l1_norm_grad_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "paddle/phi/kernels/l1_norm_kernel.h"
#include "paddle/phi/kernels/funcs/eigen/common.h"
#include "paddle/phi/kernels/funcs/eigen/eigen_function.h"
#include "paddle/phi/kernels/l1_norm_kernel.h"
namespace phi {
// Out = sum(abs(X))
template <typename T, typename Context>
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/gpu/l1_norm_grad_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "paddle/phi/kernels/l1_norm_kernel.h"
#include "paddle/phi/kernels/funcs/eigen/common.h"
#include "paddle/phi/kernels/funcs/eigen/eigen_function.h"
#include "paddle/phi/kernels/l1_norm_kernel.h"
namespace phi {
// Out = sum(abs(X))
template <typename T, typename Context>
Expand Down
18 changes: 11 additions & 7 deletions test/legacy_test/test_sparse_reshape_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,13 @@ def test_reshape_with_zero_or_minus_one_in_new_shape(self):
else:
devices.append('cpu')


class TestSparseReshapeStatic(unittest.TestCase):
"""
Test the API paddle.sparse.reshape on some sparse tensors. static graph
Test the API paddle.sparse.reshape on some sparse tensors. static graph
x: sparse, out: sparse
"""

def check_result_coo(self, x_shape, new_shape):
"""
x_shape: original shape
Expand All @@ -180,8 +182,12 @@ def check_result_coo(self, x_shape, new_shape):
paddle.rand(x_shape, dtype='float32') + 1
) * mask.astype('float32')
indices_data, values_data = (
origin_data.detach().to_sparse_coo(sparse_dim=len(x_shape)).indices(),
origin_data.detach().to_sparse_coo(sparse_dim=len(x_shape)).values()
origin_data.detach()
.to_sparse_coo(sparse_dim=len(x_shape))
.indices(),
origin_data.detach()
.to_sparse_coo(sparse_dim=len(x_shape))
.values(),
)

dense_x = origin_data
Expand All @@ -192,7 +198,6 @@ def check_result_coo(self, x_shape, new_shape):
with paddle.static.program_guard(
paddle.static.Program(), paddle.static.Program()
):

indices = paddle.static.data(
name='indices',
shape=indices_data.shape,
Expand All @@ -209,7 +214,7 @@ def check_result_coo(self, x_shape, new_shape):
shape=dense_x.shape,
dtype=dense_x.dtype,
)

sp_out = paddle.sparse.reshape(sp_x, new_shape)
sp_dense_out = sp_out.to_dense()

Expand All @@ -228,8 +233,6 @@ def check_result_coo(self, x_shape, new_shape):
)
paddle.disable_static()



def test_reshape_2d(self):
self.check_result_coo(
[2, 5],
Expand Down Expand Up @@ -276,5 +279,6 @@ def test_reshape_with_zero_or_minus_one_in_new_shape(self):
self.check_result_coo([6, 2, 3], [-1, 9, 1])
self.check_result_coo([6, 2, 3], [-1, 1, 3])


if __name__ == "__main__":
unittest.main()

0 comments on commit e81b518

Please sign in to comment.