1 #define TORCH_ASSERT_ONLY_METHOD_OPERATORS 2 #include <ATen/core/Tensor.h> 3 #include <ATen/native/quantized/cpu/QuantizedOps.h> 4 5 #ifndef AT_PER_OPERATOR_HEADERS 6 #include <ATen/NativeFunctions.h> 7 #else 8 #include <ATen/ops/gelu_native.h> 9 #endif 10 11 namespace at { 12 namespace native { 13 14 DEFINE_DISPATCH(qgelu_stub); 15 gelu_quantized_cpu(const Tensor & qx,c10::string_view approximate)16Tensor gelu_quantized_cpu(const Tensor& qx, c10::string_view approximate) { 17 Tensor qy; 18 qgelu_stub(qx.device().type(), qx, qy, get_gelutype_enum(approximate)); 19 return qy; 20 } 21 gelu_quantized_cpu_(Tensor & self,c10::string_view approximate)22Tensor& gelu_quantized_cpu_(Tensor& self, c10::string_view approximate) { 23 Tensor qy = gelu_quantized_cpu(self, approximate); 24 // This can be optimized in a future PR if it becomes a bottleneck. 25 self.copy_(qy); 26 return self; 27 } 28 29 }} // namespace at::native 30