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)
143
143
switch ( type . Kind )
144
144
{
145
145
case Type . TypeKind . DynamicType :
146
- return type . AsDynamicType ( ) ;
146
+ var dynamic = type . AsDynamicType ( ) ;
147
+ type . Dispose ( ) ;
148
+ return dynamic ;
147
149
case Type . TypeKind . TensorType :
148
- return type . AsDynamicType ( ) ;
150
+ var tensor = type . AsTensorType ( ) ;
151
+ type . Dispose ( ) ;
152
+ return tensor ;
149
153
default :
150
154
return type ;
151
155
}
Original file line number Diff line number Diff line change @@ -8,12 +8,5 @@ internal DynamicType(IntPtr handle) : base(handle)
8
8
{
9
9
this . handle = new HType ( handle , true ) ;
10
10
}
11
-
12
- internal DynamicType ( Type type ) : base ( )
13
- {
14
- handle = type . handle ;
15
- type . handle = new HType ( IntPtr . Zero , true ) ;
16
- type . Dispose ( ) ;
17
- }
18
11
}
19
12
}
Original file line number Diff line number Diff line change @@ -78,21 +78,24 @@ protected void Dispose(bool disposing)
78
78
}
79
79
80
80
[ DllImport ( "libTorchSharp" ) ]
81
- extern static short THSJIT_typeKind ( HType handle ) ;
81
+ extern static sbyte THSJIT_typeKind ( HType handle ) ;
82
82
83
83
internal TypeKind Kind
84
84
{
85
85
get { return ( TypeKind ) THSJIT_typeKind ( handle ) ; }
86
86
}
87
87
88
+ [ DllImport ( "libTorchSharp" ) ]
89
+ extern static IntPtr THSJIT_typeCast ( HType module ) ;
90
+
88
91
internal TensorType AsTensorType ( )
89
92
{
90
- return new TensorType ( this ) ;
93
+ return new TensorType ( THSJIT_typeCast ( handle ) ) ;
91
94
}
92
95
93
96
internal DynamicType AsDynamicType ( )
94
97
{
95
- return new DynamicType ( this ) ;
98
+ return new DynamicType ( THSJIT_typeCast ( handle ) ) ;
96
99
}
97
100
98
101
internal enum TypeKind : sbyte
You can’t perform that action at this time.
0 commit comments