[WIP] OpenPulse dialect - #116
Conversation
alexarice
left a comment
There was a problem hiding this comment.
Very cool, I've left a few minor comments.
I understand this is a draft PR, but if you'd like to get things merged it would be great to split this into separate PRs, one which adds the dialect, and one which adds the transformation.
|
|
||
|
|
||
| @irdl_attr_definition | ||
| class DurationType(ParametrizedAttribute, TypeAttribute): |
There was a problem hiding this comment.
What's the motivation to have a different type for durations which you then cast to from int types, instead of just using index to begin with?
| # inspired by builtin's `index` | ||
| name = "pulse.duration" | ||
|
|
||
| # todo: make this parametric by underlying value type? |
There was a problem hiding this comment.
It's unlikely this needs to be parametric unless the openpulse durations are also parametric over their type.
| """ | ||
|
|
||
| name = "pulse.frame" | ||
| frame_name: builtin.StringAttr |
There was a problem hiding this comment.
| frame_name: builtin.StringAttr | |
| frame_name: StringAttr |
Nit: lets just import things directly?
There was a problem hiding this comment.
| frame_name: builtin.StringAttr | |
| frame_name: StringAttr = param_def(converter = StringAttr.get) |
Could even do this, which would generate an __init__ of which takes a StringAttr | str as a parameter.
| return cls(builtin.StringAttr(frame_name)) | ||
|
|
||
|
|
||
| FrameT = TypeVar("FrameT", bound=FrameType) |
| class AllocFrame(IRDLOperation): | ||
| name = "pulse.alloc_frame" | ||
| result = result_def(FrameType) | ||
| traits = traits_def() |
There was a problem hiding this comment.
There's no need to add an empty traits field.
This is a very rough and incomplete start at what could eventually be an OpenPulse dialect. Mostly I wrote this to improve my own understanding of xDSL, though I am opening a draft MR to share with others at the MLIR (Un)School.
OpenPulse introduces a few new types to OpenQASM
portframewaveformIn this PR I also add a
durationtype, though this might naturally get shared with an OpenQASM dialect.The OpenPulse spec allows for several operations which have an effect on frame state (phase, frequency, etc). For now I've only considered a hyper-minimalist subset with two timing related ops
delayon a framebarrieron some sequence of framesI sketched out an (incomplete) pass to do easy timing calculations on straight line programs and attach this information as attributes.
Design Notes
pulse.const_durationop since it seemed convenient to be able to have a canonical way to carry constant values here (rather than trying to work this out indirectly).