Skip to content

Accfg

accfg

ACCFG = Dialect('accfg', [AcceleratorOp, AwaitOp, LaunchOp, ResetOp, SetupOp], [EffectsAttr, StateType, TokenType]) module-attribute

EffectsEnum

Bases: Enum

Specify to explicitly say: * NONE: There are no accfg side-effects to this operation * FULL: There are accfg side-effects to this operation

Source code in xdsl/dialects/accfg.py
43
44
45
46
47
48
49
50
51
class EffectsEnum(Enum):
    """
    Specify to explicitly say:
    * NONE: There are no accfg side-effects to this operation
    * FULL: There are accfg side-effects to this operation
    """

    NONE = "none"
    FULL = "full"

NONE = 'none' class-attribute instance-attribute

FULL = 'full' class-attribute instance-attribute

EffectsAttr dataclass

Bases: Data[EffectsEnum]

An Attribute specifying if the marked operation has any effects on accelerator states.

Source code in xdsl/dialects/accfg.py
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
class EffectsAttr(Data[EffectsEnum]):
    """
    An Attribute specifying if the marked operation has any effects on accelerator states.
    """

    name = "accfg.effects"

    @classmethod
    def parse_parameter(cls, parser: AttrParser) -> EffectsEnum:
        with parser.in_angle_brackets():
            for field in EffectsEnum:
                if parser.parse_optional_keyword(field.value):
                    return field
            valid_vals = ", ".join(field.value for field in EffectsEnum)
            parser.raise_error(f"Unknown keyword, expected one of: {valid_vals}")

    def print_parameter(self, printer: Printer) -> None:
        with printer.in_angle_brackets():
            printer.print_string(self.data.value)

name = 'accfg.effects' class-attribute instance-attribute

parse_parameter(parser: AttrParser) -> EffectsEnum classmethod

Source code in xdsl/dialects/accfg.py
61
62
63
64
65
66
67
68
@classmethod
def parse_parameter(cls, parser: AttrParser) -> EffectsEnum:
    with parser.in_angle_brackets():
        for field in EffectsEnum:
            if parser.parse_optional_keyword(field.value):
                return field
        valid_vals = ", ".join(field.value for field in EffectsEnum)
        parser.raise_error(f"Unknown keyword, expected one of: {valid_vals}")

print_parameter(printer: Printer) -> None

Source code in xdsl/dialects/accfg.py
70
71
72
def print_parameter(self, printer: Printer) -> None:
    with printer.in_angle_brackets():
        printer.print_string(self.data.value)

TokenType

Bases: ParametrizedAttribute, TypeAttribute

Async token type for launched accelerator requests.

Source code in xdsl/dialects/accfg.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
@irdl_attr_definition
class TokenType(ParametrizedAttribute, TypeAttribute):
    """
    Async token type for launched accelerator requests.
    """

    name = "accfg.token"

    accelerator: StringAttr

    def __init__(self, accelerator: str | StringAttr):
        if not isinstance(accelerator, StringAttr):
            accelerator = StringAttr(accelerator)
        super().__init__(accelerator)

name = 'accfg.token' class-attribute instance-attribute

accelerator: StringAttr instance-attribute

__init__(accelerator: str | StringAttr)

Source code in xdsl/dialects/accfg.py
85
86
87
88
def __init__(self, accelerator: str | StringAttr):
    if not isinstance(accelerator, StringAttr):
        accelerator = StringAttr(accelerator)
    super().__init__(accelerator)

StateType

Bases: ParametrizedAttribute, TypeAttribute

Used to trace an accelerators CSR state through def-use chain

Source code in xdsl/dialects/accfg.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
@irdl_attr_definition
class StateType(ParametrizedAttribute, TypeAttribute):
    """
    Used to trace an accelerators CSR state through def-use chain
    """

    name = "accfg.state"

    accelerator: StringAttr

    def __init__(self, accelerator: str | StringAttr):
        if not isinstance(accelerator, StringAttr):
            accelerator = StringAttr(accelerator)
        return super().__init__(accelerator)

name = 'accfg.state' class-attribute instance-attribute

accelerator: StringAttr instance-attribute

__init__(accelerator: str | StringAttr)

Source code in xdsl/dialects/accfg.py
101
102
103
104
def __init__(self, accelerator: str | StringAttr):
    if not isinstance(accelerator, StringAttr):
        accelerator = StringAttr(accelerator)
    return super().__init__(accelerator)

LaunchOp

Bases: IRDLOperation

