From 818630592a63afc21bce36d7e9961fbb79cab3a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20LOUNES?= Date: Wed, 5 Feb 2025 14:45:46 +0100 Subject: [PATCH] review --- src/mlir/IR/Attribute.jl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/mlir/IR/Attribute.jl b/src/mlir/IR/Attribute.jl index 58c6df7f5..42148126f 100644 --- a/src/mlir/IR/Attribute.jl +++ b/src/mlir/IR/Attribute.jl @@ -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()) @@ -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) @@ -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} - 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)) end @@ -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) @@ -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])