Mercurial > repos > public > sbplib_julia
comparison LazyTensors/src/lazy_operations.jl @ 207:f85a0b38f3ff boundary_conditions
Change error type when doing element wise operations on lazy arrays of missmatching dimension
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 24 Jun 2019 15:54:47 +0200 |
parents | 7b0650021b36 |
children | 7db145ce6e4d |
comparison
equal
deleted
inserted
replaced
206:7b0650021b36 | 207:f85a0b38f3ff |
---|---|
52 struct LazyElementwiseOperation{T,D,Op, T1<:AbstractArray{T,D}, T2 <: AbstractArray{T,D}} <: LazyArray{T,D} | 52 struct LazyElementwiseOperation{T,D,Op, T1<:AbstractArray{T,D}, T2 <: AbstractArray{T,D}} <: LazyArray{T,D} |
53 a::T1 | 53 a::T1 |
54 b::T2 | 54 b::T2 |
55 | 55 |
56 @inline function LazyElementwiseOperation{T,D,Op}(a::T1,b::T2) where {T,D,Op, T1<:AbstractArray{T,D}, T2<:AbstractArray{T,D}} | 56 @inline function LazyElementwiseOperation{T,D,Op}(a::T1,b::T2) where {T,D,Op, T1<:AbstractArray{T,D}, T2<:AbstractArray{T,D}} |
57 # TODO: Remove boundscheck once assert can be turned off by | |
58 # optimization flags. Ugly fix. | |
59 # NOTE: Seems like adding the boundscheck introduces allocations. Can this | 57 # NOTE: Seems like adding the boundscheck introduces allocations. Can this |
60 # be fixed? Since boundscheck is removed when inlined into inbounds this | 58 # be fixed? Since boundscheck is removed when inlined into inbounds this |
61 # should not in practise effect performance. | 59 # should not in practise effect performance. |
62 @boundscheck @assert size(a)==size(b) | 60 @boundscheck if size(a) != size(b) |
61 throw(DimensionMismatch("dimensions must match")) | |
62 end | |
63 return new{T,D,Op,T1,T2}(a,b) | 63 return new{T,D,Op,T1,T2}(a,b) |
64 end | 64 end |
65 end | 65 end |
66 | 66 |
67 Base.size(v::LazyElementwiseOperation) = size(v.a) | 67 Base.size(v::LazyElementwiseOperation) = size(v.a) |