Launch an accelerator. This acts as a barrier for CSR values, meaning CSRs can be safely modified after a launch op without interfering with the Accelerator.

Source code in xdsl/dialects/accfg.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
@irdl_op_definition
class LaunchOp(IRDLOperation):
    """
    Launch an accelerator. This acts as a barrier for CSR values,
    meaning CSRs can be safely modified after a launch op without
    interfering with the Accelerator.
    """

    name = "accfg.launch"

    values = var_operand_def(Attribute)  # TODO: make more precise?
    """
    The actual values used to set up registers linked to launch
    """

    state = operand_def(StateType)

    param_names = prop_def(ArrayAttr[StringAttr])
    """
    Maps the SSA values in `values` to accelerator launch parameters
    """

    accelerator = prop_def(StringAttr)

    token = result_def()

    def __init__(
        self,
        vals: Sequence[SSAValue | Operation],
        param_names: Iterable[str] | Iterable[StringAttr],
        state: SSAValue | Operation,
    ):
        state_val = SSAValue.get(state, type=StateType)

        param_names_tuple: tuple[StringAttr, ...] = tuple(
            StringAttr(name) if isinstance(name, str) else name for name in param_names
        )
        super().__init__(
            operands=[vals, state],
            properties={
                "param_names": ArrayAttr(param_names_tuple),
                "accelerator": state_val.type.accelerator,
            },
            result_types=[TokenType(state_val.type.accelerator)],
        )

    def iter_params(self) -> Iterable[tuple[str, SSAValue]]:
        return zip((p.data for p in self.param_names), self.values)

    def verify_(self) -> None:
        # that the state and my accelerator match
        assert isinstance(self.state.type, StateType)
        if self.state.type.accelerator != self.accelerator:
            raise VerifyException(
                "The state's accelerator does not match the launch accelerator!"
            )
        # that the token and my accelerator match
        assert isinstance(self.token.type, TokenType)
        if self.token.type.accelerator != self.accelerator:
            raise VerifyException(
                "The token's accelerator does not match the launch accelerator!"
            )

        # that the token is used
        if not isinstance(self.token.get_user_of_unique_use(), AwaitOp):
            raise VerifyException("Launch token must be used by exactly one await op")

        # that len(values) == len(param_names)
        if len(self.values) != len(self.param_names):
            raise ValueError(
                "Must have received same number of values as parameter names"
            )

name = 'accfg.launch' class-attribute instance-attribute

values = var_operand_def(Attribute) class-attribute instance-attribute

The actual values used to set up registers linked to launch

state = operand_def(StateType) class-attribute instance-attribute

param_names = prop_def(ArrayAttr[StringAttr]) class-attribute instance-attribute

Maps the SSA values in values to accelerator launch parameters

accelerator = prop_def(StringAttr) class-attribute instance-attribute

token = result_def() class-attribute instance-attribute

__init__(vals: Sequence[SSAValue | Operation], param_names: Iterable[str] | Iterable[StringAttr], state: SSAValue | Operation)

Source code in xdsl/dialects/accfg.py
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
def __init__(
    self,
    vals: Sequence[SSAValue | Operation],
    param_names: Iterable[str] | Iterable[StringAttr],
    state: SSAValue | Operation,
):
    state_val = SSAValue.get(state, type=StateType)

    param_names_tuple: tuple[StringAttr, ...] = tuple(
        StringAttr(name) if isinstance(name, str) else name for name in param_names
    )
    super().__init__(
        operands=[vals, state],
        properties={
            "param_names": ArrayAttr(param_names_tuple),
            "accelerator": state_val.type.accelerator,
        },
        result_types=[TokenType(state_val.type.accelerator)],
    )

iter_params() -> Iterable[tuple[str, SSAValue]]

Source code in xdsl/dialects/accfg.py
153
154
def iter_params(self) -> Iterable[tuple[str, SSAValue]]:
    return zip((p.data for p in self.param_names), self.values)

verify_() -> None

Source code in xdsl/dialects/accfg.py
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
def verify_(self) -> None:
    # that the state and my accelerator match
    assert isinstance(self.state.type, StateType)
    if self.state.type.accelerator != self.accelerator:
        raise VerifyException(
            "The state's accelerator does not match the launch accelerator!"
        )
    # that the token and my accelerator match
    assert isinstance(self.token.type, TokenType)
    if self.token.type.accelerator != self.accelerator:
        raise VerifyException(
            "The token's accelerator does not match the launch accelerator!"
        )

    # that the token is used
    if not isinstance(self.token.get_user_of_unique_use(), AwaitOp):
        raise VerifyException("Launch token must be used by exactly one await op")

    # that len(values) == len(param_names)
    if len(self.values) != len(self.param_names):
        raise ValueError(
            "Must have received same number of values as parameter names"
        )

