You can by storing the slice in a variable before passing it to `apply`. I 
tried to make it possible without the intermediate assignment but had issues 
when trying to return `var Tensor` from slicing.

Example usage for RNN/GRU implementation: 
<https://github.com/mratsim/Arraymancer/blob/1a2422a1/src/arraymancer/nn_primitives/nnp_gru.nim#L76-L84>
    
    
    .
      # Step 2 - Computing reset (r) and update (z) gate
      var W2ru = W3x[_, srz] # shape [batch_size, 2*H] - we reuse the previous 
buffer
      apply2_inline(W2ru, U3h[_, srz]):
        sigmoid(x + y)
      
      # Step 3 - Computing candidate hidden state ñ
      var n = W3x[_, s] # shape [batch_size, H] - we reuse the previous buffer
      apply3_inline(n, W2ru[_, sr], U3h[_, s]):
        tanh(x + y * z)
    
    
    Run

Reply via email to