Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion paddle/phi/kernels/sparse/cpu/unary_grad_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@

PD_REGISTER_SPARSE_UNARY_CPU_GRAD_KERNEL(asin, Asin)
PD_REGISTER_SPARSE_UNARY_CPU_GRAD_KERNEL(atan, Atan)
PD_REGISTER_SPARSE_UNARY_CPU_GRAD_KERNEL(tanh, Tanh)
PD_REGISTER_SPARSE_UNARY_CPU_GRAD_KERNEL(asinh, Asinh)
PD_REGISTER_SPARSE_UNARY_CPU_GRAD_KERNEL(atanh, Atanh)
PD_REGISTER_SPARSE_UNARY_CPU_GRAD_KERNEL(sqrt, Sqrt)
Expand All @@ -78,6 +77,7 @@ PD_REGISTER_SPARSE_UNARY_CPU_GRAD_KERNEL_WITH_COMPLEX(sinh, Sinh)
PD_REGISTER_SPARSE_UNARY_CPU_GRAD_KERNEL_WITH_COMPLEX(tan, Tan)
PD_REGISTER_SPARSE_UNARY_CPU_GRAD_KERNEL_WITH_COMPLEX(sin, Sin)
PD_REGISTER_SPARSE_UNARY_CPU_GRAD_KERNEL_WITH_COMPLEX(abs, Abs)
PD_REGISTER_SPARSE_UNARY_CPU_GRAD_KERNEL_WITH_COMPLEX(tanh, Tanh)

