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

[CMSIS-NN] Fixed the case with repeating operands in the QNN binary ops #11732

Merged
merged 2 commits into from
Jun 17, 2022

Conversation

ashutosh-arm
Copy link
Contributor

@ashutosh-arm ashutosh-arm commented Jun 15, 2022

This commit is to fix issues in CMSIS-NN passes
that surface when the same operand is repeated
in QNN binary ops.

cc @areusch

@ashutosh-arm
Copy link
Contributor Author

cc: @Mousius @grant-arm @manupa-arm for code review.

Copy link
Member

@Mousius Mousius left a comment

Choose a reason for hiding this comment

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

I have a few questions @ashutosh-arm, hopefully I've not missed the obvious 😸

python/tvm/relay/op/contrib/cmsisnn.py Outdated Show resolved Hide resolved
"input": np.random.randint(in_min, high=in_max, size=shape, dtype=dtype),
}
output_list = generate_ref_data(orig_mod["main"], inputs)
compile_and_run(
Copy link
Member

Choose a reason for hiding this comment

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

Should we not test that the internal functions only have 1 parameter each?

Copy link
Contributor Author

@ashutosh-arm ashutosh-arm Jun 16, 2022

Choose a reason for hiding this comment

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

I have added a check for this above in L182. Thanks @Mousius.

mod = relay.transform.InferType()(mod)
mod = ScalarToTensorConstants()(mod)
new_mod = relay.transform.InferType()(mod)
assert tvm.ir.structural_equal(mod[global_var].body, new_mod[global_var].body)
Copy link
Member

Choose a reason for hiding this comment

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

What is this checking? It appears to just check the body hasn't changed after InferType?

Copy link
Contributor Author

@ashutosh-arm ashutosh-arm Jun 16, 2022

Choose a reason for hiding this comment

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

Before this commit, it was producing a different body in the end due to an error in the code. Since the relay model in this test does not contain any scalar constants, expectation is that the pass should not affect the graph.

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 offline discussion it was decided to leave the check for structural equality in there.

@github-actions github-actions bot requested a review from areusch June 16, 2022 16:23
@ashutosh-arm
Copy link
Contributor Author

Thanks @Mousius for the discussions and code review. Would you like to take a look at it again?

@Mousius Mousius merged commit dffc310 into apache:main Jun 17, 2022
@Mousius
Copy link
Member

Mousius commented Jun 17, 2022

Thanks @ashutosh-arm 😸

@ashutosh-arm ashutosh-arm deleted the yolo_cmsisnn_1 branch July 4, 2022 15:30
blackkker pushed a commit to blackkker/tvm that referenced this pull request Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants