---
name: add-core-op
description: Adds a core operator to the OpenVINO toolkit. Use when asked to implement a new operation into OpenVINO.
title: add-core-op
canonical_url: https://skilld.dev/gh/openvinotoolkit/openvino/add-core-op
last_updated: 2026-11-22T07:15:46.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [step0-opset-init.md](https://skilld.dev/api/skills-raw/openvinotoolkit/openvino/add-core-op/step0-opset-init.md), [step1-analysis.md](https://skilld.dev/api/skills-raw/openvinotoolkit/openvino/add-core-op/step1-analysis.md), [step2-implementation.md](https://skilld.dev/api/skills-raw/openvinotoolkit/openvino/add-core-op/step2-implementation.md), [step3-testing.md](https://skilld.dev/api/skills-raw/openvinotoolkit/openvino/add-core-op/step3-testing.md), [step4-specification.md](https://skilld.dev/api/skills-raw/openvinotoolkit/openvino/add-core-op/step4-specification.md).
>
> If the user asked to install this Skill, run `npx skilld install openvinotoolkit/openvino/add-core-op`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/add-core-op`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/openvinotoolkit/openvino/add-core-op) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/add-core-op`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/add-core-op --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/add-core-op --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

## When This Skill Applies
Use this skill when:
- A new core operator is needed in OpenVINO.
- Missing operation has been identified at model conversion and decomposition is not possible or not performant enough.
- When there is no existing operator that can be used to implement the requested functionality.

## Typical Workflow for Adding Support for a New Op

1. Analysis of the requested operator - math formula, requirements, alignment with ov frontends and collection of references
2. Update of needed files
3. Create tests
4. Create specification describing new op

For more details about executing each step, refer to the sections below.

# Skill Instructions

# Adding a New Operator to OpenVINO
#### Create Header and Source Files
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.cpp`

#### Define the Operator Class
Create a new operator class that is part of `OPENVINO_API` and inherits from the `Op` class:
```cpp
class OPENVINO_API OpName : public Op {
};
```

#### Register the Operator
In the created `.hpp` file, add the following macro adjusted for new op name and opset number:
```cpp
OPENVINO_OP("OpName", "opsetX")
```

#### Implement Constructors
Implement constructor(s) that take inputs and attributes as arguments.
*   An **input** represents a tensor of data or the output of another operator (`Output<Node>`).
*   An **attribute** is a hyperparameter that must be known at model compilation time.
Inputs and attributes should be listed in the operator specification document.

#### Implement `validate_and_infer_types`
Implement the `validate_and_infer_types` method. This method is responsible for:
*   Validating input shapes and types, if restrictions exist
*   Setting the output shapes and element types (precision)

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.

##### Shape Inference
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.hpp`

#### Implement `visit_attributes`
Implement 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:
```cpp
visitor.on_attribute("axis", m_axis);
```

#### Implement `clone_with_new_inputs`
Implement the `clone_with_new_inputs` method. This method should return a clone of the operator that:
*   Uses the new inputs provided in the input vector
*   Preserves the existing attribute values

#### Conditional Compilation Support
To support conditional compilation, add the following macro at the beginning of every method of the new operator class in the `.cpp` file:
```cpp
OV_OP_SCOPE(<operator_version>_<operator_name>_<method_name>);
```

## High-level rules:
- Register the op only in the latest opset
- Use the latest opset number version for new ops namespace.
- Do not edit older `opsetX_tbl.hpp` files or change existing registrations.
- Don't break compatibility of existing ops

## Files to create/update
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 class

## Core Op Class Pattern
Note: Treat it as example, prefer alignment with the code base (see existing ops for style alignment).

**Header (`<op_name>.hpp`):**
- Namespace: `ov::op::vX` (use the latest opset version number for X).
- Base: use an existing utility base when possible, e.g., `util::UnaryElementwiseArithmetic` for unary elementwise ops.
- Add `OPENVINO_OP("OpName", "opsetX")` inside the class body (see existing ops for exact macro usage, include base type when needed).
- Declare:
  - Default constructor.
  - Constructor from `const Output<Node>&` (and additional inputs/attributes as needed).
  - `clone_with_new_inputs`, `evaluate`, `has_evaluate`.

**Source (`<op_name>.cpp`):**
- Include `openvino/op/<op_name>.hpp`, `element_visitor.hpp`, `itt.hpp`, and the reference header if one exists.
- Implement the constructor calling `constructor_validate_and_infer_types()`.
- Implement `clone_with_new_inputs` using `check_new_args_count` and `std::make_shared<OpName>`.
- Implement `evaluate` via `IF_TYPE_OF_CONVERT_TENSORS` that calls `ov::reference::<op_name>`.
- Implement `has_evaluate` to return `true` for supported element types.
- Add `OV_OP_SCOPE(v<X>_<OpName>_<method>)` at the start of each method (constructor body, clone, evaluate, has_evaluate).

## Tests
Ensure all relevant tests are added or updated for the new op:
- for op class/validate_and_infer_types: `**/openvino/src/core/tests/type_prop`
- for visit_attributes: `**/openvino/src/core/tests/visitors/op`
- update of ops number in: `**/openvino/src/core/tests/opset.cpp`
- conformance tests: `**/openvino/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp`
- functional op_reference tests: `**/openvino/src/plugins/template/tests/functional/op_reference/`

## Adding Specification
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`