PD_REGISTER_KERNEL(cast_coo_grad,
CPU,
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/sparse/cpu/unary_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ void DivScalarCsrKernel(const Context& dev_ctx,

PD_REGISTER_SPARSE_UNARY_CPU_KERNEL(asin, Asin)
PD_REGISTER_SPARSE_UNARY_CPU_KERNEL(atan, Atan)
PD_REGISTER_SPARSE_UNARY_CPU_KERNEL(tanh, Tanh)
PD_REGISTER_SPARSE_UNARY_CPU_KERNEL(asinh, Asinh)
PD_REGISTER_SPARSE_UNARY_CPU_KERNEL(atanh, Atanh)
PD_REGISTER_SPARSE_UNARY_CPU_KERNEL(sqrt, Sqrt)
Expand All @@ -116,6 +115,7 @@ PD_REGISTER_SPARSE_UNARY_CPU_KERNEL(expm1, Expm1)
PD_REGISTER_SPARSE_UNARY_CPU_KERNEL(relu6, Relu6)
PD_REGISTER_SPARSE_UNARY_CPU_KERNEL(leaky_relu, LeakyRelu)

PD_REGISTER_SPARSE_UNARY_CPU_KERNEL_WITH_COMPLEX(tanh, Tanh)
PD_REGISTER_SPARSE_UNARY_CPU_KERNEL_WITH_COMPLEX(sinh, Sinh)
PD_REGISTER_SPARSE_UNARY_CPU_KERNEL_WITH_COMPLEX(tan, Tan)
PD_REGISTER_SPARSE_UNARY_CPU_KERNEL_WITH_COMPLEX(sin, Sin)
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/sparse/gpu/unary_grad_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@

PD_REGISTER_SPARSE_UNARY_GPU_GRAD_KERNEL(asin, Asin)
PD_REGISTER_SPARSE_UNARY_GPU_GRAD_KERNEL(atan, Atan)
PD_REGISTER_SPARSE_UNARY_GPU_GRAD_KERNEL(tanh, Tanh)
PD_REGISTER_SPARSE_UNARY_GPU_GRAD_KERNEL(asinh, Asinh)
PD_REGISTER_SPARSE_UNARY_GPU_GRAD_KERNEL(atanh, Atanh)
PD_REGISTER_SPARSE_UNARY_GPU_GRAD_KERNEL(sqrt, Sqrt)
Expand All @@ -82,6 +81,7 @@ PD_REGISTER_SPARSE_UNARY_GPU_GRAD_KERNEL_WITH_COMPLEX(sinh, Sinh)
PD_REGISTER_SPARSE_UNARY_GPU_GRAD_KERNEL_WITH_COMPLEX(sin, Sin)
PD_REGISTER_SPARSE_UNARY_GPU_GRAD_KERNEL_WITH_COMPLEX(abs, Abs)
PD_REGISTER_SPARSE_UNARY_GPU_GRAD_KERNEL_WITH_COMPLEX(tan, Tan)
PD_REGISTER_SPARSE_UNARY_GPU_GRAD_KERNEL_WITH_COMPLEX(tanh, Tanh)

PD_REGISTER_KERNEL(cast_coo_grad,
GPU,
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/sparse/gpu/unary_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ void DivScalarCsrKernel(const Context& dev_ctx,

PD_REGISTER_SPARSE_UNARY_GPU_KERNEL(asin, Asin)
PD_REGISTER_SPARSE_UNARY_GPU_KERNEL(atan, Atan)
PD_REGISTER_SPARSE_UNARY_GPU_KERNEL(tanh, Tanh)
PD_REGISTER_SPARSE_UNARY_GPU_KERNEL(asinh, Asinh)
PD_REGISTER_SPARSE_UNARY_GPU_KERNEL(atanh, Atanh)
PD_REGISTER_SPARSE_UNARY_GPU_KERNEL(sqrt, Sqrt)
Expand All @@ -109,6 +108,7 @@ PD_REGISTER_SPARSE_UNARY_GPU_KERNEL(expm1, Expm1)
PD_REGISTER_SPARSE_UNARY_GPU_KERNEL(relu6, Relu6)
PD_REGISTER_SPARSE_UNARY_GPU_KERNEL(leaky_relu, LeakyRelu)

PD_REGISTER_SPARSE_UNARY_GPU_KERNEL_WITH_COMPLEX(tanh, Tanh)
PD_REGISTER_SPARSE_UNARY_GPU_KERNEL_WITH_COMPLEX(sinh, Sinh)
PD_REGISTER_SPARSE_UNARY_GPU_KERNEL_WITH_COMPLEX(tan, Tan)
PD_REGISTER_SPARSE_UNARY_GPU_KERNEL_WITH_COMPLEX(sin, Sin)
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/sparse/impl/unary_kernel_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ namespace sparse {

DEFINE_SPARSE_UNARY_KERNEL(Asin)
DEFINE_SPARSE_UNARY_KERNEL(Atan)
DEFINE_SPARSE_UNARY_KERNEL(Tanh)
DEFINE_SPARSE_UNARY_KERNEL(Asinh)
DEFINE_SPARSE_UNARY_KERNEL(Atanh)
DEFINE_SPARSE_UNARY_KERNEL(Sqrt)
Expand All @@ -120,6 +119,7 @@ DEFINE_SPARSE_UNARY_KERNEL_WITH_COMPLEX(Abs)
DEFINE_SPARSE_UNARY_KERNEL_WITH_COMPLEX(Sin)
DEFINE_SPARSE_UNARY_KERNEL_WITH_COMPLEX(Tan)
DEFINE_SPARSE_UNARY_KERNEL_WITH_COMPLEX(Sinh)
DEFINE_SPARSE_UNARY_KERNEL_WITH_COMPLEX(Tanh)

template <typename T, typename Context>
void ScaleCooKernel(const Context& dev_ctx,
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/sparse/unary.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def tanh(x: Tensor, name: str | None = None) -> Tensor:
out = tanh(x)

Parameters:
x (Tensor): The input Sparse Tensor with data type float32, float64.
x (Tensor): The input Sparse Tensor with data type float32, float64, complex64, complex128.
name (str|None, optional): Name for the operation (optional, default is None).
For more information, please refer to :ref:`api_guide_Name`.

Expand Down
12 changes: 10 additions & 2 deletions test/legacy_test/test_sparse_unary_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ def test_sparse_atan(self):
self.compare_with_dense(paddle.atan, paddle.sparse.atan)

def test_sparse_tanh(self):
self.compare_with_dense(paddle.tanh, paddle.sparse.tanh)
self.compare_with_dense(paddle.tanh, paddle.sparse.tanh, 'float16')
self.compare_with_dense(paddle.tanh, paddle.sparse.tanh, 'float32')
self.compare_with_dense(paddle.tanh, paddle.sparse.tanh, 'float64')
self.compare_with_dense(paddle.tanh, paddle.sparse.tanh, 'complex64')
self.compare_with_dense(paddle.tanh, paddle.sparse.tanh, 'complex128')

def test_sparse_asinh(self):
self.compare_with_dense(paddle.asinh, paddle.sparse.asinh)
Expand Down Expand Up @@ -421,7 +425,11 @@ def test_sparse_atan(self):
self.compare_with_dense(paddle.atan, paddle.sparse.atan)

def test_sparse_tanh(self):
self.compare_with_dense(paddle.tanh, paddle.sparse.tanh)
self.compare_with_dense(paddle.tanh, paddle.sparse.tanh, 'float16')
self.compare_with_dense(paddle.tanh, paddle.sparse.tanh, 'float32')
self.compare_with_dense(paddle.tanh, paddle.sparse.tanh, 'float64')
self.compare_with_dense(paddle.tanh, paddle.sparse.tanh, 'complex64')
self.compare_with_dense(paddle.tanh, paddle.sparse.tanh, 'complex128')

def test_sparse_asinh(self):
self.compare_with_dense(paddle.asinh, paddle.sparse.asinh)
Expand Down