Skip to content

[kernel] Add template based unboxing #1284

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

Closed
wants to merge 11 commits into from

Conversation

larryliu0820
Copy link
Contributor

@larryliu0820 larryliu0820 commented Nov 23, 2023

Stack from ghstack (oldest at bottom):

Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:

Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});

Differential Revision: D51553099

Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Nov 23, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/1284

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure

As of commit 84e9d77 with merge base 02edc9e (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

larryliu0820 added a commit that referenced this pull request Nov 23, 2023
Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

ghstack-source-id: 5163fd1
Pull Request resolved: #1284
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 23, 2023
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

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

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Nov 23, 2023
Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

ghstack-source-id: c82dc20
Pull Request resolved: #1284
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

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

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Nov 23, 2023
Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

ghstack-source-id: c430da1
Pull Request resolved: #1284
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

larryliu0820 added a commit that referenced this pull request Feb 19, 2024
Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

ghstack-source-id: c430da1
Pull Request resolved: #1284
Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

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

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Feb 29, 2024
Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

ghstack-source-id: f3f3dc2
Pull Request resolved: #1284
Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

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

[ghstack-poisoned]
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@iseeyuan iseeyuan left a comment

Choose a reason for hiding this comment

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

LGTM.
Is there any plan to add template selective registration in future?

larryliu0820 added a commit that referenced this pull request Mar 7, 2024
Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

ghstack-source-id: 119e9ae
Pull Request resolved: #1284
@larryliu0820
Copy link
Contributor Author

LGTM. Is there any plan to add template selective registration in future?

My intention was not to add it in the first version for simplicity. We can add it later

Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

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

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Mar 12, 2024
Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

ghstack-source-id: a5437bb
Pull Request resolved: #1284
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

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

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Mar 12, 2024
Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

ghstack-source-id: ffda42c
Pull Request resolved: #1284
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

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

[ghstack-poisoned]
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

1 similar comment
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

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

[ghstack-poisoned]
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

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

[ghstack-poisoned]
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

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

[ghstack-poisoned]
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@larryliu0820 merged this pull request in 75284d2.

kedarnath03 pushed a commit to kedarnath03/executorch that referenced this pull request Jun 25, 2025
Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

ghstack-source-id: e9c36de
Pull Request resolved: pytorch/executorch#1284
kedarnath03 pushed a commit to kedarnath03/executorch that referenced this pull request Jun 25, 2025
Adding a new feature to allow users to bypass codegen and register their
kernels directly. This is very useful for custom kernels for custom ops.

Example usage:
```
Tensor& my_op(RuntimeContext& ctx, const Tensor& self, const Tensor& other, Tensor& out) {
    // ...
    return out;
}

Kernel my_kernel = Kernel.make_boxed_kernel("my_ns::my_op",EXECUTORCH_FN(my_op));

register_kernels({my_kernel});
```

ghstack-source-id: 119e9ae
Pull Request resolved: pytorch/executorch#1284
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants