Index of every page on this site: llms.txt
All skills
openvinotoolkit avatar

/add-fe-op

@993f33e
Run it yourself

Adds a new operation to OpenVINO Frontend pipelines with translator updates, registration, and tests.

  • 7 files
  • 41.5 KB
  • Updated 6 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/openvinotoolkit/openvino/add-fe-op

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

step2-translation.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Skill: FE Op Translation

Source: skills/add-fe-op/SKILL.md (Step 2 + Translation Recommendations) Agent: fe_agent

Prerequisites

  • Completed fe_op_analysis with action=translate or action=repair.
  • Op name, source framework, support state, inputs/outputs/attributes are known.
  • OV equivalent op (or a composition path) identified.

Translation paths by frontend

PyTorch

Translator file: src/frontends/pytorch/src/op/<op_name>.cpp

// Minimal PyTorch FE translator template
#include "openvino/frontend/pytorch/node_context.hpp"
#include "openvino/op/<ov_op>.hpp"
#include "utils.hpp"

namespace ov {
namespace frontend {
namespace pytorch {
namespace op {

using namespace ov::op;

OutputVector translate_<op_name>(const NodeContext& context) {
    // Validate input count
    num_inputs_check(context, <min_inputs>, context.get_input_size());

    // Fetch inputs
    auto x = context.get_input(0);
    // auto attr = context.const_input<int64_t>(1);  // for attribute-valued inputs

    // Build OV subgraph
    auto result = std::make_shared<v0::YourOvOp>(x /*, attrs */);
    return {result};
}

}  // namespace op
}  // namespace pytorch
}  // namespace frontend
}  // namespace ov

TensorFlow

Translator file: src/frontends/tensorflow/src/op/<op_name>.cpp

Preferred patterns:

  • Unary elementwise: use the generic unary registration path (see unary_op.cpp).
  • Complex: write a dedicated translator function.
#include "common_op_table.hpp"
#include "openvino/op/<ov_op>.hpp"

namespace ov {
namespace frontend {
namespace tensorflow {
namespace op {

OutputVector translate_<op_name>(const NodeContext& context) {
    default_op_checks(context, 1, {"<TF_OP_NAME>"});
    auto x = context.get_input(0);
    auto result = std::make_shared<ov::op::v0::YourOvOp>(x);
    set_node_name(context.get_name(), result);
    return {result->output(0)};
}

}  // namespace op
}  // namespace tensorflow
}  // namespace frontend
}  // namespace ov

ONNX

Translator file: src/frontends/onnx/src/ops/<op_name>.cpp

#include "core/null_node.hpp"
#include "openvino/frontend/onnx/extension/conversion.hpp"
#include "openvino/op/<ov_op>.hpp"

namespace ngraph {
namespace onnx_import {
namespace op {
namespace set_<version> {

ov::OutputVector <op_name>(const ov::frontend::onnx::Node& node) {
    const auto inputs = node.get_ov_inputs();
    auto x = inputs.at(0);
    // auto attr_val = node.get_attribute_value<int64_t>("attr_name", default_val);
    auto result = std::make_shared<ov::op::v0::YourOvOp>(x);
    return {result};
}

}  // namespace set_<version>
}  // namespace op
}  // namespace onnx_import
}  // namespace ngraph

Translation Recommendations

Shape handling

  • Prefer runtime ShapeOf-based graph logic for shape-dependent behavior.
  • Avoid get_shape() (fully static read at conversion time).
  • get_partial_shape() is acceptable for compile-time rank-only decisions.
// Preferred: runtime shape computation
auto shape_node = std::make_shared<v3::ShapeOf>(x, element::i64);
// Avoid:
// auto static_shape = x.get_shape();  // will fail for dynamic input

Data type handling

  • If the framework op allows mixed input types, preserve this in translation — do not over-constrain to a single dtype.
  • Do not create Constant values from get_element_type() when the element type can be dynamic at conversion time.
// Preferred: type-safe runtime path
// Avoid:
// auto type_const = Constant::create(element::i64, {1}, {x.get_element_type()});

Reuse and simplification

  • For simple 1:1 ops, check utils.hpp and utils_quantize.hpp for helpers before writing new code.
  • If the same op already has a translator in another frontend (detected in fe_op_analysis), extract the shared logic into a common utility header rather than duplicating.

Fallback Translator

When a real OV mapping is unavailable:

OutputVector translate_<op_name>_stub(const NodeContext& context) {
    // FALLBACK: no OV op mapping — op is not yet supported.
    // The FE Agent will escalate to Core Agent for a new core op.
    OPENVINO_THROW("No FE translation for op: <op_name>");
}

A fallback stub:

  • Keeps the model from crashing on unrelated unsupported ops.
  • Does not count as support.
  • Must be reported as partial, never success.
  • Always triggers the FE→Core escalation path.

Output

  • Modified or created translator .cpp file (ready for commit/patch).
  • Notes for the Registration skill: which keys / macros need adding.
  • Translation complexity label: real_translation or fallback_stub.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 993f33e. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 14 hours ago.

Activeupdated 6 months ago

README badge

README badge for openvinotoolkit/openvino/add-fe-op