File tree 2 files changed +12
-16
lines changed
2 files changed +12
-16
lines changed Original file line number Diff line number Diff line change 7
7
# This file is subject to the terms and conditions defined in
8
8
# file 'LICENSE.txt', which is part of this source code package.
9
9
# ***************************************************************
10
- __version__ = '1.1.7.19 '
10
+ __version__ = '1.1.7.20 '
11
11
from . import lock
12
12
with lock .lock_scope ():
13
13
from . import compiler
@@ -818,10 +818,19 @@ def jittor_exit():
818
818
core .cleanup ()
819
819
atexit .register (jittor_exit )
820
820
821
- Var .__str__ = lambda x : str (x .data )
822
- Var .__repr__ = lambda x : str (x .data )
821
+ def vtos (v ):
822
+ return f"jt.Var({ v .data } , dtype={ v .dtype } )"
823
+
824
+ Var .__str__ = vtos
825
+ Var .__repr__ = vtos
823
826
Var .peek = lambda x : f"{ x .dtype } { x .shape } "
824
827
828
+ def size (v , dim = None ):
829
+ if dim is None :
830
+ return v .shape
831
+ return v .shape [dim ]
832
+ Var .size = size
833
+
825
834
def item (v ):
826
835
return v .data .item ()
827
836
Original file line number Diff line number Diff line change @@ -72,19 +72,6 @@ struct VarHolder {
72
72
return var->name .c_str ();
73
73
}
74
74
75
- // @pyjt(size)
76
- inline NanoVector size () {
77
- if (var->num <0 ) sync ();
78
- return var->shape ;
79
- }
80
-
81
- // @pyjt(size)
82
- inline int64 size (int64 dim) {
83
- if (var->num <0 ) sync ();
84
- ASSERT (dim>=0 && dim<var->shape .size ()) << " dim is out of index" ;
85
- return var->shape [dim];
86
- }
87
-
88
75
// @pyjt(numel)
89
76
inline int64 numel () {
90
77
if (var->num <0 ) sync ();
You can’t perform that action at this time.
0 commit comments