File tree Expand file tree Collapse file tree 3 files changed +12
-12
lines changed Expand file tree Collapse file tree 3 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -143,9 +143,13 @@ private Type GetType(Type type)
143143 switch ( type . Kind )
144144 {
145145 case Type . TypeKind . DynamicType :
146- return type . AsDynamicType ( ) ;
146+ var dynamic = type . AsDynamicType ( ) ;
147+ type . Dispose ( ) ;
148+ return dynamic ;
147149 case Type . TypeKind . TensorType :
148- return type . AsDynamicType ( ) ;
150+ var tensor = type . AsTensorType ( ) ;
151+ type . Dispose ( ) ;
152+ return tensor ;
149153 default :
150154 return type ;
151155 }
Original file line number Diff line number Diff line change @@ -8,12 +8,5 @@ internal DynamicType(IntPtr handle) : base(handle)
88 {
99 this . handle = new HType ( handle , true ) ;
1010 }
11-
12- internal DynamicType ( Type type ) : base ( )
13- {
14- handle = type . handle ;
15- type . handle = new HType ( IntPtr . Zero , true ) ;
16- type . Dispose ( ) ;
17- }
1811 }
1912}
Original file line number Diff line number Diff line change @@ -78,21 +78,24 @@ protected void Dispose(bool disposing)
7878 }
7979
8080 [ DllImport ( "libTorchSharp" ) ]
81- extern static short THSJIT_typeKind ( HType handle ) ;
81+ extern static sbyte THSJIT_typeKind ( HType handle ) ;
8282
8383 internal TypeKind Kind
8484 {
8585 get { return ( TypeKind ) THSJIT_typeKind ( handle ) ; }
8686 }
8787
88+ [ DllImport ( "libTorchSharp" ) ]
89+ extern static IntPtr THSJIT_typeCast ( HType module ) ;
90+
8891 internal TensorType AsTensorType ( )
8992 {
90- return new TensorType ( this ) ;
93+ return new TensorType ( THSJIT_typeCast ( handle ) ) ;
9194 }
9295
9396 internal DynamicType AsDynamicType ( )
9497 {
95- return new DynamicType ( this ) ;
98+ return new DynamicType ( THSJIT_typeCast ( handle ) ) ;
9699 }
97100
98101 internal enum TypeKind : sbyte
You can’t perform that action at this time.
0 commit comments