xref: /aosp_15_r20/external/executorch/runtime/kernel/test/test_util.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 <vector>
12 
13 #include <executorch/runtime/core/exec_aten/exec_aten.h>
14 #include <executorch/runtime/kernel/operator_registry.h>
15 
16 namespace executorch {
17 namespace runtime {
18 
19 namespace testing {
20 
make_kernel_key(std::vector<std::pair<executorch::aten::ScalarType,std::vector<executorch::aten::DimOrderType>>> tensors,char * buf)21 inline void make_kernel_key(
22     std::vector<std::pair<
23         executorch::aten::ScalarType,
24         std::vector<executorch::aten::DimOrderType>>> tensors,
25     char* buf) {
26   std::vector<TensorMeta> meta;
27   for (auto& t : tensors) {
28     Span<executorch::aten::DimOrderType> dim_order(
29         t.second.data(), t.second.size());
30     meta.emplace_back(t.first, dim_order);
31   }
32   Span<const TensorMeta> metadata(meta.data(), meta.size());
33   internal::make_kernel_key_string(metadata, buf);
34 }
35 
36 } // namespace testing
37 
38 } // namespace runtime
39 } // namespace executorch
40