AwaitOp

Bases: IRDLOperation

Blocks until the launched operation finishes.

Source code in xdsl/dialects/accfg.py
182
183
184
185
186
187
188
189
190
191
192
193
@irdl_op_definition
class AwaitOp(IRDLOperation):
    """
    Blocks until the launched operation finishes.
    """

    name = "accfg.await"

    token = operand_def(TokenType)

    def __init__(self, token: SSAValue | Operation):
        super().__init__(operands=[token])

name = 'accfg.await' class-attribute instance-attribute

token = operand_def(TokenType) class-attribute instance-attribute

__init__(token: SSAValue | Operation)

Source code in xdsl/dialects/accfg.py
192
193
def __init__(self, token: SSAValue | Operation):
    super().__init__(operands=[token])

SetupOp

Bases: IRDLOperation

accfg.setup writes values to a specific accelerators configuration and returns a value representing the currently known state of that accelerator's config.

If accfg.setup is called without any parameters, the resulting state is the "empty" state, that represents a state without known values.

Source code in xdsl/dialects/accfg.py
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
@irdl_op_definition
class SetupOp(IRDLOperation):
    """
    accfg.setup writes values to a specific accelerators configuration and returns
    a value representing the currently known state of that accelerator's config.

    If accfg.setup is called without any parameters, the resulting state is the
    "empty" state, that represents a state without known values.
    """

    name = "accfg.setup"

    values = var_operand_def(Attribute)  # TODO: make more precise?
    """
    The actual values used to set up the CSRs
    """

    in_state = opt_operand_def(StateType)
    """
    The state produced by a previous accfg.setup
    """

    out_state = result_def(StateType)
    """
    The CSR state after the setup op modified it.
    """

    param_names = prop_def(ArrayAttr[StringAttr])
    """
    Maps the SSA values in `values` to accelerator parameter names
    """

    accelerator = prop_def(StringAttr)
    """
    Name of the accelerator this setup is for
    """

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

    def __init__(
        self,
        vals: Sequence[SSAValue | Operation],
        param_names: Sequence[str] | Sequence[StringAttr],
        accelerator: str | StringAttr,
        in_state: SSAValue | Operation | None = None,
    ):
        if not isinstance(accelerator, StringAttr):
            accelerator = StringAttr(accelerator)

        param_names_tuple: tuple[StringAttr, ...] = tuple(
            StringAttr(name) if isinstance(name, str) else name for name in param_names
        )

        super().__init__(
            operands=[vals, in_state],
            properties={
                "param_names": ArrayAttr(param_names_tuple),
                "accelerator": accelerator,
            },
            result_types=[StateType(accelerator)],
        )

    def iter_params(self) -> Iterable[tuple[str, SSAValue]]:
        return zip((p.data for p in self.param_names), self.values)

    def verify_(self) -> None:
        # that accelerator on input matches output
        if self.in_state is not None:
            if self.in_state.type != self.out_state.type:
                raise VerifyException("Input and output state accelerators must match")
        assert isinstance(self.out_state.type, StateType)
        if self.accelerator != self.out_state.type.accelerator:
            raise VerifyException(
                "Output state accelerator and accelerator the "
                "operations property must match"
            )

        # that len(values) == len(param_names)
        if len(self.values) != len(self.param_names):
            raise ValueError(
                "Must have received same number of values as parameter names"
            )

    def print(self, printer: Printer):
        printer.print_string(" ")
        printer.print_string_literal(self.accelerator.data)

        if self.in_state:
            printer.print_string(" from ")
            printer.print_ssa_value(self.in_state)

        printer.print_string(" to (")

        for i, (name, val) in enumerate(zip(self.param_names, self.values)):
            printer.print_string_literal(name.data)
            printer.print_string(" = ")
            printer.print_ssa_value(val)
            printer.print_string(" : ")
            printer.print_attribute(val.type)
            # for all but the last value print separator
            if i != len(self.values) - 1:
                printer.print_string(", ")
        printer.print_string(") ")

        if self.attributes:
            printer.print_string("attrs ")
            printer.print_attr_dict(self.attributes)
            printer.print_string(" ")

        printer.print_string(": ")
        printer.print_attribute(self.out_state.type)

    @classmethod
    def parse(cls: type[SetupOp], parser: Parser) -> SetupOp:
        accelerator = parser.parse_str_literal("accelerator name")

        in_state: SSAValue | None = None
        if parser.parse_optional_keyword("from"):
            in_state = parser.parse_operand()

        parser.parse_keyword("to")

        def parse_itm() -> tuple[str, SSAValue]:
            name = parser.parse_str_literal("accelerator field name")
            parser.parse_punctuation("=")
            val = parser.parse_operand(f'expected value for field "{name}"')
            parser.parse_punctuation(":")
            typ = parser.parse_type()
            assert val.type == typ, (
                f"ssa value type mismatch! Expected {typ}, got {val.type}"
            )
            return name, val

        args: Sequence[tuple[str, SSAValue]] = parser.parse_comma_separated_list(
            Parser.Delimiter.PAREN, parse_itm
        )

        attributes = {}
        if parser.parse_optional_keyword("attrs"):
            attributes = parser.parse_optional_attr_dict()

        parser.parse_punctuation(":")
        pos = parser.pos
        res_typ = parser.parse_type()
        if res_typ != StateType(accelerator):
            parser.raise_error(
                f"expected {StateType(accelerator)}, but got {res_typ}", pos
            )

        setup_op = cls(
            [val for _, val in args],
            [name for name, _ in args],
            accelerator,
            in_state,
        )
        setup_op.attributes.update(attributes)
        return setup_op

