diff 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
line wrap: on
line diff
--- a/LazyTensors/src/lazy_operations.jl	Mon Jun 24 14:57:17 2019 +0200
+++ b/LazyTensors/src/lazy_operations.jl	Mon Jun 24 15:54:47 2019 +0200
@@ -54,12 +54,12 @@
     b::T2
 
     @inline function LazyElementwiseOperation{T,D,Op}(a::T1,b::T2) where {T,D,Op, T1<:AbstractArray{T,D}, T2<:AbstractArray{T,D}}
-        # TODO: Remove boundscheck once assert can be turned off by
-        # optimization flags. Ugly fix.
         # NOTE: Seems like adding the boundscheck introduces allocations. Can this
         # be fixed? Since boundscheck is removed when inlined into inbounds this
         # should not in practise effect performance.
-        @boundscheck @assert size(a)==size(b)
+        @boundscheck if size(a) != size(b)
+            throw(DimensionMismatch("dimensions must match"))
+        end
         return new{T,D,Op,T1,T2}(a,b)
     end
 end