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

[DRAFT][dredd] Introduce dredd test for TensorShape #14050

Closed
wants to merge 6 commits into from

Conversation

icodo98
Copy link
Contributor

@icodo98 icodo98 commented Sep 23, 2024

Introduce new dredd-rule for tensors shape.

ONE-DCO-1.0-Signed-off-by: JuYoung Lee rsb98759@gmail.com

@icodo98 icodo98 added DRAFT A draft issue or PR for sharing one's current working status and discussion. SSAFY labels Sep 23, 2024
@icodo98 icodo98 requested a review from a team September 23, 2024 01:49
@icodo98
Copy link
Contributor Author

icodo98 commented Sep 23, 2024

related : #13998

@icodo98 icodo98 changed the title [dredd] Introduce dredd test for TensorShape [DRAFT][dredd] Introduce dredd test for TensorShape Sep 24, 2024
@icodo98
Copy link
Contributor Author

icodo98 commented Sep 24, 2024

@nnfw-bot test nncc-debug nncc-release

@@ -0,0 +1,33 @@
# padding with dynamic shape, others same as Pad_000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This recipe and rule ard designed for shape Inference.
How about changing Pad_002 directory to Inf_Pad_00x to separate it from other tests like Net_Conv_Add_00x ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about changing Pad_002 directory to Inf_Pad_00x to separate it from other tests like Net_Conv_Add_00x ?

Nice idea!

I'll change it.

Introduce new dredd-rule for check tensors shape.

ONE-DCO-1.0-Signed-off-by: JuYoung Lee rsb98759@gmail.com
ONE-DCO-1.0-Signed-off-by: JuYoung Lee rsb98759@gmail.com
ONE-DCO-1.0-Signed-off-by: JuYoung Lee rsb98759@gmail.com
Copy link
Contributor

@shs-park shs-park left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to work well!
I left a few minor comments.

const auto tensor = tensors->Get(i);
auto shape = tensor->shape_signature() ? tensor->shape_signature() : tensor->shape();
os << reader.tensor_name(tensor) << " ";
for (int8_t i = 0; i < shape->size(); i++)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a must, but most machines do calculations in 32-bit units, so there's probably no need to reduce it to 8-bit in for loop.

Suggested change
for (int8_t i = 0; i < shape->size(); i++)
for (uint32_t i = 0; i < shape->size(); i++)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a must, but most machines do calculations in 32-bit units, so there's probably no need to reduce it to 8-bit in for loop.

I'll update it.

RULE "VERIFY_FILE_FORMAT" $(verify_file_format) '=' 1

RULE "PAD_EXIST" $(op_count PAD) '=' 1
RULE "PAD_SHAPE" $(tensor_shape ofm) '=' 1,-1,7,2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'shape' expression 1,-1,7,2 is fine now, but it would be better to express it in a more formalized form like [1, -1, 7, 2].
It would be better if it could handle spaces between commas as well.

Suggested change
RULE "PAD_SHAPE" $(tensor_shape ofm) '=' 1,-1,7,2
RULE "PAD_SHAPE" $(tensor_shape ofm) '=' [1, -1, 7, 2]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from ##13998 (comment)

FYI) RULE "PAD_SHAPE" $(tensor_shape ofm) '=' [1, -1, 7, 2] does not work with the current code. Currently, the rule only works if the arguments have exactly 4 elements, so there cannot be any spaces in between, such as [1, -1, 7, 2]. Therefore, at the moment, we are checking shapes in the form of 1,-1,7,2.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks for the description.
How about using a quoted string, i.e., "[1, -1, 7, 2]"?
If it's difficult, the current implementation is not bad either =)

@@ -0,0 +1,6 @@
# To check if dynamic dimension properly infered
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo
=)

Suggested change
# To check if dynamic dimension properly infered
# To check if dynamic dimension properly inferred

Copy link
Contributor Author

@icodo98 icodo98 Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo =)

Sorry, I'll fix it.

@@ -96,6 +96,7 @@ Add(PadV2_001 PASS substitute_padv2_to_pad)
Add(Softmax_001 PASS decompose_softmax)
Add(Softmax_002 PASS decompose_softmax)
Add(StridedSlice_003 PASS substitute_strided_slice_to_reshape)
Add(Inf_Pad_000 PASS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sort in alphabetical order

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sort in alphabetical order

Instead of sorting, what about separate Inf_ tests?

Suggested change
Add(Inf_Pad_000 PASS)
# Shape Inference test
Add(Inf_Pad_000 PASS)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

, what about separate Inf_ tests?

👍

change rule shape to be enclosed in brackets
change type to uint32_t
seperate inference test list

ONE-DCO-1.0-Signed-off-by: JuYoung Lee rsb98759@gmail.com

RULE "VERIFY_FILE_FORMAT" $(verify_file_format) '=' 1

RULE "PAD_EXIST" $(op_count PAD) '=' 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, PAD_EXIST is not related to SHAPE_INFERENCE.
Why is this necessary?

Copy link
Contributor Author

@icodo98 icodo98 Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary?

You're right.

ONE-DCO-1.0-Signed-off-by: sunki <ajsthfldu@outlook.com>
remove unneccesary rule for shape inference.

ONE-DCO-1.0-Signed-off-by: JuYoung Lee rsb98759@gmail.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DRAFT A draft issue or PR for sharing one's current working status and discussion. SSAFY
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants