Skip to content

Commit fbf38a1

Browse files
committed
Update on "[kernel] Add template based unboxing"
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]
1 parent 6ba7cbe commit fbf38a1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

runtime/kernel/targets.bzl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ def define_common_targets():
3030
runtime.cxx_library(
3131
name = "operator_registry_TWO_KERNELS_TEST_ONLY",
3232
srcs = ["operator_registry.cpp"],
33-
exported_headers = ["operator_registry.h"],
33+
exported_headers = [
34+
"operator_registry.h",
35+
"make_boxed_from_unboxed_functor.h",
36+
"type_list.h",
37+
],
3438
visibility = [
3539
"//executorch/...",
3640
"@EXECUTORCH_CLIENTS",

runtime/kernel/test/make_boxed_from_unboxed_functor_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ using RuntimeContext = torch::executor::KernelRuntimeContext;
1818
using namespace torch::executor;
1919

2020
Tensor& my_op_out(RuntimeContext& ctx, const Tensor& a, Tensor& out) {
21-
(void) ctx;
22-
(void) a;
21+
(void)ctx;
22+
(void)a;
2323
return out;
2424
}
2525

2626
Tensor& set_1_out(RuntimeContext& ctx, Tensor& out) {
27-
(void) ctx;
27+
(void)ctx;
2828
out.mutable_data_ptr<int32_t>()[0] = 1;
2929
return out;
3030
}

0 commit comments

Comments
 (0)