Skip to content

Commit

Permalink
feat: ensure size of value in setproperty is same as original shape
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 4, 2024
1 parent deefd18 commit f893df2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/TracedRArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ mutable struct TracedRArray{T,N} <: RArray{T,N}
end
end

function Base.setproperty!(x::TracedRArray, f::Symbol, v)
if f === :shape && !isnothing(v)
@assert v isa MLIR.IR.Value
mlir_size = size(MLIR.IR.type(v))
@assert mlir_size == x.shape "Expected shape $(x.shape), got $(mlir_size)"
end
return setfield!(x, f, v)
end

const WrappedTracedRArray{T,N} = WrappedArray{T,N,TracedRArray,TracedRArray{T,N}}
const AnyTracedRArray{T,N} = Union{TracedRArray{T,N},WrappedTracedRArray{T,N}}
const AnyTracedRScalar{T} = AnyTracedRArray{T,0}
Expand Down

0 comments on commit f893df2

Please sign in to comment.