-
Notifications
You must be signed in to change notification settings - Fork 32
[DeeployTest] Change order of typeMatching entries #68
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
Conversation
|
After some investigation, I discovered that the following check fails: def typeCheckNodeInputs(self, ctxt: NetworkContext, node: gs.Node) -> bool:
"""DONT OVERRIDE - Type checks all input nodes to confirm they either already are assigned the correct type or their type can be statically upcast to the rule's input types
Parameters
----------
ctxt : NetworkContext
Current NetworkContext
node : gs.Node
Node whose inputs should be analyzes
Returns
-------
bool
Whether the input's types match the rule's requirements
"""
retCheck = True
for inputNode, _type in zip(node.inputs, self.input_types):
reference = ctxt.lookup(inputNode.name)
if not isinstance(reference, VariableBuffer):
return False
if hasattr(reference, "values"):
retCheck &= _type.referencedType.checkPromotion(reference.values)
else:
if ctxt.is_global(inputNode.name):
retCheck &= _type.referencedType.partialOrderUpcast(reference._type.referencedType)
if retCheck:
reference._type = _type
reference._instance = _type(inputNode.name, ctxt)
else:
retCheck &= reference._type.referencedType == _type.referencedType
return retCheckSpecifically, in this line: retCheck &= reference._type.referencedType == _type.referencedType, as |
d72dcd0 to
79f647a
Compare
|
I fixed the failing test by generating input data for the Warning: This is a lazy fix, however, could potentially lead to problems later. This is because the type inference inherently assumes some sort of type matching order. Happy to discuss how to tackle this issue (potentially introducing some flags as hints for the compiler), but I think for now it's okay. |
|
Does it make more sense to infer an unsigned first instead of a signed? There is no "good answer" if the input sample is biased (fundamentally, both answers are correct). Can you add an interface for the user to bypass the auto-inference system? |
Our assumption is that we can infer the minimum required type based on the input sample. For the bitwidth, this is obvious, and I argue it is more logical to infer an unsigned datatype if there are no negative numbers in the inputs. In summary, I agree with Vivi's changes, but I am also in favor of adding a flag to bypass the auto-inference. |
Okay I see the point of putting unsigned type first in the matching list. Let's get this flag setup and this PR rolling then @viv-eth 😁 |
|
@viv-eth Any plans to work on this in the next 2 weeks? Alternatively, I can offer to take it over, but will most likely include it in the next release. |
d482be0 to
691e45d
Compare
Xeratec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing the suggested changes. Please rebase the PR and address the remaining small comments and make sure all tests pass. Let me know if I should take over.
343700f to
cc8f8ec
Compare
Xeratec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes were added under v0.2.0 in the Changelog and not under v0.2.1. I will change it, rebase it after merging #93, and merge it once the tests succeed. Thanks for your effort!
- Add GitHub tests - Remove outdated GitLab CI file - Add support for `--shouldFail` for network generation
56b7a31 to
214f8da
Compare
Xeratec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lukamac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the comments on the code, I have a question regarding the change of the Adder test. I saw in the beginning of the PR conversation that the change of the Adder test was a kind of stop-gap solution. Is it still necessary to change it? If not, I would revert it.
Also, I would mention in the changelog the new testTypeInferenceDifferentTypes and the deletion of the .gitlab-ci.yml.
I’ve implemented all the requested changes, except for reverting the |
abdfaba to
96febcf
Compare
96febcf to
4b5b792
Compare
Thanks for the effort :) I'm thinking that it might make more sense to rename the current |
cd6b4b0 to
37d4ca2
Compare
As discussed offline, we will keep the new test, which tests a signed addition. |
lukamac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
* [DeeployTest] Change order of typeMatching entries * [Tests] Add negative values to correctly match type * [ci] Add tests for manual type inference * [DeeployTest] Add manual type inference feature * [CHANGELOG] Update with manual type inference feature * [DeeployTest] Align command line args with network generator * [CHANGELOG] Add PR to list of PRs * [DeeployTest] Remove non-ASCII chars * [DeeployTest] Move to Numpy-style docs * [DeeployTest] Fix input/output indexing error by zipping input names and arrays * Fix CI Tests - Add GitHub tests - Remove outdated GitLab CI file - Add support for `--shouldFail` for network generation * Fix Changelog * Improve debugging and implement CodeRabbit suggestions * Implement PR feedback for Luka * Fix CI --------- Co-authored-by: viv-eth <[email protected]> Co-authored-by: Philip Wiese <[email protected]>
* [DeeployTest] Change order of typeMatching entries * [Tests] Add negative values to correctly match type * [ci] Add tests for manual type inference * [DeeployTest] Add manual type inference feature * [CHANGELOG] Update with manual type inference feature * [DeeployTest] Align command line args with network generator * [CHANGELOG] Add PR to list of PRs * [DeeployTest] Remove non-ASCII chars * [DeeployTest] Move to Numpy-style docs * [DeeployTest] Fix input/output indexing error by zipping input names and arrays * Fix CI Tests - Add GitHub tests - Remove outdated GitLab CI file - Add support for `--shouldFail` for network generation * Fix Changelog * Improve debugging and implement CodeRabbit suggestions * Implement PR feedback for Luka * Fix CI --------- Co-authored-by: viv-eth <[email protected]> Co-authored-by: Philip Wiese <[email protected]>
This PR fixes a minor issue when inferring the input type. If the data range fits both the unsigned and signed version of a certain data type, it will pick first the signed version due to the current sorting mechanism. This is changed to prefer unsigned over signed datatypes.
Added
sorted_typeslist in the integer branch to capture integer types ordered by (typeWidth,isSigned).Changed
sorted(IntegerDataTypes, key=lambda x: x.typeWidth)loop with:Fixed
PR Merge Checklist
develcommit and pointing todevel.CHANGELOG.mdfile has been updated.