Skip to content

Refactor the API of the matmul implementation#75194

Closed
lezcano wants to merge 9 commits intogh/Lezcano/56/basefrom
gh/Lezcano/56/head
Closed

Refactor the API of the matmul implementation#75194
lezcano wants to merge 9 commits intogh/Lezcano/56/basefrom
gh/Lezcano/56/head

Conversation

@lezcano
Copy link
Collaborator

@lezcano lezcano commented Apr 4, 2022

Stack from ghstack:

Previously we used an odd overload using c10::optional to implement
the matmul logic of matmul and matmul_out simultaneously. This made
some functions (those in linalg.matrix_exp) call into this native::matmul
implementation, rather than going through the dispatcher.

In this PR we remove the use of c10::optional and rename the
implementation of matmul, to make sure that no one mistakenly calls it.

Previously we used an odd overload using `c10::optional` to implement
the matmul logic of `matmul` and `matmul_out` simultaneously. This made
some functions (those in `linalg.matrix_exp`) call into this native::matmul
implementation, rather than going through the dispatcher.

In this PR we remove the use of `c10::optional` and rename the
implementation of matmul, to make sure that no one mistakenly calls it.

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Apr 4, 2022

🔗 Helpful links

💊 CI failures summary and remediations

As of commit fe001e2 (more details on the Dr. CI page):

Expand to see more

💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

Previously we used an odd overload using `c10::optional` to implement
the matmul logic of `matmul` and `matmul_out` simultaneously. This made
some functions (those in `linalg.matrix_exp`) call into this native::matmul
implementation, rather than going through the dispatcher.

In this PR we remove the use of `c10::optional` and rename the
implementation of matmul, to make sure that no one mistakenly calls it.

[ghstack-poisoned]
@lezcano lezcano mentioned this pull request Apr 4, 2022
Previously we used an odd overload using `c10::optional` to implement
the matmul logic of `matmul` and `matmul_out` simultaneously. This made
some functions (those in `linalg.matrix_exp`) call into this native::matmul
implementation, rather than going through the dispatcher.

In this PR we remove the use of `c10::optional` and rename the
implementation of matmul, to make sure that no one mistakenly calls it.

[ghstack-poisoned]
Previously we used an odd overload using `c10::optional` to implement
the matmul logic of `matmul` and `matmul_out` simultaneously. This made
some functions (those in `linalg.matrix_exp`) call into this native::matmul
implementation, rather than going through the dispatcher.

In this PR we remove the use of `c10::optional` and rename the
implementation of matmul, to make sure that no one mistakenly calls it.

[ghstack-poisoned]
Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

okey dokey

Previously we used an odd overload using `c10::optional` to implement
the matmul logic of `matmul` and `matmul_out` simultaneously. This made
some functions (those in `linalg.matrix_exp`) call into this native::matmul
implementation, rather than going through the dispatcher.

In this PR we remove the use of `c10::optional` and rename the
implementation of matmul, to make sure that no one mistakenly calls it.

[ghstack-poisoned]
lezcano added 3 commits April 6, 2022 14:22
Previously we used an odd overload using `c10::optional` to implement
the matmul logic of `matmul` and `matmul_out` simultaneously. This made
some functions (those in `linalg.matrix_exp`) call into this native::matmul
implementation, rather than going through the dispatcher.

In this PR we remove the use of `c10::optional` and rename the
implementation of matmul, to make sure that no one mistakenly calls it.

[ghstack-poisoned]
Previously we used an odd overload using `c10::optional` to implement
the matmul logic of `matmul` and `matmul_out` simultaneously. This made
some functions (those in `linalg.matrix_exp`) call into this native::matmul
implementation, rather than going through the dispatcher.

In this PR we remove the use of `c10::optional` and rename the
implementation of matmul, to make sure that no one mistakenly calls it.

[ghstack-poisoned]
Previously we used an odd overload using `c10::optional` to implement
the matmul logic of `matmul` and `matmul_out` simultaneously. This made
some functions (those in `linalg.matrix_exp`) call into this native::matmul
implementation, rather than going through the dispatcher.

In this PR we remove the use of `c10::optional` and rename the
implementation of matmul, to make sure that no one mistakenly calls it.

[ghstack-poisoned]
buffer.select(0, 2), // out for a^2
// out for a^2
auto view_out = buffer.select(0, 2);
at::matmul_out(
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need to go through the dispatcher here instead of calling _matmul_impl?

Copy link
Collaborator Author

@lezcano lezcano May 3, 2022

Choose a reason for hiding this comment

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

I thought that we should always go through the dispatcher for functorch and all the new addons we are getting? @albanD @zou3519

Copy link
Collaborator

Choose a reason for hiding this comment

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

The "real" calls like mm have to go through dispatcher, but calling from one composite implicit function to another composite implicit function can be whatever (for all you know, matmul can be a helper function that you are calling from another one).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

Previously we used an odd overload using `c10::optional` to implement
the matmul logic of `matmul` and `matmul_out` simultaneously. This made
some functions (those in `linalg.matrix_exp`) call into this native::matmul
implementation, rather than going through the dispatcher.

In this PR we remove the use of `c10::optional` and rename the
implementation of matmul, to make sure that no one mistakenly calls it.

[ghstack-poisoned]
@lezcano lezcano mentioned this pull request May 4, 2022
@ngimel
Copy link
Collaborator

ngimel commented May 4, 2022

@pytorchbot merge this

facebook-github-bot pushed a commit that referenced this pull request May 6, 2022
Summary:
Previously we used an odd overload using `c10::optional` to implement
the matmul logic of `matmul` and `matmul_out` simultaneously. This made
some functions (those in `linalg.matrix_exp`) call into this native::matmul
implementation, rather than going through the dispatcher.

In this PR we remove the use of `c10::optional` and rename the
implementation of matmul, to make sure that no one mistakenly calls it.

Pull Request resolved: #75194

Approved by: https://github.com/ezyang, https://github.com/ngimel

Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/35ae9f68c549005932b5e3d646d67bd3439622e8

Reviewed By: malfet

Differential Revision: D36171135

fbshipit-source-id: c8aaa9ce15d7cd15c76fd34459f9ee658fb791c5
@facebook-github-bot facebook-github-bot deleted the gh/Lezcano/56/head branch May 8, 2022 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed module: linear algebra Issues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmul open source topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants