Skip to content

Add unboxedCallRedispatch#35476

Closed
ezyang wants to merge 9 commits intogh/ezyang/694/basefrom
gh/ezyang/694/head
Closed

Add unboxedCallRedispatch#35476
ezyang wants to merge 9 commits intogh/ezyang/694/basefrom
gh/ezyang/694/head

Conversation

@ezyang
Copy link
Copy Markdown
Contributor

@ezyang ezyang commented Mar 26, 2020

Stack from ghstack:

A few things:

  • Add new callUnboxedRedispatch function which can be used to do a
    redispatch when you don't want to add a type id to the excluded
    set. This will recompute the dispatch key but ignore everything
    including and before the currentDispatchKey
  • Add FULL_AFTER constructor to DispatchKeySet; used to implement
    redispatch.

Signed-off-by: Edward Z. Yang ezyang@fb.com

Differential Revision: D20680518

A few things:
- Add a new BackendGeneric dispatch key, intended to be a place where
  we can put code which is generic across backends.  No operators
  are modified to use it but there is a simple use case test
  in op_registration_test.cpp.  It's enabled by default (like
  Variable) but fallthrough by default (like BackendSelect)
- Add new callUnboxedRedispatch function which can be used to do a
  redispatch when you don't want to add a type id to the excluded
  set.  This will recompute the dispatch key but ignore everything
  including and before the currentDispatchKey
- Add FULL_AFTER constructor to DispatchKeySet; used to implement
  redispatch.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Mar 26, 2020
A few things:
- Add a new BackendGeneric dispatch key, intended to be a place where
  we can put code which is generic across backends.  No operators
  are modified to use it but there is a simple use case test
  in op_registration_test.cpp.  It's enabled by default (like
  Variable) but fallthrough by default (like BackendSelect)
- Add new callUnboxedRedispatch function which can be used to do a
  redispatch when you don't want to add a type id to the excluded
  set.  This will recompute the dispatch key but ignore everything
  including and before the currentDispatchKey
- Add FULL_AFTER constructor to DispatchKeySet; used to implement
  redispatch.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

ghstack-source-id: 250a4ed
Pull Request resolved: #35476
@dr-ci
Copy link
Copy Markdown

dr-ci Bot commented Mar 26, 2020

💊 CircleCI build failures summary and remediations

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


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


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker.

See how this bot performed.

This comment has been revised 62 times.

Copy link
Copy Markdown
Contributor

@smessmer smessmer left a comment

Choose a reason for hiding this comment

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

Why do we introduce a new BackendGeneric instead of just reusing BackendSelect and potentially renaming it?

A few things:
- Add a new BackendGeneric dispatch key, intended to be a place where
  we can put code which is generic across backends.  No operators
  are modified to use it but there is a simple use case test
  in op_registration_test.cpp.  It's enabled by default (like
  Variable) but fallthrough by default (like BackendSelect)
- Add new callUnboxedRedispatch function which can be used to do a
  redispatch when you don't want to add a type id to the excluded
  set.  This will recompute the dispatch key but ignore everything
  including and before the currentDispatchKey
- Add FULL_AFTER constructor to DispatchKeySet; used to implement
  redispatch.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: [D20680518](https://our.internmc.facebook.com/intern/diff/D20680518)

[ghstack-poisoned]
@ezyang
Copy link
Copy Markdown
Contributor Author

ezyang commented Mar 27, 2020

Why do we introduce a new BackendGeneric instead of just reusing BackendSelect and potentially renaming it?

Because... they have different semantic meanings?

A few things:
- Add a new BackendGeneric dispatch key, intended to be a place where
  we can put code which is generic across backends.  No operators
  are modified to use it but there is a simple use case test
  in op_registration_test.cpp.  It's enabled by default (like
  Variable) but fallthrough by default (like BackendSelect)
- Add new callUnboxedRedispatch function which can be used to do a
  redispatch when you don't want to add a type id to the excluded
  set.  This will recompute the dispatch key but ignore everything
  including and before the currentDispatchKey
- Add FULL_AFTER constructor to DispatchKeySet; used to implement
  redispatch.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: [D20680518](https://our.internmc.facebook.com/intern/diff/D20680518)

[ghstack-poisoned]
@ezyang ezyang requested review from albanD and apaszke as code owners March 27, 2020 13:59
A few things:
- Add a new BackendGeneric dispatch key, intended to be a place where
  we can put code which is generic across backends.  No operators
  are modified to use it but there is a simple use case test
  in op_registration_test.cpp.  It's enabled by default (like
  Variable) but fallthrough by default (like BackendSelect)
- Add new callUnboxedRedispatch function which can be used to do a
  redispatch when you don't want to add a type id to the excluded
  set.  This will recompute the dispatch key but ignore everything
  including and before the currentDispatchKey
- Add FULL_AFTER constructor to DispatchKeySet; used to implement
  redispatch.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: [D20680518](https://our.internmc.facebook.com/intern/diff/D20680518)

[ghstack-poisoned]
@smessmer
Copy link
Copy Markdown
Contributor

Why do we introduce a new BackendGeneric instead of just reusing BackendSelect and potentially renaming it?

Because... they have different semantic meanings?

They're different use cases but they're the same mechanism of "do some work before calling into the actual kernel". I was thinking that maybe we can unify them.

ezyang added 3 commits March 27, 2020 13:44
A few things:
- Add a new BackendGeneric dispatch key, intended to be a place where
  we can put code which is generic across backends.  No operators
  are modified to use it but there is a simple use case test
  in op_registration_test.cpp.  It's enabled by default (like
  Variable) but fallthrough by default (like BackendSelect)
- Add new callUnboxedRedispatch function which can be used to do a
  redispatch when you don't want to add a type id to the excluded
  set.  This will recompute the dispatch key but ignore everything
  including and before the currentDispatchKey
- Add FULL_AFTER constructor to DispatchKeySet; used to implement
  redispatch.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: [D20680518](https://our.internmc.facebook.com/intern/diff/D20680518)

[ghstack-poisoned]
A few things:
- Add a new BackendGeneric dispatch key, intended to be a place where
  we can put code which is generic across backends.  No operators
  are modified to use it but there is a simple use case test
  in op_registration_test.cpp.  It's enabled by default (like
  Variable) but fallthrough by default (like BackendSelect)
- Add new callUnboxedRedispatch function which can be used to do a
  redispatch when you don't want to add a type id to the excluded
  set.  This will recompute the dispatch key but ignore everything
  including and before the currentDispatchKey
- Add FULL_AFTER constructor to DispatchKeySet; used to implement
  redispatch.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: [D20680518](https://our.internmc.facebook.com/intern/diff/D20680518)

[ghstack-poisoned]
A few things:
- Add new callUnboxedRedispatch function which can be used to do a
  redispatch when you don't want to add a type id to the excluded
  set.  This will recompute the dispatch key but ignore everything
  including and before the currentDispatchKey
- Add FULL_AFTER constructor to DispatchKeySet; used to implement
  redispatch.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: [D20680518](https://our.internmc.facebook.com/intern/diff/D20680518)

[ghstack-poisoned]
@ezyang ezyang changed the title Add BackendGeneric dispatch key and unboxedCallRedispatch Add unboxedCallRedispatch Mar 30, 2020
@ezyang
Copy link
Copy Markdown
Contributor Author

ezyang commented Mar 30, 2020

@smessmer I updated this diff to not include BackendGeneric anymore.

A few things:
- Add new callUnboxedRedispatch function which can be used to do a
  redispatch when you don't want to add a type id to the excluded
  set.  This will recompute the dispatch key but ignore everything
  including and before the currentDispatchKey
- Add FULL_AFTER constructor to DispatchKeySet; used to implement
  redispatch.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: [D20680518](https://our.internmc.facebook.com/intern/diff/D20680518)

[ghstack-poisoned]
template<class Return, class... Args>
Return callUnboxedWithDispatchKey(const OperatorHandle& op, DispatchKey dispatchKey, Args... args) const;

// Like callUnboxed, but intended for use in a redispatch: you currently
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: "you are"

Comment thread c10/core/DispatchKeySet.h
@@ -34,6 +34,7 @@ namespace c10 {
class DispatchKeySet final {
public:
enum Full { FULL };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thinking about it, I probably would have put those into static factory functions instead of constructors with an enum argument, i.e.

static DispatchKeySet DispatchKeySet::full();
static DispatchKeySet DispatchKeySet::raw();
static DispatchKeySet DispatchKeySet::full_after(...);

Seems more standard. But not a strong opinion if you wanna keep it as is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm in the habit of doing constructors because it makes field initialization syntax better (doesn't matter here as we have copy/move constructors but when you don't have those it makes a ton of difference.)

A few things:
- Add new callUnboxedRedispatch function which can be used to do a
  redispatch when you don't want to add a type id to the excluded
  set.  This will recompute the dispatch key but ignore everything
  including and before the currentDispatchKey
- Add FULL_AFTER constructor to DispatchKeySet; used to implement
  redispatch.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: [D20680518](https://our.internmc.facebook.com/intern/diff/D20680518)

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

@ezyang merged this pull request in 16a88e4.

@facebook-github-bot facebook-github-bot deleted the gh/ezyang/694/head branch April 5, 2020 14:18
karansachdev-1012 pushed a commit to karansachdev-1012/pytorch that referenced this pull request Feb 17, 2026
A few things:
- Add a new BackendGeneric dispatch key, intended to be a place where
  we can put code which is generic across backends.  No operators
  are modified to use it but there is a simple use case test
  in op_registration_test.cpp.  It's enabled by default (like
  Variable) but fallthrough by default (like BackendSelect)
- Add new callUnboxedRedispatch function which can be used to do a
  redispatch when you don't want to add a type id to the excluded
  set.  This will recompute the dispatch key but ignore everything
  including and before the currentDispatchKey
- Add FULL_AFTER constructor to DispatchKeySet; used to implement
  redispatch.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

ghstack-source-id: 53143d0
Pull Request resolved: pytorch/pytorch#35476
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Pull Request resolved: pytorch#35476

A few things:
- Add new callUnboxedRedispatch function which can be used to do a
  redispatch when you don't want to add a type id to the excluded
  set.  This will recompute the dispatch key but ignore everything
  including and before the currentDispatchKey
- Add FULL_AFTER constructor to DispatchKeySet; used to implement
  redispatch.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: D20680518

Test Plan: Imported from OSS

Pulled By: ezyang

fbshipit-source-id: ecd7fbdfa916d0d2550a5b19dd3ee4a9f2272457
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants