MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / abs

Function abs

python/paddle/sparse/unary.py:708–740  ·  view source on GitHub ↗

Calculate elementwise absolute value of x, requiring x to be a SparseCooTensor or SparseCsrTensor. .. math:: out = |x| Parameters: x (Tensor): The input Sparse Tensor with data type float32, float64, complex64, complex128. name (str|None, optional): Name for t

(x: Tensor, name: str | None = None)

Source from the content-addressed store, hash-verified

706
707
708def abs(x: Tensor, name: str | None = None) -> Tensor:
709 """
710 Calculate elementwise absolute value of x, requiring x to be a SparseCooTensor or SparseCsrTensor.
711
712 .. math::
713
714 out = |x|
715
716 Parameters:
717 x (Tensor): The input Sparse Tensor with data type float32, float64, complex64, complex128.
718 name (str|None, optional): Name for the operation (optional, default is None).
719 For more information, please refer to :ref:`api_guide_Name`.
720
721 Returns:
722 A Sparse Tensor with the same data type and shape as ``x`` .
723
724 Examples:
725 .. code-block:: pycon
726
727 >>> import paddle
728
729 >>> dense_x = paddle.to_tensor([-2, 0, 3], dtype='float32')
730 >>> sparse_x = dense_x.to_sparse_coo(1)
731 >>> out = paddle.sparse.abs(sparse_x)
732 >>> out
733 Tensor(shape=[3], dtype=paddle.float32, place=Place(cpu), stop_gradient=True,
734 indices=[[0, 2]],
735 values=[2., 3.])
736 """
737 assert in_dynamic_or_pir_mode(), (
738 "Currently, Sparse API only support dynamic mode or pir mode."
739 )
740 return _C_ops.sparse_abs(x)
741
742
743def coalesce(x: Tensor, name: str | None = None) -> Tensor:

Callers 15

p_matrix_normFunction · 0.50
rot90Function · 0.50
count_convNdFunction · 0.50
count_bnFunction · 0.50
count_linearFunction · 0.50
count_pool2dFunction · 0.50
count_element_opFunction · 0.50
count_convNdFunction · 0.50
count_bnFunction · 0.50
count_linearFunction · 0.50
count_adap_avgpoolFunction · 0.50

Calls 1

in_dynamic_or_pir_modeFunction · 0.90

Tested by

no test coverage detected