microsoft / microsoft/onnxruntime

[Feature Request] RandomUniform operator support float16

Open
#19,252 1 comment 0 reactions 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

https://onnx.ai/onnx/operators/onnx__RandomUniformLike.html#l-onnx-doc-randomuniformlike
☝️ as document said, Onnx RandomUniform op should support float16 dtype.

Describe scenario use case
Question

I attempted to generate a graph utilizing a RandomUniform node with an input data type of float16, and attempted to conduct inference using the ONNX API. However, when invoking the onnxruntime.InferenceSession, I encountered a NotImplemented error. The relevant code snippet is provided below.

Further information
  • Version of onnx: 1.15.0

  • Version of onnxruntime: 1.16.1

  • Relevant Area: model usage, operators, IR

  • Is this issue related to a specific model?
    No

Notes
import onnx
from onnx import helper
from onnx import TensorProto
import onnxruntime 

# The protobuf definition can be found here:
# https://github.com/onnx/onnx/blob/master/onnx/onnx.proto

dtype = TensorProto.FLOAT16
# Create one output (ValueInfoProto)
Y1 = helper.make_tensor_value_info('Y1', dtype, [3, 4])

# Create a node (NodeProto) - This is based on Pad-11
random_uniform_node = helper.make_node(
    'RandomUniform', # node name
    [], # inputs
    ['Y1'], # outputs
    name="random_uniform_node",
    dtype=dtype,
    high=1.0,
    low=0.0,
    seed=0.5,
    shape=[3, 4] # attributes
)
print(random_uniform_node)

# Create the graph (GraphProto)
graph_def = helper.make_graph(
    [random_uniform_node],
    'test-model',
    [],
    [Y1],
)

# Create the model (ModelProto)
model_def = helper.make_model(graph_def, producer_name='onnx-example')

print('The model is:\n{}'.format(model_def))
onnx.checker.check_model(model_def)
print('The model is checked!')

onnx.save(model_def, 'random_uniform.onnx') 

sess = onnxruntime.InferenceSession('random_uniform.onnx') 

output = sess.run(['Y1'], {})[0] 
print(Y1)
print(output)

error shown as:

NotImplemented: [ONNXRuntimeError] : 9 : NOT_IMPLEMENTED : Could not find an implementation for RandomUniform(1) node with name 'random_uniform_node'

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 with the RandomUniform operator support used by onnxruntime.InferenceSession and reproduce the failure with the supplied Python example using TensorProto.FLOAT16. Confirm that the model loads and inference succeeds for a RandomUniform node with float16 output, without the reported NotImplemented error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
machine-learning
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.