Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build] Question -- is it possible to override/replace a core operator? #23007

Open
bluejack opened this issue Dec 4, 2024 · 1 comment
Open
Labels
build build issues; typically submitted using template

Comments

@bluejack
Copy link

bluejack commented Dec 4, 2024

Describe the issue

I have read the extensions guidelines and it's not clear. Also, building and linking a shared library is not a trivial project. Before I go too far down the road, I want to see if anyone has done this, and if anyone knows of other examples of this.

Urgency

No response

Target platform

arm, but eventually all

Build script

I'm not quite sure even how to build the shared library yet.

Error / output

I tried a straight up gcc build, but am still working out the build flags. presumably there is a cmake example out there somewhere that would be a better idea.

Visual Studio Version

No response

GCC / Compiler Version

apple clang 15.0.0

@bluejack bluejack added the build build issues; typically submitted using template label Dec 4, 2024
@skottmckay
Copy link
Contributor

Yes. If you create a custom operator and register it using the matching domain and name it will override.

// This tests that a custom op can override an ONNX operator implemented by ORT.
TEST(CustomKernelTests, CustomKernelWithBuiltInSchema) {
SessionOptions so;
so.session_logid = "CustomKernelWithBuiltInSchema";
// Register a custom kernel that matches the ONNX Mul but is implemented to do an Add so we can validate the
// custom kernel overrides the ORT Mul kernel
KernelDefBuilder def;
def.SetName("Mul")
.SetDomain(onnxruntime::kOnnxDomain)
.SinceVersion(7)
.Provider(onnxruntime::kCpuExecutionProvider)
.TypeConstraint("T", DataTypeImpl::GetTensorType<float>());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build issues; typically submitted using template
Projects
None yet
Development

No branches or pull requests

2 participants