Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed extra copy for transpose arrays in dot() #1477

Merged
merged 5 commits into from
Jul 17, 2023
Merged

Conversation

antonwolfy
Copy link
Contributor

@antonwolfy antonwolfy commented Jul 13, 2023

The PR removes unnecessary copying of input arrays into C-contagious format to call dpnp.dot() function.
The change is indented to speed up execution of code like below:

import dpnp

a = dpnp.ones((128, 4), dtype=dpnp.float32)[::2]
b = dpnp.ones((1048576, 128), dtype=dpnp.float32)
_ = dpnp.dot(a.T, b.T)

This is because gemm() function from MKL blas library supports arrays contiguous on inner dimension, i.e. where a stride for at least one dimension should be equal to 1.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • If this PR is a work in progress, are you filing the PR as a draft?

Copy link
Collaborator

@vlad-perevezentsev vlad-perevezentsev left a comment

Choose a reason for hiding this comment

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

LGTM!
thanks @antonwolfy

@antonwolfy antonwolfy merged commit 326c451 into master Jul 17, 2023
@antonwolfy antonwolfy deleted the strided_dot branch July 17, 2023 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants