Skip to content

Commit 6a550d0

Browse files
Pangorawmofeing
andauthored
complex DenseElementsAttribute (#195)
* complex DenseElementsAttribute * Update src/mlir/IR/Type.jl Co-authored-by: Sergio Sánchez Ramírez <[email protected]> --------- Co-authored-by: Sergio Sánchez Ramírez <[email protected]>
1 parent 35a51ad commit 6a550d0

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/mlir/IR/Attribute.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,14 @@ function DenseElementsAttribute(values::AbstractArray{Float16})
564564
)
565565
end
566566

567+
function DenseElementsAttribute(values::AbstractArray{<:Complex})
568+
shaped_type = TensorType(size(values), Type(eltype(values)))
569+
# TODO: row major
570+
Attribute(
571+
API.mlirDenseElementsAttrRawBufferGet(shaped_type, length(values) * sizeof(eltype(values)), values)
572+
)
573+
end
574+
567575
"""
568576
DenseElementsAttribute(array::AbstractArray{String})
569577

src/mlir/IR/Type.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ Creates a signless integer type of the given bitwidth in the context. The type i
8585
Type(T::Core.Type{<:Integer}; context::Context=context()) =
8686
Type(API.mlirIntegerTypeGet(context, sizeof(T) * 8))
8787

88+
"""
89+
Type(T::Core.Type{<:Complex}; context=context())
90+
91+
Creates a complex type with the given element type.
92+
"""
93+
Type(::Core.Type{Complex{T}}; context=context()) where {T} = Type(API.mlirComplexTypeGet(Type(T)))
94+
8895
"""
8996
Type(T::Core.Type{<:Signed}; context=context()
9097

0 commit comments

Comments
 (0)