microsoft / microsoft/onnxruntime

[Feature Request] C-API: Implement KernelInfoGetAttribute for all possible attribute types

Open
#15,079 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature request
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

Describe the feature request

The current C-API only offers the following functions for loading attributes:

  • KernelInfoGetAttribute_float
  • KernelInfoGetAttribute_int64
  • KernelInfoGetAttribute_string
  • KernelInfoGetAttributeArray_float
  • KernelInfoGetAttributeArray_int64
  • KernelInfoGetAttribute_tensor

The standard allows the following types:

  enum AttributeType {
    UNDEFINED = 0;
    FLOAT = 1;
    INT = 2;
    STRING = 3;
    TENSOR = 4;
    GRAPH = 5;
    SPARSE_TENSOR = 11;
    TYPE_PROTO = 13;

    FLOATS = 6;
    INTS = 7;
    STRINGS = 8;
    TENSORS = 9;
    GRAPHS = 10;
    SPARSE_TENSORS = 12;
    TYPE_PROTOS = 14;
  }

The following functions are therefore missing from the C-API and should be added:

  • KernelInfoGetAttribute_graph
  • KernelInfoGetAttribute_sparse_tensor
  • KernelInfoGetAttribute_type_proto
  • KernelInfoGetAttributeArray_string
  • KernelInfoGetAttributeArray_tensor
  • KernelInfoGetAttributeArray_graph
  • KernelInfoGetAttributeArray_sparse_tensors
  • KernelInfoGetAttributeArray_type_proto
  • KernelInfoGetAttribute_undefined (?)
Describe scenario use case

Several of the above attribute types are used in the standard. Others might be useful to C-API authors precisely because the operator that would use them is not in the standard. Either way, it is an unfortunate surprise for C-API users to find out that the API does not support an attribute type they were planning to use.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing KernelInfoGetAttribute_* C-API functions and the linked ONNX AttributeType definition. Map the listed scalar and array attribute types to corresponding API functions, resolve whether UNDEFINED needs support, and verify that all standard types are covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.