@@ -158,15 +158,15 @@ pub struct TVMContext {
158
158
/// Supported device types
159
159
pub device_type : TVMDeviceType ,
160
160
/// Device id
161
- pub device_id : usize ,
161
+ pub device_id : i32 ,
162
162
}
163
163
164
164
impl TVMContext {
165
165
/// Creates context from device type and id.
166
- pub fn new ( device_type : TVMDeviceType , device_id : usize ) -> Self {
166
+ pub fn new ( device_type : TVMDeviceType , device_id : i32 ) -> Self {
167
167
TVMContext {
168
- device_type : device_type ,
169
- device_id : device_id ,
168
+ device_type,
169
+ device_id,
170
170
}
171
171
}
172
172
}
@@ -175,7 +175,7 @@ macro_rules! impl_ctxs {
175
175
( $( ( $ctx: ident, $dldevt: expr) ) ;+) => {
176
176
$(
177
177
impl TVMContext {
178
- pub fn $ctx( device_id: usize ) -> Self {
178
+ pub fn $ctx( device_id: i32 ) -> Self {
179
179
Self :: new( TVMDeviceType ( $dldevt) , device_id)
180
180
}
181
181
}
@@ -238,7 +238,7 @@ macro_rules! impl_device_attrs {
238
238
// `unwrap` is ok here because if there is any error,
239
239
// if would occur in function call.
240
240
function:: Builder :: from( func)
241
- . args( & [ dt, self . device_id, $attr_kind] )
241
+ . args( & [ dt, self . device_id as usize , $attr_kind] )
242
242
. invoke( )
243
243
. unwrap( )
244
244
. try_into( )
@@ -262,7 +262,7 @@ impl From<ffi::DLContext> for TVMContext {
262
262
fn from ( ctx : ffi:: DLContext ) -> Self {
263
263
TVMContext {
264
264
device_type : TVMDeviceType :: from ( ctx. device_type ) ,
265
- device_id : ctx. device_id as usize ,
265
+ device_id : ctx. device_id ,
266
266
}
267
267
}
268
268
}
0 commit comments