2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
4
#include " utils.hpp"
5
+
5
6
#include < fstream>
6
7
7
8
namespace ov {
@@ -42,7 +43,7 @@ int64_t argmax(const ov::Tensor& logits, const size_t batch_idx) {
42
43
size_t batch_offset = batch_idx * logits.get_shape ()[1 ] * vocab_size;
43
44
size_t sequence_offset = (logits.get_shape ()[1 ] - 1 ) * vocab_size;
44
45
const float * logits_data = logits.data <const float >() + batch_offset + sequence_offset;
45
-
46
+
46
47
int64_t out_token = std::max_element (logits_data, logits_data + vocab_size) - logits_data;
47
48
float max_logit = logits_data[out_token];
48
49
@@ -52,16 +53,14 @@ int64_t argmax(const ov::Tensor& logits, const size_t batch_idx) {
52
53
/* *
53
54
* Initializes position ids based on attention mask and starting position
54
55
*/
55
- void initialize_position_ids (ov::Tensor& position_ids,
56
- const ov::Tensor& attention_mask,
57
- int64_t start_pos) {
58
- OPENVINO_ASSERT (position_ids.get_element_type () == ov::element::i64,
56
+ void initialize_position_ids (ov::Tensor& position_ids, const ov::Tensor& attention_mask, int64_t start_pos) {
57
+ OPENVINO_ASSERT (position_ids.get_element_type () == ov::element::i64,
59
58
" position_ids tensor element type should be an i64" );
60
- OPENVINO_ASSERT (position_ids.get_shape ().size () == 2 ,
59
+ OPENVINO_ASSERT (position_ids.get_shape ().size () == 2 ,
61
60
" position_ids tensor should of rank 2 with shape [batch_size, seq_len]" );
62
- OPENVINO_ASSERT (attention_mask.get_element_type () == ov::element::i64,
61
+ OPENVINO_ASSERT (attention_mask.get_element_type () == ov::element::i64,
63
62
" attention_mask tensor element type should be an i64" );
64
- OPENVINO_ASSERT (attention_mask.get_shape ().size () == 2 ,
63
+ OPENVINO_ASSERT (attention_mask.get_shape ().size () == 2 ,
65
64
" attention_mask tensor should of rank 2 with shape [batch_size, seq_len]" );
66
65
67
66
const size_t batch_size = attention_mask.get_shape ()[0 ];
@@ -97,7 +96,6 @@ void initialize_beam_inputs(const ov::Tensor& input_ids, const ov::Tensor& atten
97
96
std::fill_n (beam_idx.data <int32_t >(), input_shape.at (0 ), 0 );
98
97
}
99
98
100
-
101
99
void set_attention_mask (ov::Tensor&& attention_mask, std::vector<int32_t > next_beams) {
102
100
ov::Tensor original_mask{ov::element::i64, attention_mask.get_shape ()};
103
101
ov::Shape original_shape = original_mask.get_shape ();
@@ -185,6 +183,27 @@ ov::genai::OptionalGenerationConfig get_config_from_map(const ov::AnyMap& config
185
183
return std::nullopt;
186
184
}
187
185
186
+ /* *
187
+ * Split config by core and compile configs
188
+ * There are not supported by `core.compile` function plugin options like `ENABLE_MMAP`
189
+ * Move this options to `core.set_property` config
190
+ */
191
+ std::pair<ov::AnyMap, ov::AnyMap> split_core_complile_config (const ov::AnyMap& plugin_config) {
192
+ const std::vector<std::string> unsupported_by_compile_options{" ENABLE_MMAP" };
193
+ ov::AnyMap core_config;
194
+ ov::AnyMap compile_config{plugin_config};
195
+
196
+ for (const auto option : unsupported_by_compile_options) {
197
+ auto iter = plugin_config.find (option);
198
+ if (iter != plugin_config.end ()) {
199
+ core_config[option] = iter->second ;
200
+ compile_config.erase (option);
201
+ }
202
+ }
203
+
204
+ return {core_config, compile_config};
205
+ };
206
+
188
207
} // namespace utils
189
208
} // namespace genai
190
209
} // namespace ov
0 commit comments