openvino icon indicating copy to clipboard operation
openvino copied to clipboard

[ONNX] Added support for Multinomial-7 operator

Open PRATHAM-SPS opened this issue 11 months ago • 16 comments

Details:

  • Extend ONNX Frontend with Multinomial-7 operator

Tickets:

  • 118986

PRATHAM-SPS avatar Mar 16 '24 08:03 PRATHAM-SPS

I am Facing this Error:-

/home/pratham/Desktop/openvino/src/frontends/onnx/frontend/src/op/multinomial.cpp: In function ‘ov::OutputVector ov::frontend::onnx::op::set_1::multinomial(const ov::frontend::onnx::Node&)’: /home/pratham/Desktop/openvino/src/frontends/onnx/frontend/src/op/multinomial.cpp:33:44: error: ‘class ov::descriptor::Tensor’ has no member named ‘data’ 33 | auto data_ptr = input.get_tensor().data(); | ^~~~ /home/pratham/Desktop/openvino/src/frontends/onnx/frontend/src/op/multinomial.cpp:33:49: error: expected primary-expression before ‘double’ 33 | auto data_ptr = input.get_tensor().data(); | ^~~~~~ gmake[2]: *** [src/frontends/onnx/frontend/CMakeFiles/openvino_onnx_frontend.dir/build.make:1462: src/frontends/onnx/frontend/CMakeFiles/openvino_onnx_frontend.dir/src/op/multinomial.cpp.o] Error 1 gmake[1]: *** [CMakeFiles/Makefile2:5782: src/frontends/onnx/frontend/CMakeFiles/openvino_onnx_frontend.dir/all] Error 2 gmake: *** [Makefile:166: all] Error 2

PRATHAM-SPS avatar Mar 16 '24 08:03 PRATHAM-SPS

@PRATHAM-SPS I've took a look on a docs.

https://github.com/onnx/onnx/blob/main/docs/Operators.md#Multinomial and https://docs.openvino.ai/2024/documentation/openvino-ir-format/operation-sets/operation-specs/generation/multinomial-13.html

In my understanding you don't need to generate samples at all. You should pass ONNX's "sample_size" to OpenVINO's "num_samples". @mitruska could you correct me if I'm wrong.

Also, important thing - you shouldn't ignore "seed" and "dtype". But because OpenVINO uses seed as a int64 - you should do it like here https://github.com/openvinotoolkit/openvino/blob/3d45a644969454d09c3f7e97ea60cbbd8abb0740/src/frontends/onnx/frontend/src/op/random_uniform.cpp#L28

And use this https://github.com/openvinotoolkit/openvino/blob/3d45a644969454d09c3f7e97ea60cbbd8abb0740/src/frontends/onnx/frontend/src/utils/common.cpp#L33 to convert dtype to ov::element::Type

gkrivor avatar Mar 20 '24 11:03 gkrivor

Hello @PRATHAM-SPS, thank you for this contribution!

I agree with the @gkrivor previous comments. Added few more. The final solution should be similar to the RandomUniform.

Please confirm that you are working on resolving the comments.

Sure I will try to make necessary changes

PRATHAM-SPS avatar Mar 26 '24 07:03 PRATHAM-SPS

@gkrivor and @mitruska , could you take a look at the code and tell me if I'm on the right track?

PRATHAM-SPS avatar Mar 27 '24 13:03 PRATHAM-SPS

@PRATHAM-SPS do you have any updates here? seems we are about to cross the finish line with it

andrei-kochin avatar Apr 15 '24 11:04 andrei-kochin

@PRATHAM-SPS do you have any updates here? seems we are about to cross the finish line with it

Hey @andrei-kochin , I'll get to it in 3 to 4 days. Pretty tied up with academic stuff, but I'll definitely catch up soon.

PRATHAM-SPS avatar Apr 17 '24 16:04 PRATHAM-SPS

@PRATHAM-SPS do you have any updates here? seems we are about to cross the finish line with it

Hey @andrei-kochin , I'll get to it in 3 to 4 days. Pretty tied up with academic stuff, but I'll definitely catch up soon.

@PRATHAM-SPS Good luck!

andrei-kochin avatar Apr 17 '24 17:04 andrei-kochin

@PRATHAM-SPS any news for us?

andrei-kochin avatar Apr 22 '24 11:04 andrei-kochin

@PRATHAM-SPS any news for us?

I've made some slight adjustments based on feedback, and now I'm testing it out on my end.

PRATHAM-SPS avatar Apr 24 '24 16:04 PRATHAM-SPS

@PRATHAM-SPS I suggest to modify tests and verify only output shapes. But you need to make input parameters slightly more complicated because: Output tensor with shape [batch_size, sample_size] So, you need to provide batch_size > 1 and sample_size > 1 (I think something around 5-10 is ok) to get some checks. We cannot just verify an output is only [1,1]. Do you need any help with tests?

gkrivor avatar Apr 29 '24 07:04 gkrivor

@PRATHAM-SPS I suggest to modify tests and verify only output shapes. But you need to make input parameters slightly more complicated because: Output tensor with shape [batch_size, sample_size] So, you need to provide batch_size > 1 and sample_size > 1 (I think something around 5-10 is ok) to get some checks. We cannot just verify an output is only [1,1]. Do you need any help with tests?

I think there is some build issue on my system, all other test cases are getting failed. I have tried with a mish 18 operator, it is also getting failed at my end. And surely, I will need some assistance from you to cover multinomial test cases as its outcome is probable. Thank you for your assistance.

PRATHAM-SPS avatar Apr 30 '24 01:04 PRATHAM-SPS

build_jenkins

gkrivor avatar May 07 '24 11:05 gkrivor

build_jenkins

gkrivor avatar May 13 '24 09:05 gkrivor

build_jenkins

gkrivor avatar May 20 '24 09:05 gkrivor

build_jenkins

gkrivor avatar May 21 '24 04:05 gkrivor

build_jenkins

gkrivor avatar May 22 '24 14:05 gkrivor

build_jenkins

gkrivor avatar May 24 '24 04:05 gkrivor

build_jenkins

gkrivor avatar May 28 '24 08:05 gkrivor