• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <executorch/runtime/core/evalue.h>
10 
11 namespace executorch {
12 namespace runtime {
13 template <>
14 exec_aten::ArrayRef<exec_aten::optional<exec_aten::Tensor>>
get() const15 BoxedEvalueList<exec_aten::optional<exec_aten::Tensor>>::get() const {
16   for (typename exec_aten::ArrayRef<
17            exec_aten::optional<exec_aten::Tensor>>::size_type i = 0;
18        i < wrapped_vals_.size();
19        i++) {
20     if (wrapped_vals_[i] == nullptr) {
21       unwrapped_vals_[i] = exec_aten::nullopt;
22     } else {
23       unwrapped_vals_[i] =
24           wrapped_vals_[i]->to<exec_aten::optional<exec_aten::Tensor>>();
25     }
26   }
27   return exec_aten::ArrayRef<exec_aten::optional<exec_aten::Tensor>>{
28       unwrapped_vals_, wrapped_vals_.size()};
29 }
30 } // namespace runtime
31 } // namespace executorch
32