@@ -62,16 +62,14 @@ type memory_mode =
6262 optional [array] of {!t}). *)
6363[@@ deriving sexp , compare , equal ]
6464
65- type delayed_prec =
66- | Not_specified
67- | Default_spec of (Ops .prec Lazy .t [@ sexp.opaque])
68- | Specified of Ops .prec
65+ type delayed_prec = Not_specified | Default_spec of Ops .prec Lazy .t | Specified of Ops .prec
6966[@@ deriving sexp , equal ]
7067
7168type t = {
72- array : (Nd .t option Lazy .t [@ sexp.opaque]);
73- prec : (Ops .prec Lazy .t [@ sexp.opaque]);
74- dims : (int array Lazy .t [@ sexp.opaque]);
69+ array : Nd .t option Lazy .t ;
70+ prec : Ops .prec Lazy .t ;
71+ dims : int array Lazy .t ;
72+ size_in_bytes : int Lazy .t ;
7573 id : int ;
7674 label : string list ;
7775 (* * Display information. It is better if the last element of the list is the most narrow or
@@ -90,7 +88,6 @@ let num_elems tn =
9088 let dims = Lazy. force tn.dims in
9189 if Array. is_empty dims then 0 else Array. reduce_exn dims ~f: ( * )
9290
93- let size_in_bytes tn = num_elems tn * Ops. prec_in_bytes (Lazy. force tn.prec)
9491let id { id; _ } = " n" ^ Int. to_string id
9592let label a = String. concat ~sep: " _" a.label
9693let is_alphanum_ = String. for_all ~f: (fun c -> Char. equal c '_' || Char. is_alphanum c)
@@ -512,6 +509,7 @@ let create ?default_prec ~id ~label ~dims init_op =
512509 | Specified prec | Default_spec (lazy prec ) -> prec
513510 | Not_specified ->
514511 raise @@ Utils. User_error " Tnode.update_prec: precision is not specified yet" )
512+ and size_in_bytes = lazy (num_elems tn * Ops. prec_in_bytes (Lazy. force tn.prec))
515513 and tn =
516514 let delayed_prec_unsafe =
517515 match default_prec with None -> Not_specified | Some prec -> Default_spec prec
@@ -521,6 +519,7 @@ let create ?default_prec ~id ~label ~dims init_op =
521519 delayed_prec_unsafe;
522520 prec;
523521 dims;
522+ size_in_bytes;
524523 id;
525524 label;
526525 memory_mode = None ;
@@ -541,6 +540,7 @@ let find =
541540 prec = lazy Ops. single;
542541 delayed_prec_unsafe = Specified Ops. single;
543542 dims = lazy [||];
543+ size_in_bytes = lazy 0 ;
544544 id = - 1 ;
545545 label = [] ;
546546 memory_mode = None ;
0 commit comments