-
Notifications
You must be signed in to change notification settings - Fork 88
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
python: add 'make generate' OS agnostic #2288
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2288 +/- ##
===========================================
- Coverage 91.45% 91.45% -0.01%
===========================================
Files 433 433
Lines 16175 16174 -1
===========================================
- Hits 14793 14792 -1
Misses 1382 1382
|
tools/CMakeLists.txt
Outdated
string(MAKE_C_IDENTIFIER ${__rel_name} __cid) | ||
add_custom_target(generate_${__cid} DEPENDS ${__output_native_path}) | ||
add_dependencies(generate generate_${__cid}) | ||
endfunction() |
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.
Can this be written using python instead of cmake? Python is much easier to read. I would like a generate.py script to do the same thing as the generate.sh script.
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.
In PR #1893, you asked us to do a Python or CMake script instead of a batch script. We chose CMake because it is more accessible on Windows regarding build configuration and has all the infrastructure for searching for external tools.
This build is not recommended to merge 🔴 |
🔴bert_base_cased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output🔴bert_large_uncased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output🔴distilgpt2_fp16: FAILED: MIGraphX is not within tolerance - check verbose output |
3674d8f
to
68f800a
Compare
4cb5d9a
to
721a0c5
Compare
721a0c5
to
e63dc69
Compare
tools/generate.py
Outdated
|
||
def api_generate(input_path: Path, output_path: Path): | ||
with open(output_path, 'w') as f: | ||
f.write(clang_format(api.invoke(input_path))) |
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.
Just call the run
function directly: f.write(clang_format(api.invoke([migraphx_py_path, input_path])))
then there is no need to call register_functions
.
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 tried that. It fails with an exception after the second call to the original run()
, saying "update() not being called". The second call to run()
doubles the functions already in the functions
list, and @once
attached to process_functions()
prevents them from being updated. When I removed the decorator/reset the had_run
flag, I ended up doubling everything: functions, parameters, structures, etc., in the resulting files. So, either I register functions once or drop everything after each call to api.invoke()
. I decided to register functions once.
tools/api.py
Outdated
@@ -678,6 +679,10 @@ def add_function(name: str, *args, **kwargs) -> Function: | |||
return f | |||
|
|||
|
|||
def register_functions(path: Union[Path, str]) -> None: |
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 doesnt need to be moved out into a separate function.
tools/te.py
Outdated
f = open(sys.argv[1]).read() | ||
r = template_eval(f) | ||
sys.stdout.write(r) | ||
def invoke(p): |
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.
Call this run
instead of invoke
.
The Python version of 'make generate' for Linux and Windows.