namespace ov::pass::transpose_sinking::utils

Overview

namespace utils {

// namespaces

namespace ov::pass::transpose_sinking::utils::sink_backward;
namespace ov::pass::transpose_sinking::utils::sink_forward;

// structs

struct TransposeInputsInfo;

// global functions

TransposeInputsInfo GetFirstTransposeInput(const std::shared_ptr<ov::Node>&);
bool IfNodeHasTransposeInputs(const ov::Output<ov::Node>&);
ov::AxisVector ReverseTransposeOrder(const ov::AxisVector&);
void SwapOutputNames(ov::Output<ov::Node>, ov::Output<ov::Node>);

void SwapFriendlyNames(
    const std::shared_ptr<ov::Node>&,
    const std::shared_ptr<ov::Node>&
    );

void UpdateForwardSinkingAbility(const std::shared_ptr<ov::Node>&);
bool CheckTransposeConsumers(const ov::Output<ov::Node>&);
bool RemoveTransposeConsumers(const std::shared_ptr<ov::Node>& node);

ov::Output<ov::Node> ChangeValuesOrder(
    const ov::Output<ov::Node>& input,
    const ov::AxisVector& transpose_axis_order,
    const std::shared_ptr<ov::opset10::Constant>& axis
    );

Output<Node> ChangeAxes(
    const Output<Node>& input,
    const AxisVector& transpose_axis_order,
    const std::shared_ptr<ov::opset10::Constant>& axis
    );

Output<Node> ChangeAxes(
    const Output<Node>& input,
    const std::shared_ptr<ov::opset10::Constant>& transpose_axis_order,
    const std::shared_ptr<ov::opset10::Constant>& axis
    );

std::vector<size_t> GetOrderAfterReduction(
    const std::vector<size_t>& axes_values,
    const std::vector<size_t>& order_values
    );

std::vector<size_t> GetOrderBeforeReduction(
    const std::vector<size_t>& axes_values,
    const std::vector<size_t>& order_values
    );

} // namespace utils

Detailed Documentation

Global Functions

TransposeInputsInfo GetFirstTransposeInput(const std::shared_ptr<ov::Node>&)

Finds node first input that is a transpose operation and returns filled TransposeInputsInfo for it.

bool IfNodeHasTransposeInputs(const ov::Output<ov::Node>&)

Checks if.

  • has any input node that is a transpose operation

ov::AxisVector ReverseTransposeOrder(const ov::AxisVector&)

Reverses order of transpose operation. Do it in a such way that if we had couple following one after another transposes (one would be reversed version of another) we will have no transpose as a result of that couple of transposes.

void SwapOutputNames(ov::Output<ov::Node>, ov::Output<ov::Node>)

Swaps @args output tensor names.

void SwapFriendlyNames(
    const std::shared_ptr<ov::Node>&,
    const std::shared_ptr<ov::Node>&
    )

Swaps @args friendly names.

bool CheckTransposeConsumers(const ov::Output<ov::Node>&)

Checks if.

  • has consumers that are all the same Transpose operation and that sinking is enabled for all these Transpose ops. Otherwise returns false. If no consumers at all returns false.

bool RemoveTransposeConsumers(const std::shared_ptr<ov::Node>& node)

Removes all Transpose consumers for given node.

ov::Output<ov::Node> ChangeValuesOrder(
    const ov::Output<ov::Node>& input,
    const ov::AxisVector& transpose_axis_order,
    const std::shared_ptr<ov::opset10::Constant>& axis
    )

Inserts Gather operation which changes the order of values in.

  • input according to

  • transpose_axis_order along

  • axis.

Output<Node> ChangeAxes(
    const Output<Node>& input,
    const AxisVector& transpose_axis_order,
    const std::shared_ptr<ov::opset10::Constant>& axis
    )

Inserts Gather operation which changes the order of values in.

  • input according to

  • transpose_axis_order along

  • axis.

Output<Node> ChangeAxes(
    const Output<Node>& input,
    const std::shared_ptr<ov::opset10::Constant>& transpose_axis_order,
    const std::shared_ptr<ov::opset10::Constant>& axis
    )

Inserts Gather operation which changes the order of values in.

  • input according to

  • transpose_axis_order along

  • axis.

std::vector<size_t> GetOrderAfterReduction(
    const std::vector<size_t>& axes_values,
    const std::vector<size_t>& order_values
    )

Returns the updated axes order for case when the initial axes order has more elements than after TransposeSinking, e.g.:

before: Transpose(the initial axes order) -> ReduceMax after : ReduceMax -> Transpose (the updated axes order)

before: Unsqueeze -> Transpose (the initial axes order) after : Transpose (the updated axes order) -> Unsqueeze

std::vector<size_t> GetOrderBeforeReduction(
    const std::vector<size_t>& axes_values,
    const std::vector<size_t>& order_values
    )

Returns the updated axes order for case when the initial axes order has less elements than after TransposeSinking, e.g.:

before : ReduceMax -> Transpose (the updated axes order) after: Transpose(the initial axes order) -> ReduceMax

before: Transpose (the updated axes order) -> Unsqueeze after : Unsqueeze -> Transpose (the initial axes order)