-
Notifications
You must be signed in to change notification settings - Fork 54
add more wasm examples and clean up checks #1070
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
648f341 to
fde2418
Compare
fde2418 to
f5e8653
Compare
pytket/pytket/utils/operators.py
Outdated
|
|
||
| def get(self, key: QubitPauliString, default: CoeffType) -> CoeffType: | ||
| return self._dict.get(key, default) | ||
| return self._dict.get(key, default) # type: ignore |
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.
Hmm, not sure why this wasn't needed before. Maybe a mypy update.
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.
Not yet sure if this solves the issue, I had not shown this locally.
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.
Sorry to be pedantic but could you change "unvalid" to "invalid" everywhere?
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.
No problem, done in baef46c
| Ways to compile wasm from C/C++ are: | ||
|
|
||
| ``` | ||
| emcc <filename>.c -o <filename>.html |
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.
Does this produce html? How do you get the wasm from that?
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.
This produces an html file and a wasm file, I have not found a way to use emcc to generate only the wasm file without the html if the file that is compiled contains additional libraries. I just deleted the html files after compiling.
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.
OK
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.
( I have pointed this out in the readme, see b07edfa )
.gitignore
Outdated
| pytket/tests/qasm_test_files/testout4.qasm | ||
| pytket/tests/qasm_test_files/testout5.qasm | ||
| pytket/tests/qasm_test_files/testout6.qasm | ||
| secret-file.wasm |
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.
Where does this come from?
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.
I have some additional tests locally with files that should not be uploaded. I wanted to add this to make sure the file does not get added accidentally.
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.
You can add it to .git/info/exclude locally instead of here.
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.
I have clean up this up in 0c6137a
pytket/pytket/wasm/wasm.py
Outdated
| if not supported_function: | ||
| self._unsupported_function.append(x) | ||
|
|
||
| except: |
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.
I'm wary of catching all errors, at least if we swallow up the error content like this -- it can easily mask bugs. Why don't we define a custom error type that we can throw from specific places in this code? Are there particular cases you're aware of where the checker fails but the code runs? Ideally this would not be the case but if there are I think it would be better to single them out rather than treat all errors this way.
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 general idea if this was to avoid cryptic error messages when paring wasm files that are broken. I wanted to point out to the user that something has gone wrong and explain what the causes might have been. I am not aware of wasm files that can break the parsing and still can be run. I have removed this now.
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.
Removed in 71697f1
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.
This file probably shouldn't be here, as there is README.md?
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.
Yes, remove the file in b9674e2
| ``` | ||
|
|
||
| ``` | ||
| clang --target=wasm32 -mmultivalue -Xclang -target-abi -Xclang experimental-mv --no-standard-libraries -Wl,--export-all -Wl,--no-entry -o <filename>.wasm <filename>.c |
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.
Any reason not to always run this command, i.e. do we need to also give the version without multivalue support?
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.
This command is not working with older clang versions, I thought it might be nice to have both. If you thing we should remove this, I am happy to do that.
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.
Don't mind having both but should explain what the difference is and when one needs to use the latter.
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.
I have added some details to the readme in b07edfa
No description provided.