Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
glou-nes committed Feb 5, 2025
1 parent 3c60425 commit 8186305
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/mlir/IR/Attribute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Returns an empty attribute.
"""
Attribute() = Attribute(API.mlirAttributeGetNull())

Base.convert(::Core.Type{API.MlirAttribute}, attribute::Attribute) = attribute.attr
Base.convert(::Core.Type{API.MlirAttribute}, attribute::AbstractAttribute) = attribute.attr

"""
parse(::Core.Type{Attribute}, str; context=context())
Expand Down Expand Up @@ -42,7 +42,8 @@ context(attr::Attribute) = Context(API.mlirAttributeGetContext(attr))
Gets the type of this attribute.
"""
type(attr::Attribute) = Type(API.mlirAttributeGetType(attr))
type(attr::AbstractAttribute) = Type(API.mlirAttributeGetType(Attribute(attr)))


"""
typeid(attribute)
Expand Down Expand Up @@ -670,9 +671,8 @@ end
Creates a dense elements attribute that has the same data as the given dense elements attribute and a different shaped type. The new type must have the same total number of elements.
"""
function Base.reshape(attr::DenseElementsAttribute{T}, shape) where {T}

Check warning on line 673 in src/mlir/IR/Attribute.jl

View check run for this annotation

Codecov / codecov/patch

src/mlir/IR/Attribute.jl#L673

Added line #L673 was not covered by tests
attr = attr.attr
@assert length(attr) == prod(shape) "new shape $(shape) has a different number of elements than the original attribute"
element_type = eltype(type(Attribute(attr)))
element_type = eltype(type(attr))
shaped_type = TensorType(shape, element_type)
return DenseElementsAttribute{T}(API.mlirDenseElementsAttrReshape(attr, shaped_type))

Check warning on line 677 in src/mlir/IR/Attribute.jl

View check run for this annotation

Codecov / codecov/patch

src/mlir/IR/Attribute.jl#L677

Added line #L677 was not covered by tests
end
Expand Down Expand Up @@ -778,7 +778,7 @@ function Base.length(attr::Attribute)
end

function Base.getindex(attr::DenseElementsAttribute, i)
attr = attr.attr
attr = Attribute(attr)
elem_type = julia_type(eltype(type(attr)))
if elem_type isa Bool
API.mlirDenseElementsAttrGetBoolValue(attr, i)
Expand Down Expand Up @@ -926,7 +926,6 @@ function Base.convert(::Core.Type{API.MlirAttribute}, named_attribute::NamedAttr
return named_attribute.named_attribute
end

#Attribute(d::DenseElementsAttribute) = d.attr.attr

function DenseArrayAttribute(values::Vector{<:Enum})
return Attribute([Attribute(value) for value in values])
Expand Down

0 comments on commit 8186305

Please sign in to comment.