Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Abdurrahheem
Copy link
Contributor

This PR replaces iterative batch matrix multiplication which FastGemmBatch in Einsum layer.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake


std::vector<Mat> output;
Mat reshapedInput1 = input1;
Mat reshapedInput2 = input2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate why reshape is needed here? fastGemmBatch can already handle multiplification of n-dimensional matrices.

Copy link
Contributor Author

@Abdurrahheem Abdurrahheem Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required as some tensors might come in with dummy deletion BxNxMx1. Reshape just removes that dummy dimension.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you give a real Einsum example of dummy deletion BxNxMx1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dummy dimension on BxNxMx1 appears during pre-processing for some tensors. The reshape is not needed because we want to multiply 2 tenors with dummy dimension.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fengyuentau is there anything to change more? Could you please approve if not ?

Copy link
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@asmorkalov asmorkalov added this to the 4.10.0 milestone Jan 6, 2024
@asmorkalov asmorkalov marked this pull request as ready for review January 9, 2024 17:06
@Abdurrahheem
Copy link
Contributor Author

@dkurt any comments?

@asmorkalov asmorkalov merged commit c923c59 into opencv:4.x Jan 12, 2024
This was referenced Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants