diff --git a/src/core/include/openvino/op/identity.hpp b/src/core/include/openvino/op/identity.hpp index 6fc625340f46aa..0f63631b6bcdea 100644 --- a/src/core/include/openvino/op/identity.hpp +++ b/src/core/include/openvino/op/identity.hpp @@ -17,22 +17,13 @@ class OPENVINO_API Identity : public Op { OPENVINO_OP("Identity", "opset15"); Identity() = default; /** - * @brief Identity operation is used as a placeholder. It either passes the tensor down to the next layer, - * or copies the tensor to the output. - * - * @param copy Boolean that determines whether to copy the input to the output, or just return the output. + * @brief Identity operation is used as a placeholder. It copies the tensor data to the output. */ - Identity(const Output& data, const bool copy = false); + Identity(const Output& data); bool visit_attributes(AttributeVisitor& visitor) override; void validate_and_infer_types() override; std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; - - bool get_copy() const; - void set_copy(const bool copy); - -private: - bool m_copy; }; } // namespace v15 } // namespace op diff --git a/src/core/reference/include/openvino/reference/identity.hpp b/src/core/reference/include/openvino/reference/identity.hpp index d33c5249a80e8b..319cf2bb3eb1a7 100644 --- a/src/core/reference/include/openvino/reference/identity.hpp +++ b/src/core/reference/include/openvino/reference/identity.hpp @@ -17,18 +17,9 @@ namespace identity { * * @param input Input matrix (matrices) pointer. * @param output Output matrix (matrices) pointer. - * @param copy Boolean that determines whether to return the input as output or - * copy the input to a new memory address. **/ -template -void identity(const T** input, T** output, const Shape& shape, const bool copy) { - const auto total_elements = shape_size(shape); - - if (!copy) { - *output = *input; - } else { - std::memcpy(*output, *input, total_elements * sizeof(T)); - } +void identity(const char* input, char* output, const size_t size_in_bytes) { + std::memcpy(output, input, size_in_bytes); } } // namespace identity } // namespace reference diff --git a/src/core/src/op/identity.hpp b/src/core/src/op/identity.hpp index 800e5034fa0c30..db4a3de389c00b 100644 --- a/src/core/src/op/identity.hpp +++ b/src/core/src/op/identity.hpp @@ -14,13 +14,12 @@ namespace ov { namespace op { namespace v15 { -Identity::Identity(const Output& data, const bool copy) : Op({data}), m_copy(copy) { +Identity::Identity(const Output& data) : Op({data}) { constructor_validate_and_infer_types(); } bool Identity::Identity::visit_attributes(AttributeVisitor& visitor) { OV_OP_SCOPE(v15_Identity_visit_attributes); - visitor.on_attribute("copy", m_copy); return true; } @@ -36,14 +35,6 @@ std::shared_ptr Identity::Identity::clone_with_new_inputs(const OutputVect OV_OP_SCOPE(v15_Identity_clone_with_new_inputs); check_new_args_count(this, new_args); - return std::make_shared(new_args.at(0), m_copy); -} - -bool Identity::get_copy() const { - return m_copy; -} - -void Identity::set_copy(const bool copy) { - m_copy = copy; + return std::make_shared(new_args.at(0)); } } // namespace ov diff --git a/src/core/tests/type_prop/identity.cpp b/src/core/tests/type_prop/identity.cpp index 8764ecb0e68373..65c9fe462585b5 100644 --- a/src/core/tests/type_prop/identity.cpp +++ b/src/core/tests/type_prop/identity.cpp @@ -24,5 +24,4 @@ TEST_F(TypePropIdentityV15Test, default_ctor) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), ov::element::f64); EXPECT_EQ(op->get_output_partial_shape(0), ov::PartialShape({2, 2})); - EXPECT_EQ(op->get_copy(), false); } diff --git a/src/core/tests/visitors/op/identity.cpp b/src/core/tests/visitors/op/identity.cpp index ade79b499fd6e2..ced50d57a69892 100644 --- a/src/core/tests/visitors/op/identity.cpp +++ b/src/core/tests/visitors/op/identity.cpp @@ -15,11 +15,10 @@ TEST(attributes, Identity) { NodeBuilder::opset().insert(); const auto data = std::make_shared(ov::element::f32, ov::Shape{2, 2}); - const auto op = std::make_shared(data, true); + const auto op = std::make_shared(data); NodeBuilder builder(op, {data}); auto g_identity = ov::as_type_ptr(builder.create()); - constexpr auto expected_attr_count = 1; + constexpr auto expected_attr_count = 0; EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); - EXPECT_EQ(op->get_copy(), g_identity->get_copy()); } diff --git a/src/plugins/template/backend/ops/identity.cpp b/src/plugins/template/backend/ops/identity.cpp index 9fab43a2db867d..0c40ee5569fc5f 100644 --- a/src/plugins/template/backend/ops/identity.cpp +++ b/src/plugins/template/backend/ops/identity.cpp @@ -14,9 +14,12 @@ inline bool evaluate(const std::shared_ptr& op, using T = typename ov::element_type_traits::value_type; const std::vector input_shapes{op->get_input_shape(0)}; + const auto total_size = get_shape_size(out_shape); + const auto total_size_in_bytes = total_size * inputs[0].get_dtype().get_element_size(); + outputs[0].set_shape(input_shapes[0]); - ov::reference::Identity(inputs[0].data(), outputs[0].data(), out_shape, op->get_copy()); + ov::reference::Identity(static_cast(inputs[0].data()), static_cast(outputs[0].data()), total_size_in_bytes); return true; } diff --git a/src/plugins/template/tests/functional/op_reference/identity.cpp b/src/plugins/template/tests/functional/op_reference/identity.cpp index a5a2e51e751ce7..fc9a249851539c 100644 --- a/src/plugins/template/tests/functional/op_reference/identity.cpp +++ b/src/plugins/template/tests/functional/op_reference/identity.cpp @@ -12,11 +12,9 @@ namespace { struct IdentityParams { IdentityParams(const reference_tests::Tensor& matrices, bool copy, std::string name) : matrices{matrices}, - copy(copy), test_case_name{std::move(name)} {} reference_tests::Tensor matrices; - bool copy; std::string test_case_name; }; @@ -27,7 +25,6 @@ class ReferenceIdentity : public testing::TestWithParam, public function = CreateFunction(params); inputData = {params.matrices.data}; refOutData = {params.matrices.data}; - m_copy = params.copy; } static std::string getTestCaseName(const testing::TestParamInfo& obj) { @@ -37,26 +34,15 @@ class ReferenceIdentity : public testing::TestWithParam, public name << obj.param.matrices.type; name << "_shape_"; name << obj.param.matrices.shape; - name << "_copy_"; - name << obj.param.copy; return name.str(); } - void Validate() { - CommonReferenceTest::Validate(); - - bool pointers_match = refOutData[0].data() == actualOutData[0].data(); - ASSERT_EQ(pointers_match, !m_copy); - } - private: static std::shared_ptr CreateFunction(const IdentityParams& params) { const auto in_matrices = std::make_shared(params.matrices.type, params.matrices.shape); - const auto identity = std::make_shared(in_matrices, params.copy); + const auto identity = std::make_shared(in_matrices); return std::make_shared(identity->outputs(), ov::ParameterVector{in_matrices}); } - - bool m_copy; }; template @@ -91,10 +77,8 @@ std::vector generateIdentityParams() { 0.0f}); std::vector params; - params.emplace_back(matrices_2_2, false, "single_simple"); - params.emplace_back(matrices_2_2, true, "single_simple"); - params.emplace_back(matrices_2_3_3, false, "many_simple"); - params.emplace_back(matrices_2_3_3, true, "many_simple"); + params.emplace_back(matrices_2_2, "single"); + params.emplace_back(matrices_2_3_3, "many"); return params; } diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp index d24be9c9e2a250..ca8af030c88063 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp @@ -527,7 +527,7 @@ std::shared_ptr generate(const std::shared_ptr generate(const std::shared_ptr& node) { ov::ParameterVector params{std::make_shared(ov::element::f32, ov::Shape{4, 4, 4})}; - const auto identity = std::make_shared(params[0], false); + const auto identity = std::make_shared(params[0]); ov::ResultVector results{std::make_shared(identity)}; return std::make_shared(results, params, "Identity"); }