@@ -274,22 +274,22 @@ let%expect_test "Simple gradients hosted" =
274274 Tensor. print_tree ~with_grad: true ~depth: 9 l;
275275 [% expect
276276 {|
277- #12 *. _l Host & dev / 41
278- < not - in - yet>
279- #13 grad_*. _l Host & dev / 41
280- < not - in - yet>
281- #8 + _d Host & dev / 41 │#10 f Host - non - const / 24
282- < not - in - yet> │< not - in - yet>
283- #9 grad_+ _d Host & dev / 41 │#11 grad_f Host & dev / 41
284- < not - in - yet> │< not - in - yet>
285- #4 *. _e Host & dev / 41 │#6 c Host - non - const / 24 │
286- < not - in - yet> │< not - in - yet> │
287- #5 grad_*. _e Host & dev / 41 │#7 grad_c Host & dev / 41 │
288- < not - in - yet> │< not - in - yet> │
289- #0 a Host - non - const / 24 │#2 b Host - non - const / 24 │ │
290- < not - in - yet> │< not - in - yet> │ │
291- #1 grad_a Host & dev / 41 │#3 grad_b Host & dev / 41 │ │
292- < not - in - yet> │< not - in - yet> │ │
277+ #12 *. _l Host & stream / 41
278+ < not - in - yet>
279+ #13 grad_*. _l Host & stream / 41
280+ < not - in - yet>
281+ #8 + _d Host & stream / 41 │#10 f Host & shared / 39
282+ < not - in - yet> │< not - in - yet>
283+ #9 grad_+ _d Host & stream / 41 │#11 grad_f Host & stream / 41
284+ < not - in - yet> │< not - in - yet>
285+ #4 *. _e Host & stream / 41 │#6 c Host & shared / 39 │
286+ < not - in - yet> │< not - in - yet> │
287+ #5 grad_*. _e Host & stream / 41 │#7 grad_c Host & stream / 41 │
288+ < not - in - yet> │< not - in - yet> │
289+ #0 a Host & shared / 39 │#2 b Host & shared / 39 │ │
290+ < not - in - yet> │< not - in - yet> │ │
291+ #1 grad_a Host & stream / 41 │#3 grad_b Host & stream / 41 │ │
292+ < not - in - yet> │< not - in - yet> │ │
293293 | }];
294294 (* Do not update the params: all values and gradients will be at initial points, which are
295295 specified in the tensor in the brackets. *)
@@ -411,45 +411,45 @@ let%expect_test "Simple gradients virtual" =
411411 Tensor. print_tree ~with_grad: true ~depth: 9 l;
412412 [% expect
413413 {|
414- #12 *. _l Host & dev / 41
415- < not - in - yet>
416- #13 grad_*. _l Virt / 40
417- < not - in - yet>
418- #8 + _d Local / 50 │#10 f Host - non - const / 24
419- < not - in - yet> │< not - in - yet>
420- #9 grad_+ _d Virt / 40 │#11 grad_f On - dev / 50
421- < not - in - yet> │< not - in - yet>
422- #4 *. _e Virt / 152 │#6 c Host - non - const / 24 │
423- < not - in - yet> │< not - in - yet> │
424- #5 grad_*. _e Virt / 40 │#7 grad_c On - dev / 50 │
425- < not - in - yet> │< not - in - yet> │
426- #0 a Host - non - const / 24 │#2 b Host - non - const / 24 │ │
427- < not - in - yet> │< not - in - yet> │ │
428- #1 grad_a On - dev / 50 │#3 grad_b On - dev / 50 │ │
429- < not - in - yet> │< not - in - yet> │ │
414+ #12 *. _l Host & stream / 41
415+ < not - in - yet>
416+ #13 grad_*. _l Virt / 40
417+ < not - in - yet>
418+ #8 + _d Local / 46 │#10 f Host & shared / 39
419+ < not - in - yet> │< not - in - yet>
420+ #9 grad_+ _d Virt / 40 │#11 grad_f Dev - stream / 41
421+ < not - in - yet> │< not - in - yet>
422+ #4 *. _e Virt / 152 │#6 c Host & shared / 39 │
423+ < not - in - yet> │< not - in - yet> │
424+ #5 grad_*. _e Virt / 40 │#7 grad_c Dev - stream / 41 │
425+ < not - in - yet> │< not - in - yet> │
426+ #0 a Host & shared / 39 │#2 b Host & shared / 39 │ │
427+ < not - in - yet> │< not - in - yet> │ │
428+ #1 grad_a Dev - stream / 41 │#3 grad_b Dev - stream / 41 │ │
429+ < not - in - yet> │< not - in - yet> │ │
430430 | }];
431431 (* Do not update the params: all values and gradients will be at initial points, which are
432432 specified in the tensor in the brackets. *)
433433 Train. sync_run backend grad_routine l;
434434 Tensor. print_tree ~with_grad: true ~depth: 9 l;
435435 [% expect
436436 {|
437- #12 *. _l
438- - 8.00e+0
439- #13 grad_*. _l Virt / 40
440- < void>
441- #8 + _d Local / 50 │#10 f
442- < void> │ - 2.00e+0
443- #9 grad_+ _d Virt / 40 │#11 grad_f On - dev / 50
444- < void> │< void>
445- #4 *. _e Virt / 152 │#6 c │
446- < void> │ 1.00e+1 │
447- #5 grad_*. _e Virt / 40 │#7 grad_c On - dev / 50 │
448- < void> │< void> │
449- #0 a │#2 b │ │
450- 2.00e+0 │ - 3.00e+0 │ │
451- #1 grad_a On - dev / 50 │#3 grad_b On - dev / 50 │ │
452- < void> │< void> │ │
437+ #12 *. _l
438+ - 8.00e+0
439+ #13 grad_*. _l Virt / 40
440+ < void>
441+ #8 + _d Local / 46 │#10 f
442+ < void> │ - 2.00e+0
443+ #9 grad_+ _d Virt / 40 │#11 grad_f Dev - stream / 41
444+ < void> │< void>
445+ #4 *. _e Virt / 152 │#6 c │
446+ < void> │ 1.00e+1 │
447+ #5 grad_*. _e Virt / 40 │#7 grad_c Dev - stream / 41 │
448+ < void> │< void> │
449+ #0 a │#2 b │ │
450+ 2.00e+0 │ - 3.00e+0 │ │
451+ #1 grad_a Dev - stream / 41 │#3 grad_b Dev - stream / 41 │ │
452+ < void> │< void> │ │
453453 | }];
454454 (* Only now compile the SGD update. *)
455455 let sgd_routine = Train. to_routine (module Backend ) grad_routine.context IDX. empty sgd in
@@ -460,45 +460,45 @@ let%expect_test "Simple gradients virtual" =
460460 Tensor. print_tree ~with_grad: true ~depth: 9 l;
461461 [% expect
462462 {|
463- #12 *. _l
464- - 8.00e+0
465- #13 grad_*. _l Virt / 40
466- < void>
467- #8 + _d Local / 50 │#10 f
468- < void> │ - 2.40e+0
469- #9 grad_+ _d Virt / 40 │#11 grad_f On - dev / 50
470- < void> │< void>
471- #4 *. _e Virt / 152 │#6 c │
472- < void> │ 1.02e+1 │
473- #5 grad_*. _e Virt / 40 │#7 grad_c On - dev / 50 │
474- < void> │< void> │
475- #0 a │#2 b │ │
476- 1.40e+0 │ - 2.60e+0 │ │
477- #1 grad_a On - dev / 50 │#3 grad_b On - dev / 50 │ │
478- < void> │< void> │ │
463+ #12 *. _l
464+ - 8.00e+0
465+ #13 grad_*. _l Virt / 40
466+ < void>
467+ #8 + _d Local / 46 │#10 f
468+ < void> │ - 2.40e+0
469+ #9 grad_+ _d Virt / 40 │#11 grad_f Dev - stream / 41
470+ < void> │< void>
471+ #4 *. _e Virt / 152 │#6 c │
472+ < void> │ 1.02e+1 │
473+ #5 grad_*. _e Virt / 40 │#7 grad_c Dev - stream / 41 │
474+ < void> │< void> │
475+ #0 a │#2 b │ │
476+ 1.40e+0 │ - 2.60e+0 │ │
477+ #1 grad_a Dev - stream / 41 │#3 grad_b Dev - stream / 41 │ │
478+ < void> │< void> │ │
479479 | }];
480480 (* Now the params will remain as above, but both param gradients and the values and gradients of
481481 other nodes will change thanks to the forward and backward passes. *)
482482 Train. sync_run backend grad_routine l;
483483 Tensor. print_tree ~with_grad: true ~depth: 9 l;
484484 [% expect
485485 {|
486- #12 *. _l
487- - 1.57e+1
488- #13 grad_*. _l Virt / 40
489- < void>
490- #8 + _d Local / 50 │#10 f
491- < void> │ - 2.40e+0
492- #9 grad_+ _d Virt / 40 │#11 grad_f On - dev / 50
493- < void> │< void>
494- #4 *. _e Virt / 152 │#6 c │
495- < void> │ 1.02e+1 │
496- #5 grad_*. _e Virt / 40 │#7 grad_c On - dev / 50 │
497- < void> │< void> │
498- #0 a │#2 b │ │
499- 1.40e+0 │ - 2.60e+0 │ │
500- #1 grad_a On - dev / 50 │#3 grad_b On - dev / 50 │ │
501- < void> │< void> │ │
486+ #12 *. _l
487+ - 1.57e+1
488+ #13 grad_*. _l Virt / 40
489+ < void>
490+ #8 + _d Local / 46 │#10 f
491+ < void> │ - 2.40e+0
492+ #9 grad_+ _d Virt / 40 │#11 grad_f Dev - stream / 41
493+ < void> │< void>
494+ #4 *. _e Virt / 152 │#6 c │
495+ < void> │ 1.02e+1 │
496+ #5 grad_*. _e Virt / 40 │#7 grad_c Dev - stream / 41 │
497+ < void> │< void> │
498+ #0 a │#2 b │ │
499+ 1.40e+0 │ - 2.60e+0 │ │
500+ #1 grad_a Dev - stream / 41 │#3 grad_b Dev - stream / 41 │ │
501+ < void> │< void> │ │
502502 | }]
503503
504504let % expect_test " tanh plot" =
@@ -565,12 +565,12 @@ let%expect_test "2D neuron virtual" =
565565 7.00e-1
566566 #9 grad_+ _v Virt / 40
567567 < void>
568- #6 * Local / 50 │#0 b
568+ #6 * Local / 46 │#0 b
569569 < void> │ 6.70e+0
570- #7 grad_* Virt / 40 │#1 grad_b Local / 50
570+ #7 grad_* Virt / 40 │#1 grad_b Local / 46
571571 < void> │< void>
572572 #2 w │#4 x │
573573 - 3.00e+0 1.00e+0 │ 2.00e+0 0.00e+0 │
574- #3 grad_w Local / 50 │#5 grad_x Local / 50 │
574+ #3 grad_w Local / 46 │#5 grad_x Local / 46 │
575575 < void> │< void> │
576576 | }]
0 commit comments