name = 'accfg.setup' class-attribute instance-attribute

values = var_operand_def(Attribute) class-attribute instance-attribute

The actual values used to set up the CSRs

in_state = opt_operand_def(StateType) class-attribute instance-attribute

The state produced by a previous accfg.setup

out_state = result_def(StateType) class-attribute instance-attribute

The CSR state after the setup op modified it.

param_names = prop_def(ArrayAttr[StringAttr]) class-attribute instance-attribute

Maps the SSA values in values to accelerator parameter names

accelerator = prop_def(StringAttr) class-attribute instance-attribute

Name of the accelerator this setup is for

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

__init__(vals: Sequence[SSAValue | Operation], param_names: Sequence[str] | Sequence[StringAttr], accelerator: str | StringAttr, in_state: SSAValue | Operation | None = None)

Source code in xdsl/dialects/accfg.py
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
def __init__(
    self,
    vals: Sequence[SSAValue | Operation],
    param_names: Sequence[str] | Sequence[StringAttr],
    accelerator: str | StringAttr,
    in_state: SSAValue | Operation | None = None,
):
    if not isinstance(accelerator, StringAttr):
        accelerator = StringAttr(accelerator)

    param_names_tuple: tuple[StringAttr, ...] = tuple(
        StringAttr(name) if isinstance(name, str) else name for name in param_names
    )

    super().__init__(
        operands=[vals, in_state],
        properties={
            "param_names": ArrayAttr(param_names_tuple),
            "accelerator": accelerator,
        },
        result_types=[StateType(accelerator)],
    )

iter_params() -> Iterable[tuple[str, SSAValue]]

Source code in xdsl/dialects/accfg.py
258
259
def iter_params(self) -> Iterable[tuple[str, SSAValue]]:
    return zip((p.data for p in self.param_names), self.values)

verify_() -> None

Source code in xdsl/dialects/accfg.py
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
def verify_(self) -> None:
    # that accelerator on input matches output
    if self.in_state is not None:
        if self.in_state.type != self.out_state.type:
            raise VerifyException("Input and output state accelerators must match")
    assert isinstance(self.out_state.type, StateType)
    if self.accelerator != self.out_state.type.accelerator:
        raise VerifyException(
            "Output state accelerator and accelerator the "
            "operations property must match"
        )

    # that len(values) == len(param_names)
    if len(self.values) != len(self.param_names):
        raise ValueError(
            "Must have received same number of values as parameter names"
        )

print(printer: Printer)

Source code in xdsl/dialects/accfg.py
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
def print(self, printer: Printer):
    printer.print_string(" ")
    printer.print_string_literal(self.accelerator.data)

    if self.in_state:
        printer.print_string(" from ")
        printer.print_ssa_value(self.in_state)

    printer.print_string(" to (")

    for i, (name, val) in enumerate(zip(self.param_names, self.values)):
        printer.print_string_literal(name.data)
        printer.print_string(" = ")
        printer.print_ssa_value(val)
        printer.print_string(" : ")
        printer.print_attribute(val.type)
        # for all but the last value print separator
        if i != len(self.values) - 1:
            printer.print_string(", ")
    printer.print_string(") ")

    if self.attributes:
        printer.print_string("attrs ")
        printer.print_attr_dict(self.attributes)
        printer.print_string(" ")

    printer.print_string(": ")
    printer.print_attribute(self.out_state.type)

