Skip to content
Open
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
27 changes: 27 additions & 0 deletions src/common/transformations/tests/hash_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "openvino/op/add.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/parameter.hpp"
#include "openvino/util/common_util.hpp"
#include "transformations/hash.hpp"

namespace v0 = ov::op::v0;
Expand Down Expand Up @@ -69,4 +70,30 @@ TEST(HashTest, same_model_struct_different_weigth) {
EXPECT_NE(hash1, hash2);
}

TEST(HashTest, same_model_struct_different_weigth_by_offset) {
constexpr auto weights = ov::util::make_array<int>(11, 11, 12);

uint64_t hash1 = 0, hash2 = 0;
{
auto out = std::make_shared<Add>(std::make_shared<Parameter>(element::i32, Shape{1}),
std::make_shared<Constant>(element::i32, Shape{1}, weights.data()));
out = std::make_shared<Add>(out, std::make_shared<Constant>(element::i32, Shape{1}, weights.data() + 1));
auto model = std::make_shared<Model>(OutputVector{out}, "TestModel");

ov::pass::Hash hasher(hash1);
hasher.run_on_model(model);
}
{
auto out = std::make_shared<Add>(std::make_shared<Parameter>(element::i32, Shape{1}),
std::make_shared<Constant>(element::i32, Shape{1}, weights.data()));
out = std::make_shared<Add>(out, std::make_shared<Constant>(element::i32, Shape{1}, weights.data() + 2));
auto model = std::make_shared<Model>(OutputVector{out}, "TestModel");

ov::pass::Hash hasher(hash2);
hasher.run_on_model(model);
}

EXPECT_NE(hash1, hash2);
}

} // namespace ov::test
2 changes: 1 addition & 1 deletion src/core/src/xml_util/constant_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ ConstantWriter::FilePosition ConstantWriter::write(const char* ptr,
}
if (m_write_hash_value) {
// hash stored with special ostream only
m_binary_output.get().write(reinterpret_cast<const char*>(&hash), hash);
m_binary_output.get().rdbuf()->sputn(reinterpret_cast<const char*>(&hash), hash);
} else {
m_binary_output.get().write(ptr_to_write, new_size);
}
Expand Down
Loading