Skip to content

Commit

Permalink
rename python files
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaishaonvjituizi committed May 6, 2022
1 parent 67d14b4 commit 268ac34
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 102 deletions.
8 changes: 4 additions & 4 deletions python/paddle/sparse/functional/__init__.py
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .activation import relu # noqa: F401
from .activation import tanh # noqa: F401
from .math import sqrt # noqa: F401
from .math import sin # noqa: F401
from .unary import relu # noqa: F401
from .unary import tanh # noqa: F401
from .unary import sqrt # noqa: F401
from .unary import sin # noqa: F401
from .conv import conv3d # noqa: F401
from .conv import subm_conv3d # noqa: F401
from .pooling import max_pool3d # noqa: F401
Expand Down
97 changes: 0 additions & 97 deletions python/paddle/sparse/functional/math.py

This file was deleted.

Expand Up @@ -95,3 +95,83 @@ def tanh(x, name=None):
raise ValueError(
"Currently, sparse.tanh only support the input of SparseCooTensor or SparseCsrTensor"
)


def sqrt(x, name=None):
"""
Calculate square root of x, requiring x to be a sparse coo or sparse csr tensor.
.. math::
out = sqrt(x)
Parameters:
x (Tensor): The input Sparse Tensor with data type float32, float64.
name (str, optional): Name for the operation (optional, default is None).
For more information, please refer to :ref:`api_guide_Name`.
Returns:
A Sparse Tensor with the same data type and shape as ``x`` .
Examples:
.. code-block:: python
import paddle
from paddle.fluid.framework import _test_eager_guard
with _test_eager_guard():
dense_x = paddle.to_tensor([4, 0, 1], dtype='float32')
sparse_x = dense_x.to_sparse_coo(1)
out = paddle.sparse.sqrt(sparse_x)
"""

assert in_dynamic_mode(), "Currently, Sparse API only support dynamic mode"

if x.is_sparse_coo():
return _C_ops.final_state_sparse_coo_sqrt(x)
elif x.is_sparse_csr():
return _C_ops.final_state_sparse_csr_sqrt(x)
else:
raise ValueError(
"Currently, sparse.sqrt only support the input of SparseCooTensor or SparseCsrTensor"
)


def sin(x, name=None):
"""
Calculate sin of x, requiring x to be a sparse coo or sparse csr tensor.
.. math::
out = sin(x)
Parameters:
x (Tensor): The input Sparse Tensor with data type float32, float64.
name (str, optional): Name for the operation (optional, default is None).
For more information, please refer to :ref:`api_guide_Name`.
Returns:
A Sparse Tensor with the same data type and shape as ``x`` .
Examples:
.. code-block:: python
import paddle
from paddle.fluid.framework import _test_eager_guard
with _test_eager_guard():
dense_x = paddle.to_tensor([-2, 0, 3], dtype='float32')
sparse_x = dense_x.to_sparse_coo(1)
out = paddle.sparse.sin(sparse_x)
"""

assert in_dynamic_mode(), "Currently, Sparse API only support dynamic mode"

if x.is_sparse_coo():
return _C_ops.final_state_sparse_coo_sin(x)
elif x.is_sparse_csr():
return _C_ops.final_state_sparse_csr_sin(x)
else:
raise ValueError(
"Currently, sparse.sin only support the input of SparseCooTensor or SparseCsrTensor"
)
2 changes: 1 addition & 1 deletion python/paddle/sparse/layer/__init__.py
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .activation import ReLU
from .unary import ReLU
from .norm import BatchNorm
from .conv import Conv3D
from .conv import SubmConv3D
Expand Down
File renamed without changes.

0 comments on commit 268ac34

Please sign in to comment.