 
 (defn- max-extend-strides
   [shape strides max-count]
-  (let [num-items (count shape)
+  (let [shape (disambiguate-shape shape)
+        num-items (count shape)
         max-stride-idx (long
                         (loop [idx 1
                                max-idx 0]



(defn dimensions
  "A dimension is a map with at least a shape (vector of integers) and potentially another
vector of dimension names.  By convention the first member of the shape is the slowest changing
and the last member of the shape is the most rapidly changing.  There can also be optionally a
companion vector of names which name each dimension.  Names are used when doing things that are
dimension aware such as a 2d convolution.  Shape is the same as a core-matrix shape."
  [shape & {:keys [names strides]}]
  (let [strides (extend-strides shape strides)
        sorted-shape-stride (->> (map vector shape strides)
                                 (sort-by second >))
        max-stride (apply max 0 (map second sorted-shape-stride))
        elem-count (apply * 1 (drop 1 (map first sorted-shape-stride)))]
    (when-not-error (<= (long elem-count)
                        (long max-stride))
      "Stride appears to be too small for element count"

  (let [shapes (map :shape args)
        strides (map :strides args)
        max-count (long (apply max 0 (map count shapes)))
        ;;Max extend strides that are too small.
        strides (map (fn [shp stride]
                       (max-extend-strides shp stride max-count))
                     shapes strides)
        ;;One extend shapes that are too small
        shapes (map (fn [shp]
                      (->> (concat (repeat (- max-count (count shp)) 1)
                                   shp)
