Skip to content

Commit

Permalink
Fixes for #94
Browse files Browse the repository at this point in the history
  • Loading branch information
cnuernber committed Mar 10, 2024
1 parent 41e03f3 commit 7ddf447
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/tech/v3/tensor_api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
(apply dims/select (.dimensions t) select-args)
buffer (or (.buffer t) (.bufferIO t))
buf-offset (long buf-offset)
;; _ (println "buflen" buf-len)
new-buffer (if (and buf-len (== 0 (long buf-len)))
buffer
(if-not (and (== buf-offset 0)
Expand Down Expand Up @@ -215,10 +214,14 @@
(reify ObjectReader
(lsize [rdr] n-offsets)
(readObject [rdr idx]
(construct-tensor (dtype-base/sub-buffer
tens-buf
(.readLong offsets idx)
buf-ecount)
(construct-tensor (if buf-ecount
(dtype-base/sub-buffer
tens-buf
(.readLong offsets idx)
buf-ecount)
(dtype-base/sub-buffer
tens-buf
(.readLong offsets idx)))
dimensions)))))))
(mget [t idx-seq]
(.ndReadObjectIter t idx-seq))
Expand Down
9 changes: 9 additions & 0 deletions test/tech/v3/tensor/integration_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,12 @@
(is (= [0 10] (dtype/shape (dtt/select a 2 :lla))))
(is (= [0] (dtype/shape (dtt/select a 2 :all 4))))
(is (= [2 0 3] (dtype/shape (dtt/select a (range 2 4) :all (range 6 9)))))))


(deftest issue-94
(let [n-neurons 10
weights (dtt/clone (dtt/compute-tensor [n-neurons n-neurons] (fn [_ _] (< (double (rand)) 0.1)) :boolean))
activations (dtt/->tensor (range n-neurons))
ww (dtt/select weights (range n-neurons))
answer (dtt/reduce-axis (dtt/select weights (dtt/->tensor (range n-neurons))) dfn/sum 0 :float32)]
(is (not (nil? (.toString ^Object answer))))))

0 comments on commit 7ddf447

Please sign in to comment.