Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void scaled_dot_product_attention(const T* query,
gk_softmax_shape,
qk_shape.size() - 1,
sizeof(T));
qk_data = qk_data_with_sink;
qk_data = std::move(qk_data_with_sink);
}
std::vector<T> qk_data_softmax(qk_data.size(), 0);
ov::reference::softmax<T>(qk_data.data(),
Expand All @@ -167,7 +167,7 @@ void scaled_dot_product_attention(const T* query,
reinterpret_cast<char*>(qk_data_sliced.data()),
gk_softmax_shape,
sizeof(T));
qk_data_softmax = qk_data_sliced;
qk_data_softmax = std::move(qk_data_sliced);
}
ov::reference::matmul<T>(qk_data_softmax.data(), value, output, qk_shape, value_shape, output_shape, false, false);
}
Expand Down
16 changes: 7 additions & 9 deletions src/core/src/op/fake_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,15 @@ bool FakeConvert::evaluate(ov::TensorVector& outputs, const ov::TensorVector& in
OPENVINO_ASSERT(outputs.size() == 1);
OPENVINO_ASSERT(inputs.size() == 2 || inputs.size() == 3);

const auto make_zero_shift_tensor = [](auto&& scale_tensor) {
auto shift_tensor = Tensor(scale_tensor.get_element_type(), scale_tensor.get_shape());
std::memset(shift_tensor.data(), 0, shift_tensor.get_byte_size());
return shift_tensor;
};

const auto& data = inputs[0];
const auto& scale = inputs[1];
const auto& shift = [&] {
if (inputs.size() == 3) {
return inputs[2];
} else {
auto shift_tensor = Tensor(scale.get_element_type(), scale.get_shape());
std::memset(shift_tensor.data(), 0, shift_tensor.get_byte_size());
return shift_tensor;
}
}();
const auto& shift = inputs.size() == 3 ? inputs[2] : make_zero_shift_tensor(scale);
outputs[0].set_shape(data.get_shape());

using namespace ov::element;
Expand Down
30 changes: 12 additions & 18 deletions src/core/src/op/read_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,25 +149,19 @@ bool ReadValue::evaluate(TensorVector& outputs,
const auto& var_value = variable_values.find(m_variable);

const auto use_context = var_value != variable_values.end() && !var_value->second->get_reset();
auto& output = outputs[0];
const auto& input = [&] {
if (use_context) {
return var_value->second->get_state();
} else if (!inputs.empty()) {
return inputs[0];
} else {
const auto var_info = m_variable->get_info();
OPENVINO_ASSERT(var_info.data_shape.is_static() && var_info.data_type.is_static());
const auto& shape = var_info.data_shape.get_shape();
const auto& type = var_info.data_type;
auto input = ov::Tensor(type, shape);
memset(input.data(), 0, input.get_byte_size());
return input;
}
}();

output.set_shape(input.get_shape());
std::memcpy(output.data(), input.data(), output.get_byte_size());
if (auto& output = outputs[0]; use_context) {
output.set_shape(var_value->second->get_state().get_shape());
memcpy(output.data(), var_value->second->get_state().data(), output.get_byte_size());
} else if (!inputs.empty()) {
output.set_shape(inputs[0].get_shape());
memcpy(output.data(), inputs[0].data(), output.get_byte_size());
} else {
const auto var_info = m_variable->get_info();
OPENVINO_ASSERT(var_info.data_shape.is_static() && var_info.data_type.is_static());
output.set_shape(var_info.data_shape.get_shape());
memset(output.data(), 0, output.get_byte_size());
}
return true;
}

Expand Down
15 changes: 7 additions & 8 deletions src/core/src/op/shape_of.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,17 @@ bool evaluate_bound(const Node* const node, ov::TensorVector& outputs, const boo
constexpr auto max_et_val = static_cast<int64_t>(std::numeric_limits<int32_t>::max());

const auto get_val = is_upper ? &Interval::get_max_val : &Interval::get_min_val;
auto limit_val = is_upper ? max_et_val : static_cast<decltype(max_et_val)>(0);
const auto limit_val = is_upper ? max_et_val : static_cast<decltype(max_et_val)>(0);

auto dynamic_mask = Tensor{element::boolean, Shape{in_shape_rank}};
TensorVector inputs{
{element::boolean, Shape{in_shape_rank}}, // mask
{out_et, Shape{}, &limit_val}, // limit
outputs[0] // output
};
auto& dynamic_mask = inputs[0];
std::transform(in_shape.begin(), in_shape.end(), dynamic_mask.data<char>(), [&](const Dimension& d) {
return static_cast<char>((d.get_interval().*get_val)() >= max_et_val);
});

const TensorVector inputs{
dynamic_mask, // mask
{out_et, Shape{}, &limit_val}, // limit
outputs[0] // output
};
eval_status = v1::Select().evaluate(outputs, inputs);
}
return eval_status;
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/pass/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void serialize_func(std::ostream& xml_file,
ov::pass::Serialize::Version ver,
bool deterministic = false) {
ov::util::ConstantWriter constant_write_handler(bin_file);
serialize_func(xml_file, bin_file, model, ver, deterministic, constant_write_handler);
serialize_func(xml_file, bin_file, std::move(model), ver, deterministic, constant_write_handler);
}
} // namespace

