// Copyright (C) 2018-2026 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "snippets/op/broadcastmove.hpp"

#include <memory>
#include <utility>

#include "openvino/core/attribute_visitor.hpp"
#include "openvino/core/dimension.hpp"
#include "openvino/core/node.hpp"
#include "openvino/core/node_output.hpp"
#include "openvino/op/op.hpp"
#include "snippets/itt.hpp"

namespace ov::snippets::op {

BroadcastMove::BroadcastMove(const Output<Node>& x, ov::Dimension bcast_dimension)
    : Op({x}),
      bcast_dimension(std::move(bcast_dimension)) {
    constructor_validate_and_infer_types();
}

bool BroadcastMove::visit_attributes(AttributeVisitor& visitor) {
    visitor.on_attribute("bcast_dimension", bcast_dimension);
    return true;
}

std::shared_ptr<Node> BroadcastMove::clone_with_new_inputs(const OutputVector& new_args) const {
    INTERNAL_OP_SCOPE(BroadcastMove);
    check_new_args_count(this, new_args);
    return std::make_shared<BroadcastMove>(new_args.at(0), bcast_dimension);
}

void BroadcastMove::validate_and_infer_types() {
    auto broadcasted_shape = get_input_partial_shape(0);
    if (broadcasted_shape.size() == 0) {
        broadcasted_shape.resize(1);
    }
    *broadcasted_shape.rbegin() = bcast_dimension;
    set_output_type(0, get_input_element_type(0), broadcasted_shape);
}

}  // namespace ov::snippets::op
