Closed ezw2 closed 3 years ago
For the tests, you need to do the following things
test_xxx
. Thus, you need to rename the functions if you want our tool to test it (or not test it). Our tool would ignore the __main__
function.test_
in order for it to be tested.hcl.print
is tested. Otherwise the passed tests do not mean anything.Forgot to mention one thing. For Python, we usually use 4 spaces for the indentation.
Ok should I fix the python indentations to make them all 4 spaces?
This PR introduces a new API hcl.assert_, which evaluates whether a condition is true or false in HeteroCL programs. The user has the option to provide a customized message as well as print out a value or array of values for debugging purposes. If the condition is true, the assert statement has no effect on the program, and if it is false, the rest of the program will not be executed and the error message will be printed out.
Examples for hcl.assert_
output:
1
output:
assert error, A[7]: 8 (should be 7) and A[1]: 2 (should be 1)
output:
The assert message and values to be printed are optional. As with hcl print: for integers, by default use "%d". For all other data types including floating points and fixed points, use "%f".