Skip to content

Reference implementation of ops #4432

@gramalingam

Description

@gramalingam

It would be useful to have a reference implementation of the ONNX ops, to complement the existing spec.

The existing guidelines for adding a new op to the spec already recommends a reference implementation of the op in Python, and this has been followed for a number of recent ops. However, there are still two limitations that would be worth addressing.

  • Many of the ops added to the spec earlier do not have reference implementations.
  • The reference implementations are not available in a well-organized way that makes it easy for users to call them.

The proposal is to enable users to write code as below:

import onnx.opset15 as op

def my_function(x, y, bias):
   t1 = op.MatMul(x, y)  # calls operation MatMul (of opset 15) with inputs x and y
   t2 = op.Add(t1, bias)
   t3 = op.Elu(t2, alpha=0.4)  # calls operation Elu with input t2 and value 0.4 for attribute alpha.
   return t3

Specifically, this requires ensuring that all reference implementations use a consistent API, and type-representation for values (eg., numpy arrays for tensors), and that they be organized into a module/class like object that allows us to invoke the ops belonging to a specific opset version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions