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

[Feature Request] RandomUniform operator support float16 #19252

Open
ZackWan opened this issue Jan 24, 2024 · 1 comment
Open

[Feature Request] RandomUniform operator support float16 #19252

ZackWan opened this issue Jan 24, 2024 · 1 comment
Labels
feature request request for unsupported feature or enhancement

Comments

@ZackWan
Copy link

ZackWan commented Jan 24, 2024

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'
@ZackWan ZackWan added the feature request request for unsupported feature or enhancement label Jan 24, 2024
@xadupre
Copy link
Member

xadupre commented Jan 25, 2024

Would it be possible to generate floats and cast them into float16? It would be less efficient but could unblock you until this issue is addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request request for unsupported feature or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants