is_same_shape

paddle.sparse. is_same_shape ( x, y ) [source]

Return the results of shape comparison between two Tensors, check whether x.shape equal to y.shape. Any two type Tensor among DenseTensor/SparseCooTensor/SparseCsrTensor are supported.

Parameters
  • x (Tensor) – The input tensor. It can be DenseTensor/SparseCooTensor/SparseCsrTensor.

  • y (Tensor) – The input tensor. It can be DenseTensor/SparseCooTensor/SparseCsrTensor.

Returns

True for same shape and False for different shape.

Return type

bool

Examples

>>> import paddle

>>> x = paddle.rand([2, 3, 8])
>>> y = paddle.rand([2, 3, 8])
>>> y = y.to_sparse_csr()
>>> z = paddle.rand([2, 5])

>>> paddle.sparse.is_same_shape(x, y)
True
>>> paddle.sparse.is_same_shape(x, z)
False