Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Problem description

Agree to Privacy Statement

mindspore.ops.SparseTensorDenseMatmul

class mindspore.ops.SparseTensorDenseMatmul(adjoint_st=False, adjoint_dt=False)[source]

Multiplies sparse matrix A by dense matrix B. The rank of sparse matrix and dense matrix must be equal to 2.

Parameters
  • adjoint_st (bool) – If true, sparse tensor is transposed before multiplication. Default: False.

  • adjoint_dt (bool) – If true, dense tensor is transposed before multiplication. Default: False.

Inputs:
  • indices (Tensor) - A 2-D Tensor, represents the position of the element in the sparse tensor. Support int32, int64, each element value should be a non-negative int number. The shape is (n,2).

  • values (Tensor) - A 1-D Tensor, represents the value corresponding to the position in the indices. Support float16, float32, float64, int32, int64, complex64, complex128. The shape should be (n,).

  • sparse_shape (tuple(int) or (Tensor)) - A positive int tuple or tensor which specifies the shape of sparse tensor, and only constant value is allowed when sparse_shape is a tensor, should have 2 elements, represent sparse tensor shape is (N,C).

  • dense (Tensor) - A 2-D Tensor, the dtype is same as values. If adjoint_st is False and adjoint_dt is False, the shape must be (C,M). If adjoint_st is False and adjoint_dt is True, the shape must be (M,C). If adjoint_st is True and adjoint_dt is False, the shape must be (N,M). If adjoint_st is True and adjoint_dt is True, the shape must be (M,N).

Outputs:

Tensor, the dtype is the same as values. If adjoint_st is False, the shape is (N,M). If adjoint_st is True, the shape is (C,M).

Raises
  • TypeError – If the type of adjoint_st or adjoint_dt is not bool, or the dtype of indices, dtype of values and dtype of dense don’t meet the parameter description.

  • ValueError – If sparse_shape, shape of indices, shape of values, and shape of dense don’t meet the parameter description.

Supported Platforms:

GPU CPU

Examples

>>> import mindspore
>>> from mindspore import Tensor
>>> from mindspore.ops import operations as ops
>>> from mindspore.common import dtype as mstype
>>> indices = Tensor([[0, 1], [1, 2]], dtype=mindspore.int32)
>>> values = Tensor([1, 2], dtype=mindspore.float32)
>>> sparse_shape = (3, 4)
>>> dense = Tensor([[1, 1], [2, 2], [3, 3], [4, 4]], dtype=mindspore.float32)
>>> sparse_dense_matmul = ops.SparseTensorDenseMatmul()
>>> out = sparse_dense_matmul(indices, values, sparse_shape, dense)
>>> print(out)
[[2. 2.]
 [6. 6.]
 [0. 0.]]