anchor.diff:      let reduceCache = ExpressionCache()
       let mapReduceCache = ExpressionCache()
       let mapReduceImageCache = ExpressionCache()
  +    
  +    let scanImage2dCache = ExpressionCache()
  +
   
   
       let getMapper (map : Expr<int -> 'a -> 'b>) = mapCache.GetOrCreate(map, fun map -> new Map<'a, 'b>(runtime, map))
  
positive.code:     member x.CompileScan(add : Expr<'a -> 'a -> 'a>, input : IBufferVector<'a>, output : IBufferVector<'a>) =
          let scanner = getScanner add
          scanner.Compile(input, output)
  
      member x.CompileFold(add : Expr<'a -> 'a -> 'a>, input : IBufferVector<'a>) =
          let reducer = getReducer add
  
negative.code: 
      static member Expr = add
  
  type private ScanImage2d(runtime : IComputeRuntime, add : Expr<V4d -> V4d -> V4d>) =
  
      static let ceilDiv (v : int) (d : int) =
          if v % d = 0 then v / d
          else 1 + v / d
  
      let scanX   = runtime.CreateComputeShader (Kernels.scanImageKernel2d 0 add)
      let scanY   = runtime.CreateComputeShader (Kernels.scanImageKernel2d 1 add)
  
      let release() =
          runtime.DeleteComputeShader scanX
          runtime.DeleteComputeShader scanY
  
      let rec build (args : HashSet<IComputeShaderInputBinding>) (input : ITexture) (output : ITextureSubResource) =
          let size = output.Size
          if size.X <= Kernels.scanSize && size.Y <= Kernels.scanSize then
              
              let xInput = runtime.NewInputBinding(scanX)
              xInput.["InputTexture"] <- input
              xInput.["outputImage"] <- output
              xInput.Flush()
  
              let yInput = runtime.NewInputBinding(scanX)
              xInput.["InputTexture"] <- input
              xInput.["outputImage"] <- output
              xInput.Flush()
  
              [
                  ComputeCommand.Bind scanX
                  ComputeCommand.SetInput xInput
                  ComputeCommand.Dispatch(V2i(ceilDiv size.X Kernels.scanSize, size.Y))
  
              ]
  
  
  
          else
              failwith ""
  
  
  
          
      member x.Compile (input : ITexture, output : ITextureSubResource) =
          let args = System.Collections.Generic.HashSet<IComputeShaderInputBinding>()
          let cmd = build args input output
          let prog = runtime.Compile cmd
          
          prog.OnDispose(fun () ->
              for a in args do a.Dispose()
              args.Clear()
          )
          prog
          
      member x.Run (input : ITexture, output : ITextureSubResource) =
          let args = System.Collections.Generic.HashSet<IComputeShaderInputBinding>()
          let cmd = build args input output
          runtime.Run cmd
          for a in args do a.Dispose()
          args.Clear()
    
      member x.Dispose() =
          release()
  
      
  
  
  [<AbstractClass>]
  type private Existential<'r>() =
      static let visitMeth = typeof<Existential<'r>>.GetMethod "Visit"
  