1 #pragma once 2 #include <c10/util/intrusive_ptr.h> 3 4 namespace c10 { 5 6 /** 7 * Inherit from OperatorKernel to implement a c10 kernel. 8 * 9 * Example: 10 * > namespace { 11 * > class my_kernel_cpu final : public c10::OperatorKernel { 12 * > public: 13 * > Tensor operator()(Tensor a, Tensor b) {...} 14 * > }; 15 * > } 16 * 17 * The kernel class is allowed to have members but these are equivalent 18 * to global variables. The kernel implementation is responsible for 19 * preventing race conditions on them. 20 * 21 * See below for how to register this kernel with PyTorch. 22 */ 23 struct TORCH_API OperatorKernel : public c10::intrusive_ptr_target { 24 ~OperatorKernel() override = default; 25 }; 26 27 } // namespace c10 28