parse(parser: Parser) -> SetupOp classmethod

Source code in xdsl/dialects/accfg.py
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
@classmethod
def parse(cls: type[SetupOp], parser: Parser) -> SetupOp:
    accelerator = parser.parse_str_literal("accelerator name")

    in_state: SSAValue | None = None
    if parser.parse_optional_keyword("from"):
        in_state = parser.parse_operand()

    parser.parse_keyword("to")

    def parse_itm() -> tuple[str, SSAValue]:
        name = parser.parse_str_literal("accelerator field name")
        parser.parse_punctuation("=")
        val = parser.parse_operand(f'expected value for field "{name}"')
        parser.parse_punctuation(":")
        typ = parser.parse_type()
        assert val.type == typ, (
            f"ssa value type mismatch! Expected {typ}, got {val.type}"
        )
        return name, val

    args: Sequence[tuple[str, SSAValue]] = parser.parse_comma_separated_list(
        Parser.Delimiter.PAREN, parse_itm
    )

    attributes = {}
    if parser.parse_optional_keyword("attrs"):
        attributes = parser.parse_optional_attr_dict()

    parser.parse_punctuation(":")
    pos = parser.pos
    res_typ = parser.parse_type()
    if res_typ != StateType(accelerator):
        parser.raise_error(
            f"expected {StateType(accelerator)}, but got {res_typ}", pos
        )

    setup_op = cls(
        [val for _, val in args],
        [name for name, _ in args],
        accelerator,
        in_state,
    )
    setup_op.attributes.update(attributes)
    return setup_op

AcceleratorSymbolOpTrait dataclass

Bases: SymbolOpInterface

Source code in xdsl/dialects/accfg.py
355
356
357
358
class AcceleratorSymbolOpTrait(SymbolOpInterface):
    def get_sym_attr_name(self, op: Operation) -> StringAttr | None:
        assert isinstance(op, AcceleratorOp)
        return StringAttr(op.name_prop.string_value())

get_sym_attr_name(op: Operation) -> StringAttr | None

Source code in xdsl/dialects/accfg.py
356
357
358
def get_sym_attr_name(self, op: Operation) -> StringAttr | None:
    assert isinstance(op, AcceleratorOp)
    return StringAttr(op.name_prop.string_value())

AcceleratorOp

Bases: IRDLOperation

Declares an accelerator that can be configured, launched, etc. fields is a dictionary mapping accelerator configuration names to CSR addresses.

Source code in xdsl/dialects/accfg.py
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
@irdl_op_definition
class AcceleratorOp(IRDLOperation):
    """
    Declares an accelerator that can be configured, launched, etc.
    `fields` is a dictionary mapping accelerator configuration names to
    CSR addresses.
    """

    name = "accfg.accelerator"

    traits = traits_def(AcceleratorSymbolOpTrait())

    name_prop = prop_def(SymbolRefAttr, prop_name="name")

    fields = prop_def(DictionaryAttr)

    launch_fields = prop_def(DictionaryAttr)

    barrier = prop_def(
        IntegerAttr[IntegerType]
    )  # TODO: this will be reworked in a later version

    def __init__(
        self,
        name: str | StringAttr | SymbolRefAttr,
        fields: dict[str, int] | DictionaryAttr,
        launch_fields: dict[str, int] | DictionaryAttr,
        barrier: int | IntegerAttr[IntegerType],
    ):
        if not isinstance(fields, DictionaryAttr):
            fields = DictionaryAttr(
                {name: IntegerAttr(val, i32) for name, val in fields.items()}
            )

        if not isinstance(launch_fields, DictionaryAttr):
            launch_fields = DictionaryAttr(
                {name: IntegerAttr(val, i32) for name, val in launch_fields.items()}
            )

        super().__init__(
            properties={
                "name": (
                    SymbolRefAttr(name) if not isinstance(name, SymbolRefAttr) else name
                ),
                "fields": fields,
                "launch_fields": launch_fields,
                "barrier": (
                    IntegerAttr(barrier, i32)
                    if not isinstance(barrier, IntegerAttr)
                    else barrier
                ),
            }
        )

    def verify_(self) -> None:
        for _, val in self.fields.data.items():
            if not isinstance(val, IntegerAttr):
                raise VerifyException("fields must only contain IntegerAttr!")

    def field_names(self) -> tuple[str, ...]:
        return tuple(self.fields.data.keys())

    def field_items(self) -> Iterable[tuple[str, IntegerAttr]]:
        for name, val in self.fields.data.items():
            yield name, cast(IntegerAttr, val)

    def launch_field_names(self) -> tuple[str, ...]:
        return tuple(self.launch_fields.data.keys())

    def launch_field_items(self) -> Iterable[tuple[str, IntegerAttr]]:
        for name, val in self.launch_fields.data.items():
            yield name, cast(IntegerAttr, val)

