|
| 1 | +module triton_ext |
| 2 | +using ...IR |
| 3 | +import ...IR: |
| 4 | + NamedAttribute, |
| 5 | + Value, |
| 6 | + Location, |
| 7 | + Block, |
| 8 | + Region, |
| 9 | + Attribute, |
| 10 | + create_operation, |
| 11 | + context, |
| 12 | + IndexType |
| 13 | +import ..Dialects: namedattribute, operandsegmentsizes |
| 14 | +import ...API |
| 15 | + |
| 16 | +function call( |
| 17 | + gridx::Value, |
| 18 | + gridy::Value, |
| 19 | + gridz::Value, |
| 20 | + shmem::Value, |
| 21 | + inputs::Vector{Value}; |
| 22 | + result_0::Vector{IR.Type}, |
| 23 | + fn, |
| 24 | + backend_config=nothing, |
| 25 | + operand_layouts=nothing, |
| 26 | + result_layouts=nothing, |
| 27 | + arg_attrs=nothing, |
| 28 | + res_attrs=nothing, |
| 29 | + output_operand_aliases=nothing, |
| 30 | + xla_side_effect_free=nothing, |
| 31 | + location=Location(), |
| 32 | +) |
| 33 | + op_ty_results = IR.Type[result_0...,] |
| 34 | + operands = Value[gridx, gridy, gridz, shmem, inputs...] |
| 35 | + owned_regions = Region[] |
| 36 | + successors = Block[] |
| 37 | + attributes = NamedAttribute[namedattribute("fn", fn),] |
| 38 | + !isnothing(backend_config) && |
| 39 | + push!(attributes, namedattribute("backend_config", backend_config)) |
| 40 | + !isnothing(operand_layouts) && |
| 41 | + push!(attributes, namedattribute("operand_layouts", operand_layouts)) |
| 42 | + !isnothing(result_layouts) && |
| 43 | + push!(attributes, namedattribute("result_layouts", result_layouts)) |
| 44 | + !isnothing(arg_attrs) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) |
| 45 | + !isnothing(res_attrs) && push!(attributes, namedattribute("res_attrs", res_attrs)) |
| 46 | + !isnothing(output_operand_aliases) && |
| 47 | + push!(attributes, namedattribute("output_operand_aliases", output_operand_aliases)) |
| 48 | + !isnothing(xla_side_effect_free) && |
| 49 | + push!(attributes, namedattribute("xla_side_effect_free", xla_side_effect_free)) |
| 50 | + |
| 51 | + return create_operation( |
| 52 | + "triton_ext.call", |
| 53 | + location; |
| 54 | + operands, |
| 55 | + owned_regions, |
| 56 | + successors, |
| 57 | + attributes, |
| 58 | + results=op_ty_results, |
| 59 | + result_inference=false, |
| 60 | + ) |
| 61 | +end |
| 62 | + |
| 63 | +function module_(; sym_name, bodyRegion::Region, location=Location()) |
| 64 | + op_ty_results = IR.Type[] |
| 65 | + operands = Value[] |
| 66 | + owned_regions = Region[bodyRegion,] |
| 67 | + successors = Block[] |
| 68 | + attributes = NamedAttribute[namedattribute("sym_name", sym_name),] |
| 69 | + |
| 70 | + return create_operation( |
| 71 | + "triton_ext.module", |
| 72 | + location; |
| 73 | + operands, |
| 74 | + owned_regions, |
| 75 | + successors, |
| 76 | + attributes, |
| 77 | + results=op_ty_results, |
| 78 | + result_inference=false, |
| 79 | + ) |
| 80 | +end |
| 81 | + |
| 82 | +end # triton_ext |
0 commit comments