Expand Down
4 changes: 2 additions & 2 deletions src/core/src/pattern/op/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Block::Block(const OutputVector& inputs, const OutputVector& outputs, const std:
}

bool Block::match_value(Matcher* matcher, const Output<Node>& pattern_value, const Output<Node>& graph_value) {
auto block_pattern_root = m_outputs.front();
const auto& block_pattern_root = m_outputs.front();

// Using a local matcher to match only those patterns that are encapsulated into the current Block.
auto local_matcher = std::make_shared<Matcher>(block_pattern_root.get_node_shared_ptr(), "BlockMatcher");
Expand Down Expand Up @@ -55,4 +55,4 @@ bool Block::match_value(Matcher* matcher, const Output<Node>& pattern_value, con
}
}
return true;
}
}
9 changes: 5 additions & 4 deletions src/core/src/xml_util/xml_serialize_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ class PostponedConstantReplacer {
if (node->get_rt_info().count("postponed_constant")) {
OPENVINO_ASSERT(node->get_output_size() == 1);
ov::OutputVector outputs(1);
std::shared_ptr<ov::Node> node_clone;
std::shared_ptr<ov::Node> node_to_fold;
if (ov::pass::constant_folding_is_disabled(node)) {
// clone to keep original node unchanged
node_clone = node->clone_with_new_inputs(node->input_values());
node_clone->get_rt_info().erase(ov::pass::DisableConstantFolding::get_type_info_static());
node_to_fold = node->clone_with_new_inputs(node->input_values());
node_to_fold->get_rt_info().erase(ov::pass::DisableConstantFolding::get_type_info_static());
} else {
node_to_fold = node->shared_from_this();
}
auto node_to_fold = node_clone ? node_clone : node->shared_from_this();
OPENVINO_ASSERT(
node_to_fold->constant_fold(outputs, node_to_fold->input_values()),
"Node with set `postponed_constant` attribute cannot be fold to constant when saving model to IR file");
Expand Down
2 changes: 1 addition & 1 deletion src/core/xml_util/src/xml_deserialize_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ std::shared_ptr<ov::Model> XmlDeserializer::parse_function(const pugi::xml_node&
}

// Run DFS starting from outputs to get nodes topological order
std::function<void(size_t)> dfs = [&edges, &order, &dfs_used_nodes](const size_t start_id) {
const std::function<void(size_t)> dfs = [&edges, &order, &dfs_used_nodes](const size_t start_id) {
std::stack<size_t> stack;
std::unordered_set<size_t> visited;
stack.push(start_id);
Expand Down
Loading