name = 'accfg.accelerator' class-attribute instance-attribute

traits = traits_def(AcceleratorSymbolOpTrait()) class-attribute instance-attribute

name_prop = prop_def(SymbolRefAttr, prop_name='name') class-attribute instance-attribute

fields = prop_def(DictionaryAttr) class-attribute instance-attribute

launch_fields = prop_def(DictionaryAttr) class-attribute instance-attribute

barrier = prop_def(IntegerAttr[IntegerType]) class-attribute instance-attribute

__init__(name: str | StringAttr | SymbolRefAttr, fields: dict[str, int] | DictionaryAttr, launch_fields: dict[str, int] | DictionaryAttr, barrier: int | IntegerAttr[IntegerType])

Source code in xdsl/dialects/accfg.py
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
def __init__(
    self,
    name: str | StringAttr | SymbolRefAttr,
    fields: dict[str, int] | DictionaryAttr,
    launch_fields: dict[str, int] | DictionaryAttr,
    barrier: int | IntegerAttr[IntegerType],
):
    if not isinstance(fields, DictionaryAttr):
        fields = DictionaryAttr(
            {name: IntegerAttr(val, i32) for name, val in fields.items()}
        )

    if not isinstance(launch_fields, DictionaryAttr):
        launch_fields = DictionaryAttr(
            {name: IntegerAttr(val, i32) for name, val in launch_fields.items()}
        )

    super().__init__(
        properties={
            "name": (
                SymbolRefAttr(name) if not isinstance(name, SymbolRefAttr) else name
            ),
            "fields": fields,
            "launch_fields": launch_fields,
            "barrier": (
                IntegerAttr(barrier, i32)
                if not isinstance(barrier, IntegerAttr)
                else barrier
            ),
        }
    )

verify_() -> None

Source code in xdsl/dialects/accfg.py
415
416
417
418
def verify_(self) -> None:
    for _, val in self.fields.data.items():
        if not isinstance(val, IntegerAttr):
            raise VerifyException("fields must only contain IntegerAttr!")

field_names() -> tuple[str, ...]

Source code in xdsl/dialects/accfg.py
420
421
def field_names(self) -> tuple[str, ...]:
    return tuple(self.fields.data.keys())

field_items() -> Iterable[tuple[str, IntegerAttr]]

Source code in xdsl/dialects/accfg.py
423
424
425
def field_items(self) -> Iterable[tuple[str, IntegerAttr]]:
    for name, val in self.fields.data.items():
        yield name, cast(IntegerAttr, val)

launch_field_names() -> tuple[str, ...]

Source code in xdsl/dialects/accfg.py
427
428
def launch_field_names(self) -> tuple[str, ...]:
    return tuple(self.launch_fields.data.keys())

launch_field_items() -> Iterable[tuple[str, IntegerAttr]]

Source code in xdsl/dialects/accfg.py
430
431
432
def launch_field_items(self) -> Iterable[tuple[str, IntegerAttr]]:
    for name, val in self.launch_fields.data.items():
        yield name, cast(IntegerAttr, val)

ResetOp

Bases: IRDLOperation

Source code in xdsl/dialects/accfg.py
435
436
437
438
439
440
441
442
443
444
@irdl_op_definition
class ResetOp(IRDLOperation):
    name = "accfg.reset"

    in_state = operand_def(StateType)

    assembly_format = "$in_state attr-dict `:` type($in_state)"

    def __init__(self, in_state: Operation | SSAValue):
        super().__init__(operands=[in_state])

name = 'accfg.reset' class-attribute instance-attribute

in_state = operand_def(StateType) class-attribute instance-attribute

assembly_format = '$in_state attr-dict `:` type($in_state)' class-attribute instance-attribute

__init__(in_state: Operation | SSAValue)

Source code in xdsl/dialects/accfg.py
443
444
def __init__(self, in_state: Operation | SSAValue):
    super().__init__(operands=[in_state])