xref: /aosp_15_r20/external/executorch/extension/llm/custom_ops/op_fast_hadamard_transform.h (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 #pragma once
10 
11 #include <executorch/runtime/kernel/kernel_includes.h>
12 
13 namespace torch::executor::native {
14 
15 // Compute the fast Walsh-Hadamard transform
16 // (https://en.wikipedia.org/wiki/Fast_Walsh%E2%80%93Hadamard_transform)
17 // of mat along the last dimension (which must be contiguous).
18 //
19 // mat.sizes().back() is currently required to be either a power of
20 // two, or 28 * a power of two.
21 Tensor& fast_hadamard_transform_out(
22     RuntimeContext& ctx,
23     const Tensor& mat,
24     Tensor& out);
25 } // namespace torch::executor::native
26