-
Notifications
You must be signed in to change notification settings - Fork 12
[tools][lh-transform] A cmd tool for applying schedules to payloads #67
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
Changes from all commits
f5a8cb5
2a7c604
d7ab981
2f92996
f9d0efc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| # See https://llvm.org/LICENSE.txt for license information. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| import argparse | ||
| import sys | ||
|
|
||
| from mlir import ir | ||
| from mlir.dialects import transform | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| arg_parser = argparse.ArgumentParser( | ||
| prog="lh-transform", description="Apply a schedule to a payload module" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could also add |
||
| ) | ||
| arg_parser.add_argument( | ||
| "schedule", help="path to file containing MLIR schedule module" | ||
| ) | ||
| arg_parser.add_argument( | ||
| "payload", help="path to file containing MLIR payload module" | ||
| ) | ||
| args = arg_parser.parse_args(sys.argv[1:]) | ||
|
|
||
| with ir.Context(), ir.Location.unknown(): | ||
| with open(args.schedule) as sched_file, open(args.payload) as payload_file: | ||
| schedule_module = ir.Module.parse(sched_file.read()) | ||
| payload_module = ir.Module.parse(payload_file.read()) | ||
|
|
||
| schedule = schedule_module.body.operations[0] | ||
| if not isinstance(schedule, transform.NamedSequenceOp): | ||
| sys.exit( | ||
|
Comment on lines
+31
to
+33
|
||
| "The following op was expected to be a `transform.named_sequence`, instead got:\n" | ||
| + str(schedule) | ||
| ) | ||
| schedule.apply(payload_module) | ||
|
|
||
| print(payload_module) | ||
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.
nit: header is skipped everywhere else