 
 ! Construct a tensor with vec { 0 1 2 ... } and reshape to the desired shape
 : naturals ( shape -- tensor )
-    check-shape [ ] [ product [0..b) >float-array ] bi <tensor> ;
+    check-shape dup product [0..b) >float-array <tensor> ;
 
 ! Construct a tensor without initializing its values
 : (tensor) ( shape -- tensor )


! Sum together all elements in the tensor
syntax:M: tensor sum vec>> 0 <simd-slice>
    [ simd-slice>> 0 [ sum + ] reduce ]
    [ end-slice>> sum ] bi + ;

<PRIVATE

:: final-vstack-shape ( seq -- shape )
    ! Compute the new second-to-last dimension
    seq first dims 2 - :> vdim
    seq [ shape>> vdim swap nth ] map-sum
    ! Combine it to create the new shape
    seq first shape>> clone :> new-shape
    vdim new-shape set-nth
