一键导入
add-core-op
// Adds a core operator to the OpenVINO toolkit. Use when asked to implement a new operation into OpenVINO.
// Adds a core operator to the OpenVINO toolkit. Use when asked to implement a new operation into OpenVINO.
Add a new operation to the OpenVINO CPU plugin — node registration, JIT/oneDNN executors (AVX2/AVX-512/AMX), and functional tests.
Adds a new operation to OpenVINO Frontend pipelines with translator updates, registration, and tests.
Adds a new OpenVINO fusion transformation (subgraph to one or several operations) and corresponding tests.
Add a new operation to the OpenVINO GPU plugin — OpenCL kernel design, oneDNN-backed paths, sub-group/LWS tuning, and functional tests.
Analyze a HuggingFace model and attempt OpenVINO conversion — probe properties, run strategy matrix, classify failures, and produce a structured routing report.
Investigate and fix model conversion issues in OpenVINO Frontends (ONNX, PyTorch) — triage, debugging, accuracy comparison, and pre-submission verification.
| name | add-core-op |
| description | Adds a core operator to the OpenVINO toolkit. Use when asked to implement a new operation into OpenVINO. |
Use this skill when:
For more details about executing each step, refer to the sections below.
The implementation of a class representing an operator must have corresponding .hpp and .cpp files. These files should be created in the following locations:
**/openvino/src/core/include/openvino/op/new_op_name.hpp**/openvino/src/core/src/op/new_op_name.cppCreate a new operator class that is part of OPENVINO_API and inherits from the Op class:
class OPENVINO_API OpName : public Op {
};
In the created .hpp file, add the following macro adjusted for new op name and opset number:
OPENVINO_OP("OpName", "opsetX")
Implement constructor(s) that take inputs and attributes as arguments.
Output<Node>).validate_and_infer_typesImplement the validate_and_infer_types method. This method is responsible for:
At this stage, input values are usually unknown unless the input is a Constant.
If an input is a Constant or can be evaluated, its value may be retrieved. For example, the axis input for a Reduce operator is typically provided as a Constant, allowing its value to be validated and used for output shape inference.
Input and output shapes may be static or dynamic. The PartialShape class is used to represent both cases.
For operators without existing common shape inference function, the shape-related logic should be implemented in a separate shape_infer function so it can be shared with plugins. This function should be added to: **/openvino/src/core/shape_inference/include/
Following the file name convention, example:
**/openvino/src/core/shape_inference/include/new_op_shape_inference.hppvisit_attributesImplement the visit_attributes method, which is used, for example, by the serialization mechanism.
Each attribute (usually also a class member) must be visited by calling on_attribute with the attribute name and value, for example:
visitor.on_attribute("axis", m_axis);
clone_with_new_inputsImplement the clone_with_new_inputs method. This method should return a clone of the operator that:
To support conditional compilation, add the following macro at the beginning of every method of the new operator class in the .cpp file:
OV_OP_SCOPE(<operator_version>_<operator_name>_<method_name>);
opsetX_tbl.hpp files or change existing registrations.Note: Treat it as a double-check; no need to create a file if adding a new version of the op.
Create:
**/openvino/src/core/include/openvino/op/new_op_name.hpp – class declaration.**/openvino/src/core/src/op/new_op_name.cpp – implementation.**/openvino/src/core/reference/include/openvino/reference/new_op_name.hpp – reference kernel.Update :
**/openvino/src/core/dev_api/openvino/op/ops_decl.hpp – register new Op class**/openvino/src/core/include/openvino/op/ops.hpp – include new op header**/openvino/src/core/include/openvino/opsets/opsetX_tbl.hpp- register new Op classNote: Treat it as example, prefer alignment with the code base (see existing ops for style alignment).
Header (<op_name>.hpp):
ov::op::vX (use the latest opset version number for X).util::UnaryElementwiseArithmetic for unary elementwise ops.OPENVINO_OP("OpName", "opsetX") inside the class body (see existing ops for exact macro usage, include base type when needed).const Output<Node>& (and additional inputs/attributes as needed).clone_with_new_inputs, evaluate, has_evaluate.Source (<op_name>.cpp):
openvino/op/<op_name>.hpp, element_visitor.hpp, itt.hpp, and the reference header if one exists.constructor_validate_and_infer_types().clone_with_new_inputs using check_new_args_count and std::make_shared<OpName>.evaluate via IF_TYPE_OF_CONVERT_TENSORS that calls ov::reference::<op_name>.has_evaluate to return true for supported element types.OV_OP_SCOPE(v<X>_<OpName>_<method>) at the start of each method (constructor body, clone, evaluate, has_evaluate).Ensure all relevant tests are added or updated for the new op:
**/openvino/src/core/tests/type_prop**/openvino/src/core/tests/visitors/op**/openvino/src/core/tests/opset.cpp**/openvino/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp**/openvino/src/plugins/template/tests/functional/op_reference/For the newly added operation, a specification must be created as a .rst file following the conventions for other operators.
Example: **/openvino/docs/articles_en/documentation/openvino-ir-format/operation-sets/operation-specs/signals/istft-16.rst