@@ -91,22 +91,27 @@ format.lazy_tensor = function(x, ...) { # nolint
9191 if (! length(x )) return (character (0 ))
9292 shape = dd(x )$ pointer_shape
9393 shape = if (is.null(shape )) {
94- return (rep(" <tnsr[]>" , length(x )))
94+ return (rep(" <tnsr[? ]>" , length(x )))
9595 }
9696 shape = paste0(dd(x )$ pointer_shape [- 1L ], collapse = " x" )
9797
9898 map_chr(x , function (elt ) {
9999 sprintf(" <tnsr[%s]>" , shape )
100100 })
101101}
102-
103102# ' @export
104- print.lazy_tensor = function (x , ... ) {
105- cat(paste0(" <ltnsr[" , length(x ), " ]>" , " \n " , collapse = " " ))
106- if (length(x ) == 0 ) return (invisible (x ))
107-
108- out <- stats :: setNames(format(x ), names(x ))
109- print(out , quote = FALSE )
103+ print.lazy_tensor = function (x , ... ) { # nolint
104+ if (length(x ) == 0 ) {
105+ cat(" <ltnsr[len=0]>\n " )
106+ return (invisible (x ))
107+ }
108+ shape = dd(x )$ pointer_shape
109+ if (is.null(shape )) {
110+ cat(sprintf(" <ltnsr[len=%d, shapes=unknown]>\n " , length(x )))
111+ } else {
112+ shape_str = paste0(shape [- 1L ], collapse = " ," )
113+ cat(sprintf(" <ltnsr[len=%d, shapes=(%s)]>\n " , length(x ), shape_str ))
114+ }
110115 invisible (x )
111116}
112117
@@ -181,9 +186,6 @@ as_lazy_tensor.numeric = function(x, ...) { # nolint
181186
182187# ' @export
183188as_lazy_tensor.torch_tensor = function (x , ... ) { # nolint
184- if (length(dim(x )) == 1L ) {
185- x = x $ unsqueeze(2 )
186- }
187189 ds = dataset(
188190 initialize = function (x ) {
189191 self $ x = x
0 commit comments