Skip to content

Commit f8022de

Browse files
committed
lazy model bugfixes
1 parent f6aa0b6 commit f8022de

File tree

2 files changed

+26
-40
lines changed

2 files changed

+26
-40
lines changed

libraries/dfns/graph/demo.lisp

+16-16
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@
5353
(provision "scg1 ← ,¨1(2 4 5)(3 6)(2 7)(0 5)6 5(3 6)")
5454
(provision "scg2 ← ,¨4 0(1 3)2 1(1 4 6)(2 5)(3 6 7)")
5555
(provision "scg3 ← (3)(4)(3 4)(0 2 4)(1 2 3)")
56-
;; (is "↓show scg1" #("1 → 1 " "2 → 2 4 5" "3 → 3 6 " "4 → 2 7 "
57-
;; "5 → 0 5 " "6 → 6 " "7 → 5 " "8 → 3 6 "))
58-
;; (is "{⎕io←0 ⋄ scc ⍵} scg1" #(0 0 1 1 0 2 2 1))
59-
;; (is "↓show scg2" #("1 → 4 " "2 → 0 " "3 → 1 3 " "4 → 2 "
60-
;; "5 → 1 " "6 → 1 4 6" "7 → 2 5 " "8 → 3 6 7"))
61-
;; (is "{⎕io←0 ⋄ scc ⍵} scg2" #(0 0 1 1 0 2 2 3))
62-
;; (is "{⎕io←0 ⋄ scc ⍵} scg3" #(0 0 0 0 0))
63-
;; (is "{⎕io←0 ⋄ ↑∪scc¨{⍵∘gperm¨↓pmat ≢⍵} ⍵} scg3" #2A((0 0 0 0 0)))
64-
;; (is "scc scg1+1" #(1 1 2 2 1 3 3 2))
65-
;; (is "scc scg2+1" #(1 1 2 2 1 3 3 4))
66-
;; (is "scc 1⌽⍳10" #(1 1 1 1 1 1 1 1 1 1))
67-
;; (is "scc ⍳10" #(1 2 3 4 5 6 7 8 9 10))
68-
;; (is "scc 2⌽⍳10" #(1 2 1 2 1 2 1 2 1 2))
69-
;; (is "cond scg1+1" #(#(#(2 3) #(3) #()) #(#(1 2 5) #(3 4 8) #(6 7))))
70-
;; (is "(scc≡⍳∘≢) scg1+1" 0)
71-
;; (is "(scc≡⍳∘≢) (⍳10),⊂⍬" 1)
56+
(is "↓show scg1" #("1 → 1 " "2 → 2 4 5" "3 → 3 6 " "4 → 2 7 "
57+
"5 → 0 5 " "6 → 6 " "7 → 5 " "8 → 3 6 "))
58+
(is "{⎕io←0 ⋄ scc ⍵} scg1" #(0 0 1 1 0 2 2 1))
59+
(is "↓show scg2" #("1 → 4 " "2 → 0 " "3 → 1 3 " "4 → 2 "
60+
"5 → 1 " "6 → 1 4 6" "7 → 2 5 " "8 → 3 6 7"))
61+
(is "{⎕io←0 ⋄ scc ⍵} scg2" #(0 0 1 1 0 2 2 3))
62+
(is "{⎕io←0 ⋄ scc ⍵} scg3" #(0 0 0 0 0))
63+
(is "{⎕io←0 ⋄ ↑∪scc¨{⍵∘gperm¨↓pmat ≢⍵} ⍵} scg3" #2A((0 0 0 0 0)))
64+
(is "scc scg1+1" #(1 1 2 2 1 3 3 2))
65+
(is "scc scg2+1" #(1 1 2 2 1 3 3 4))
66+
(is "scc 1⌽⍳10" #(1 1 1 1 1 1 1 1 1 1))
67+
(is "scc ⍳10" #(1 2 3 4 5 6 7 8 9 10))
68+
(is "scc 2⌽⍳10" #(1 2 1 2 1 2 1 2 1 2))
69+
(is "cond scg1+1" #(#(#(2 3) #(3) #()) #(#(1 2 5) #(3 4 8) #(6 7))))
70+
(is "(scc≡⍳∘≢) scg1+1" 0)
71+
(is "(scc≡⍳∘≢) (⍳10),⊂⍬" 1)
7272
(is "stdists¨g∘span¨⍳⍴g" #(#(0 1 1 2 3) #(3 0 1 2 3) #(2 1 0 1 2) #(1 2 2 0 1) #(3 2 1 2 0)))
7373
(is "(g span 3)∘stpath¨⍳5" #(#(3 4 1) #(3 2) #(3) #(3 4) #(3 4 5)))
7474
(is "(g∘span¨⍳⍴g)∘.stpath⍳⍴g"

varray/varray.lisp

+10-24
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,10 @@
312312
;; divisions division-size sbesize sbsize))
313313
(loop :for d :below divisions
314314
:do (if ;; (< *active-workers* *workers-count*)
315-
;; (loop :for worker :across (lparallel.kernel::workers lparallel::*kernel*)
316-
;; :never (null (lparallel.kernel::running-category worker)))
315+
(loop :for worker :across (lparallel.kernel::workers lparallel::*kernel*)
316+
:never (null (lparallel.kernel::running-category worker)))
317317
;; t
318-
(lparallel:kernel-worker-index)
318+
;; (lparallel:kernel-worker-index)
319319
(funcall (funcall process d))
320320
(progn (incf threaded-count)
321321
(lparallel::submit-task lpchannel (funcall process d)))))
@@ -2325,8 +2325,9 @@
23252325

23262326
(defmethod prototype-of ((varray vader-mix))
23272327
(let ((base-indexer (base-indexer-of varray)))
2328-
(prototype-of (if (not (functionp base-indexer))
2329-
base-indexer (funcall base-indexer 0)))))
2328+
(prototype-of (or (vamix-cached-elements varray)
2329+
(if (not (functionp base-indexer))
2330+
base-indexer (funcall base-indexer 0))))))
23302331

23312332
(defmethod shape-of ((varray vader-mix))
23322333
(get-promised
@@ -2342,15 +2343,12 @@
23422343
((not base-shape)
23432344
(setf (vamix-cached-elements varray)
23442345
(funcall base-indexer 0))
2345-
;; (print (list :eoe (shape-of (vamix-cached-elements varray))))
23462346
(shape-of (vamix-cached-elements varray)))
23472347
(t
2348-
(if (typep base 'vacomp-reduce) (print :aa))
23492348
(loop :for ix :below (reduce #'* base-shape)
23502349
:do (let ((member (funcall base-indexer ix)))
23512350
(setf max-rank (max max-rank (length (shape-of member))))
23522351
(push (shape-of member) each-shape)))
2353-
(if (typep base 'vacomp-reduce) (print :ee))
23542352
(let ((out-shape) (shape-indices)
23552353
(max-shape (make-array max-rank :element-type 'fixnum :initial-element 0)))
23562354
(loop :for shape :in each-shape
@@ -2361,8 +2359,6 @@
23612359
(setf axis (setf (vads-axis varray)
23622360
(if (eq :last axis) (length base-shape)
23632361
(ceiling (- axis (vads-io varray))))))
2364-
2365-
(if (typep base 'vacomp-reduce) (print :dd))
23662362
;; push the outer shape elements to the complete shape
23672363
(loop :for odim :in base-shape :for ix :from 0
23682364
:do (when (= ix axis)
@@ -2385,27 +2381,21 @@
23852381
(defmethod indexer-of ((varray vader-mix) &optional params)
23862382
(get-promised
23872383
(varray-indexer varray)
2388-
(let* (;; (ee (if (typep (vader-base varray) 'vacomp-reduce) (print :cc)))
2389-
(oshape (shape-of varray))
2384+
(let* ((oshape (shape-of varray))
23902385
(ofactors (get-dimensional-factors oshape t))
23912386
(oindexer (base-indexer-of varray))
23922387
(dim-indices (vamix-shape-indices varray))
23932388
(orank (length (shape-of (vader-base varray))))
2394-
;; (ee (if (typep (vader-base varray) 'vacomp-reduce) (print :dd)))
23952389
(outer-shape (loop :for i :in dim-indices :for s :in oshape
23962390
:when (> orank i) :collect s))
23972391
(inner-shape (loop :for i :in dim-indices :for s :in oshape
23982392
:when (<= orank i) :collect s))
23992393
(inner-rank (length inner-shape))
24002394
(iofactors (get-dimensional-factors outer-shape t)))
2401-
;; (if (typep (vader-base varray) 'vacomp-reduce) (print :aa))
2402-
;; (print (list :oo oshape (shape-of (vader-base varray))
2403-
;; (not (shape-of (vader-base varray)))))
2404-
24052395
;; TODO: add logic to simply return the argument if it's an array containing no nested arrays
24062396
(if (not oshape) ;; if the argument is a scalar
24072397
(if (not (functionp oindexer)) ;; a scalar value like 5
2408-
(lambda (index) (disclose oindexer))
2398+
(lambda (i) (declare (ignore i)) (disclose oindexer))
24092399
;; TODO: change indexer-of for rank 0 arrays to obviate this
24102400
(let* ((indexed (funcall oindexer 0))
24112401
(iindexer (indexer-of indexed))
@@ -2414,10 +2404,9 @@
24142404
(if (and (typep (vader-base varray) 'varray)
24152405
(not (shape-of (vader-base varray))))
24162406
(indexer-of (vader-base varray))
2417-
(lambda (index) sub-index))))
2407+
(lambda (i) (declare (ignore i)) sub-index))))
24182408
(if (not (shape-of (vader-base varray)))
24192409
;; pass through the indexer of enclosed arrays as for ↑⊂2 4
2420-
;; (indexer-of (funcall oindexer 0))
24212410
(indexer-of (vamix-cached-elements varray))
24222411
(if (vamix-cached-elements varray)
24232412
(progn (print (list :ce (vamix-cached-elements varray)))
@@ -2445,9 +2434,6 @@
24452434
(irank (length ishape))
24462435
(doffset (- inner-rank irank))
24472436
(iindex 0))
2448-
;; (if (arrayp iarray)
2449-
;; (print (list :ia iarray (type-of (vader-base varray))
2450-
;; (shape-of varray))))
24512437
(if (not (functionp iindexer))
24522438
(when (zerop (reduce #'+ inner-indices)) iindexer)
24532439
(progn (loop :for i :in inner-indices :for ix :from 0 :while iindex
@@ -4119,7 +4105,7 @@
41194105
(setq value (if (not value) item
41204106
(funcall (vacmp-left varray)
41214107
value item))))))
4122-
;; (print (list :val value (render value)))
4108+
;; (print (list :val value))
41234109
value))))))))))))
41244110

41254111
;; (flet ((process-item (ix)

0 commit comments

Comments
 (0)