|
14 | 14 | #include <unordered_map> |
15 | 15 | #include <vector> |
16 | 16 |
|
| 17 | +#include <executorch/runtime/core/exec_aten/util/scalar_type_util.h> |
17 | 18 | #include <executorch/runtime/core/span.h> |
18 | 19 | #include <executorch/runtime/executor/method.h> |
19 | 20 | #include <executorch/runtime/platform/log.h> |
@@ -53,8 +54,8 @@ class StaticKVCache { |
53 | 54 | style_(style), |
54 | 55 | input_ptrs_(n_caches_), |
55 | 56 | output_ptrs_(n_caches_) { |
56 | | - size_t total_cache_len = |
57 | | - std::accumulate(cache_lengths_.begin(), cache_lengths_.end(), 0); |
| 57 | + size_t total_cache_len = std::accumulate( |
| 58 | + cache_lengths_.begin(), cache_lengths_.end(), size_t(0)); |
58 | 59 | cache_data_size_ = total_cache_len * n_heads_per_cache_ * head_dim_; |
59 | 60 | update_data_size_ = |
60 | 61 | n_caches_ * n_heads_per_cache_ * max_input_len_ * head_dim_; |
@@ -867,6 +868,12 @@ class StaticAttentionIOManager { |
867 | 868 | void set_input(executorch::runtime::Method& method, size_t idx, T* data) { |
868 | 869 | auto methodMeta = method.method_meta(); |
869 | 870 | auto inputMeta = methodMeta.input_tensor_meta(idx); |
| 871 | + ET_CHECK_MSG( |
| 872 | + sizeof(T) == executorch::runtime::elementSize(inputMeta->scalar_type()), |
| 873 | + "set_input: sizeof(T)=%zu but model expects element size %zu for input %zu", |
| 874 | + sizeof(T), |
| 875 | + executorch::runtime::elementSize(inputMeta->scalar_type()), |
| 876 | + idx); |
870 | 877 | auto impl = ::executorch::runtime::etensor::TensorImpl( |
871 | 878 | inputMeta->scalar_type(), |
872 | 879 | inputMeta->sizes().size(), |
|
0 commit comments