hanzo-rocm 0.5.2

Rust bindings for AMD ROCm libraries
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
// src/miopen/convolution.rs

use crate::miopen::error::{Error, Result};
use crate::miopen::ffi;
use crate::miopen::handle::Handle;
use crate::miopen::tensor::TensorDescriptor;
use std::os::raw::c_void;
use std::ptr;

/// Convolution mode
pub type ConvolutionMode = ffi::miopenConvolutionMode_t;

/// Convolution forward algorithm
pub type ConvFwdAlgorithm = ffi::miopenConvFwdAlgorithm_t;

/// Convolution backward data algorithm
pub type ConvBwdDataAlgorithm = ffi::miopenConvBwdDataAlgorithm_t;

/// Convolution backward weights algorithm
pub type ConvBwdWeightsAlgorithm = ffi::miopenConvBwdWeightsAlgorithm_t;

/// General convolution algorithm
pub type ConvAlgorithm = ffi::miopenConvAlgorithm_t;

/// Padding mode
pub type PaddingMode = ffi::miopenPaddingMode_t;

/// Convolution attribute
pub type ConvolutionAttribute = ffi::miopenConvolutionAttrib_t;

/// Performance result for convolution algorithms
pub type ConvolutionPerf = ffi::miopenConvAlgoPerf_t;

/// Safe wrapper for MIOpen convolution descriptor
pub struct ConvolutionDescriptor {
    desc: ffi::miopenConvolutionDescriptor_t,
}

impl ConvolutionDescriptor {
    /// Create a new convolution descriptor
    pub fn new() -> Result<Self> {
        let mut desc = ptr::null_mut();
        let status = unsafe { ffi::miopenCreateConvolutionDescriptor(&mut desc) };

        if status != ffi::miopenStatus_t_miopenStatusSuccess {
            return Err(Error::new(status));
        }

        Ok(Self { desc })
    }

    /// Initialize a 2D convolution descriptor
    pub fn init_2d(
        &mut self,
        c_mode: ConvolutionMode,
        pad_h: i32,
        pad_w: i32,
        stride_h: i32,
        stride_w: i32,
        dilation_h: i32,
        dilation_w: i32,
    ) -> Result<()> {
        let status = unsafe {
            ffi::miopenInitConvolutionDescriptor(
                self.desc, c_mode, pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w,
            )
        };

        if status != ffi::miopenStatus_t_miopenStatusSuccess {
            return Err(Error::new(status));
        }

        Ok(())
    }

    /// Initialize an N-dimensional convolution descriptor
    pub fn init_nd(
        &mut self,
        padA: &[i32],
        strideA: &[i32],
        dilationA: &[i32],
        c_mode: ConvolutionMode,
    ) -> Result<()> {
        let spatial_dim = padA.len() as i32;

        if spatial_dim as usize != strideA.len() || spatial_dim as usize != dilationA.len() {
            return Err(Error::new(ffi::miopenStatus_t_miopenStatusBadParm));
        }

        let status = unsafe {
            ffi::miopenInitConvolutionNdDescriptor(
                self.desc,
                spatial_dim,
                padA.as_ptr(),
                strideA.as_ptr(),
                dilationA.as_ptr(),
                c_mode,
            )
        };

        if status != ffi::miopenStatus_t_miopenStatusSuccess {
            return Err(Error::new(status));
        }

        Ok(())
    }

    /// Get the spatial dimension of the convolution descriptor
    pub fn get_spatial_dim(&self) -> Result<i32> {
        let mut spatial_dim = 0;

        let status = unsafe { ffi::miopenGetConvolutionSpatialDim(self.desc, &mut spatial_dim) };

        if status != ffi::miopenStatus_t_miopenStatusSuccess {
            return Err(Error::new(status));
        }

        Ok(spatial_dim)
    }

    /// Get the details of a 2D convolution descriptor
    pub fn get_2d(&self) -> Result<(ConvolutionMode, i32, i32, i32, i32, i32, i32)> {
        let mut c_mode = 0;
        let mut pad_h = 0;
        let mut pad_w = 0;
        let mut stride_h = 0;
        let mut stride_w = 0;
        let mut dilation_h = 0;
        let mut dilation_w = 0;

        let status = unsafe {
            ffi::miopenGetConvolutionDescriptor(
                self.desc,
                &mut c_mode,
                &mut pad_h,
                &mut pad_w,
                &mut stride_h,
                &mut stride_w,
                &mut dilation_h,
                &mut dilation_w,
            )
        };

        if status != ffi::miopenStatus_t_miopenStatusSuccess {
            return Err(Error::new(status));
        }

        Ok((
            c_mode, pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w,
        ))
    }

    /// Get the details of an N-dimensional convolution descriptor
    pub fn get_nd(
        &self,
        requested_spatial_dim: i32,
    ) -> Result<(i32, Vec<i32>, Vec<i32>, Vec<i32>, ConvolutionMode)> {
        let mut spatial_dim = 0;
        let mut padA = vec![0; requested_spatial_dim as usize];
        let mut strideA = vec![0; requested_spatial_dim as usize];
        let mut dilationA = vec![0; requested_spatial_dim as usize];
        let mut c_mode = 0;

        let status = unsafe {
            ffi::miopenGetConvolutionNdDescriptor(
                self.desc,
                requested_spatial_dim,
                &mut spatial_dim,
                padA.as_mut_ptr(),
                strideA.as_mut_ptr(),
                dilationA.as_mut_ptr(),
                &mut c_mode,
            )
        };

        if status != ffi::miopenStatus_t_miopenStatusSuccess {
            return Err(Error::new(status));
        }

        Ok((spatial_dim, padA, strideA, dilationA, c_mode))
    }

    /// Get the number of groups for group/depthwise convolution
    pub fn get_group_count(&self) -> Result<i32> {
        let mut group_count = 0;

        let status = unsafe { ffi::miopenGetConvolutionGroupCount(self.desc, &mut group_count) };

        if status != ffi::miopenStatus_t_miopenStatusSuccess {
            return Err(Error::new(status));
        }

        Ok(group_count)
    }

    /// Set the number of groups for group/depthwise convolution
    pub fn set_group_count(&mut self, group_count: i32) -> Result<()> {
        let status = unsafe { ffi::miopenSetConvolutionGroupCount(self.desc, group_count) };

        if status != ffi::miopenStatus_t_miopenStatusSuccess {
            return Err(Error::new(status));
        }

        Ok(())
    }

    /// Set output padding for 2D transpose convolution
    pub fn set_transpose_conv_output_padding(&mut self, adj_h: i32, adj_w: i32) -> Result<()> {
        let status = unsafe { ffi::miopenSetTransposeConvOutputPadding(self.desc, adj_h, adj_w) };

        if status != ffi::miopenStatus_t_miopenStatusSuccess {
            return Err(Error::new(status));
        }

        Ok(())
    }

    /// Set output padding for N-dimensional transpose convolution
    pub fn set_transpose_conv_nd_output_padding(&mut self, adjA: &[i32]) -> Result<()> {
        let spatial_dim = adjA.len() as i32;

        let status = unsafe {
            ffi::miopenSetTransposeConvNdOutputPadding(self.desc, spatial_dim, adjA.as_ptr())
        };

        if status != ffi::miopenStatus_t_miopenStatusSuccess {
            return Err(Error::new(status));
        }

        Ok(())
    }

    /// Get the output dimensions of a 2D convolution
    pub fn get_forward_output_dim(
        &self,
        input_desc: &TensorDescriptor,
        filter_desc: &TensorDescriptor,
    ) -> Result<(i32, i32, i32, i32)> {
        let mut n = 0;
        let mut c = 0;
        let mut h = 0;
        let mut w = 0;

        let status = unsafe {
            ffi::miopenGetConvolutionForwardOutputDim(
                self.desc,
                input_desc.as_raw(),
                filter_desc.as_raw(),
                &mut n,
                &mut c,
                &mut h,
                &mut w,
            )
        };

        if status != ffi::miopenStatus_t_miopenStatusSuccess {
            return Err(Error::new(status));
        }

        Ok((n, c, h, w))
    }

    /// Get the output dimensions of an N-dimensional convolution
    pub fn get_nd_forward_output_dim(
        &self,
        input_desc: &TensorDescriptor,
        filter_desc: &TensorDescriptor,
        dims_capacity: usize,
    ) -> Result<(i32, Vec<i32>)> {
        let mut n_dim = 0;
        let mut output_dims = vec![0; dims_capacity];

        let status = unsafe {
            ffi::miopenGetConvolutionNdForwardOutputDim(
                self.desc,
                input_desc.as_raw(),
                filter_desc.as_raw(),
                &mut n_dim,
                output_dims.as_mut_ptr(),
            )
        };

        if status != ffi::miopenStatus_t_miopenStatusSuccess {
            return Err(Error::new(status));
        }

        Ok((n_dim, output_dims))
    }

    /// Set an attribute for the convolution descriptor
    pub fn set_attribute(&mut self, attr: ConvolutionAttribute, value: i32) -> Result<()> {
        let status = unsafe { ffi::miopenSetConvolutionAttribute(self.desc, attr, value) };

        if status != ffi::miopenStatus_t_miopenStatusSuccess {
            return Err(Error::new(status));
        }

        Ok(())
    }

    /// Get an attribute from the convolution descriptor
    pub fn get_attribute(&self, attr: ConvolutionAttribute) -> Result<i32> {
        let mut value = 0;

        let status = unsafe { ffi::miopenGetConvolutionAttribute(self.desc, attr, &mut value) };

        if status != ffi::miopenStatus_t_miopenStatusSuccess {
            return Err(Error::new(status));
        }

        Ok(value)
    }

    /// Get the raw descriptor
    pub fn as_raw(&self) -> ffi::miopenConvolutionDescriptor_t {
        self.desc
    }
}

impl Drop for ConvolutionDescriptor {
    fn drop(&mut self) {
        if !self.desc.is_null() {
            unsafe {
                let _ = ffi::miopenDestroyConvolutionDescriptor(self.desc);
                // We cannot handle errors in drop, so just ignore the result
            };
            self.desc = ptr::null_mut();
        }
    }
}

/// Query the workspace size required for a forward convolution algorithm
pub fn get_convolution_forward_workspace_size(
    handle: &Handle,
    w_desc: &TensorDescriptor,
    x_desc: &TensorDescriptor,
    conv_desc: &ConvolutionDescriptor,
    y_desc: &TensorDescriptor,
) -> Result<usize> {
    let mut workspace_size = 0;

    let status = unsafe {
        ffi::miopenConvolutionForwardGetWorkSpaceSize(
            handle.as_raw(),
            w_desc.as_raw(),
            x_desc.as_raw(),
            conv_desc.as_raw(),
            y_desc.as_raw(),
            &mut workspace_size,
        )
    };

    if status != ffi::miopenStatus_t_miopenStatusSuccess {
        return Err(Error::new(status));
    }

    Ok(workspace_size)
}

/// Search for the fastest convolution forward algorithm
pub unsafe fn find_convolution_forward_algorithm(
    handle: &Handle,
    x_desc: &TensorDescriptor,
    x: *const c_void,
    w_desc: &TensorDescriptor,
    w: *const c_void,
    conv_desc: &ConvolutionDescriptor,
    y_desc: &TensorDescriptor,
    y: *mut c_void,
    request_algo_count: i32,
    workspace: *mut c_void,
    workspace_size: usize,
    exhaustive_search: bool,
) -> Result<(i32, Vec<ConvolutionPerf>)> {
    let mut returned_algo_count = 0;
    let mut perf_results = vec![unsafe { std::mem::zeroed() }; request_algo_count as usize];

    let status = unsafe {
        ffi::miopenFindConvolutionForwardAlgorithm(
            handle.as_raw(),
            x_desc.as_raw(),
            x,
            w_desc.as_raw(),
            w,
            conv_desc.as_raw(),
            y_desc.as_raw(),
            y,
            request_algo_count,
            &mut returned_algo_count,
            perf_results.as_mut_ptr(),
            workspace,
            workspace_size,
            exhaustive_search,
        )
    };

    if status != ffi::miopenStatus_t_miopenStatusSuccess {
        return Err(Error::new(status));
    }

    perf_results.truncate(returned_algo_count as usize);
    Ok((returned_algo_count, perf_results))
}

/// Execute a forward convolution operation
pub unsafe fn convolution_forward(
    handle: &Handle,
    alpha: &[u8],
    x_desc: &TensorDescriptor,
    x: *const c_void,
    w_desc: &TensorDescriptor,
    w: *const c_void,
    conv_desc: &ConvolutionDescriptor,
    algo: ConvFwdAlgorithm,
    beta: &[u8],
    y_desc: &TensorDescriptor,
    y: *mut c_void,
    workspace: *mut c_void,
    workspace_size: usize,
) -> Result<()> {
    let status = unsafe {
        ffi::miopenConvolutionForward(
            handle.as_raw(),
            alpha.as_ptr() as *const c_void,
            x_desc.as_raw(),
            x,
            w_desc.as_raw(),
            w,
            conv_desc.as_raw(),
            algo,
            beta.as_ptr() as *const c_void,
            y_desc.as_raw(),
            y,
            workspace,
            workspace_size,
        )
    };

    if status != ffi::miopenStatus_t_miopenStatusSuccess {
        return Err(Error::new(status));
    }

    Ok(())
}

/// Apply element-wise bias to a tensor
pub unsafe fn convolution_forward_bias(
    handle: &Handle,
    alpha: &[u8],
    b_desc: &TensorDescriptor,
    b: *const c_void,
    beta: &[u8],
    y_desc: &TensorDescriptor,
    y: *mut c_void,
) -> Result<()> {
    let status = unsafe {
        ffi::miopenConvolutionForwardBias(
            handle.as_raw(),
            alpha.as_ptr() as *const c_void,
            b_desc.as_raw(),
            b,
            beta.as_ptr() as *const c_void,
            y_desc.as_raw(),
            y,
        )
    };

    if status != ffi::miopenStatus_t_miopenStatusSuccess {
        return Err(Error::new(status));
    }

    Ok(())
}

/// Query the workspace size required for a backward data convolution algorithm
pub fn get_convolution_backward_data_workspace_size(
    handle: &Handle,
    dy_desc: &TensorDescriptor,
    w_desc: &TensorDescriptor,
    conv_desc: &ConvolutionDescriptor,
    dx_desc: &TensorDescriptor,
) -> Result<usize> {
    let mut workspace_size = 0;

    let status = unsafe {
        ffi::miopenConvolutionBackwardDataGetWorkSpaceSize(
            handle.as_raw(),
            dy_desc.as_raw(),
            w_desc.as_raw(),
            conv_desc.as_raw(),
            dx_desc.as_raw(),
            &mut workspace_size,
        )
    };

    if status != ffi::miopenStatus_t_miopenStatusSuccess {
        return Err(Error::new(status));
    }

    Ok(workspace_size)
}

/// Search for the fastest convolution backward data algorithm
pub unsafe fn find_convolution_backward_data_algorithm(
    handle: &Handle,
    dy_desc: &TensorDescriptor,
    dy: *const c_void,
    w_desc: &TensorDescriptor,
    w: *const c_void,
    conv_desc: &ConvolutionDescriptor,
    dx_desc: &TensorDescriptor,
    dx: *mut c_void,
    request_algo_count: i32,
    workspace: *mut c_void,
    workspace_size: usize,
    exhaustive_search: bool,
) -> Result<(i32, Vec<ConvolutionPerf>)> {
    let mut returned_algo_count = 0;
    let mut perf_results = vec![unsafe { std::mem::zeroed() }; request_algo_count as usize];

    let status = unsafe {
        ffi::miopenFindConvolutionBackwardDataAlgorithm(
            handle.as_raw(),
            dy_desc.as_raw(),
            dy,
            w_desc.as_raw(),
            w,
            conv_desc.as_raw(),
            dx_desc.as_raw(),
            dx,
            request_algo_count,
            &mut returned_algo_count,
            perf_results.as_mut_ptr(),
            workspace,
            workspace_size,
            exhaustive_search,
        )
    };

    if status != ffi::miopenStatus_t_miopenStatusSuccess {
        return Err(Error::new(status));
    }

    perf_results.truncate(returned_algo_count as usize);
    Ok((returned_algo_count, perf_results))
}

/// Execute a backward data convolution operation
pub unsafe fn convolution_backward_data(
    handle: &Handle,
    alpha: &[u8],
    dy_desc: &TensorDescriptor,
    dy: *const c_void,
    w_desc: &TensorDescriptor,
    w: *const c_void,
    conv_desc: &ConvolutionDescriptor,
    algo: ConvBwdDataAlgorithm,
    beta: &[u8],
    dx_desc: &TensorDescriptor,
    dx: *mut c_void,
    workspace: *mut c_void,
    workspace_size: usize,
) -> Result<()> {
    let status = unsafe {
        ffi::miopenConvolutionBackwardData(
            handle.as_raw(),
            alpha.as_ptr() as *const c_void,
            dy_desc.as_raw(),
            dy,
            w_desc.as_raw(),
            w,
            conv_desc.as_raw(),
            algo,
            beta.as_ptr() as *const c_void,
            dx_desc.as_raw(),
            dx,
            workspace,
            workspace_size,
        )
    };

    if status != ffi::miopenStatus_t_miopenStatusSuccess {
        return Err(Error::new(status));
    }

    Ok(())
}

/// Get the GPU memory required for the backward weights convolution algorithm
pub fn get_convolution_backward_weights_workspace_size(
    handle: &Handle,
    dy_desc: &TensorDescriptor,
    x_desc: &TensorDescriptor,
    conv_desc: &ConvolutionDescriptor,
    dw_desc: &TensorDescriptor,
) -> Result<usize> {
    let mut workspace_size = 0;

    let status = unsafe {
        ffi::miopenConvolutionBackwardWeightsGetWorkSpaceSize(
            handle.as_raw(),
            dy_desc.as_raw(),
            x_desc.as_raw(),
            conv_desc.as_raw(),
            dw_desc.as_raw(),
            &mut workspace_size,
        )
    };

    if status != ffi::miopenStatus_t_miopenStatusSuccess {
        return Err(Error::new(status));
    }

    Ok(workspace_size)
}

/// Search for the fastest convolution backward weights algorithm
pub unsafe fn find_convolution_backward_weights_algorithm(
    handle: &Handle,
    dy_desc: &TensorDescriptor,
    dy: *const c_void,
    x_desc: &TensorDescriptor,
    x: *const c_void,
    conv_desc: &ConvolutionDescriptor,
    dw_desc: &TensorDescriptor,
    dw: *mut c_void,
    request_algo_count: i32,
    workspace: *mut c_void,
    workspace_size: usize,
    exhaustive_search: bool,
) -> Result<(i32, Vec<ConvolutionPerf>)> {
    let mut returned_algo_count = 0;
    let mut perf_results = vec![unsafe { std::mem::zeroed() }; request_algo_count as usize];

    let status = unsafe {
        ffi::miopenFindConvolutionBackwardWeightsAlgorithm(
            handle.as_raw(),
            dy_desc.as_raw(),
            dy,
            x_desc.as_raw(),
            x,
            conv_desc.as_raw(),
            dw_desc.as_raw(),
            dw,
            request_algo_count,
            &mut returned_algo_count,
            perf_results.as_mut_ptr(),
            workspace,
            workspace_size,
            exhaustive_search,
        )
    };

    if status != ffi::miopenStatus_t_miopenStatusSuccess {
        return Err(Error::new(status));
    }

    perf_results.truncate(returned_algo_count as usize);
    Ok((returned_algo_count, perf_results))
}

/// Execute a backward weights convolution operation
pub unsafe fn convolution_backward_weights(
    handle: &Handle,
    alpha: &[u8],
    dy_desc: &TensorDescriptor,
    dy: *const c_void,
    x_desc: &TensorDescriptor,
    x: *const c_void,
    conv_desc: &ConvolutionDescriptor,
    algo: ConvBwdWeightsAlgorithm,
    beta: &[u8],
    dw_desc: &TensorDescriptor,
    dw: *mut c_void,
    workspace: *mut c_void,
    workspace_size: usize,
) -> Result<()> {
    let status = unsafe {
        ffi::miopenConvolutionBackwardWeights(
            handle.as_raw(),
            alpha.as_ptr() as *const c_void,
            dy_desc.as_raw(),
            dy,
            x_desc.as_raw(),
            x,
            conv_desc.as_raw(),
            algo,
            beta.as_ptr() as *const c_void,
            dw_desc.as_raw(),
            dw,
            workspace,
            workspace_size,
        )
    };

    if status != ffi::miopenStatus_t_miopenStatusSuccess {
        return Err(Error::new(status));
    }

    Ok(())
}

/// Calculates the gradient with respect to the bias
pub unsafe fn convolution_backward_bias(
    handle: &Handle,
    alpha: &[u8],
    dy_desc: &TensorDescriptor,
    dy: *const c_void,
    beta: &[u8],
    db_desc: &TensorDescriptor,
    db: *mut c_void,
) -> Result<()> {
    let status = unsafe {
        ffi::miopenConvolutionBackwardBias(
            handle.as_raw(),
            alpha.as_ptr() as *const c_void,
            dy_desc.as_raw(),
            dy,
            beta.as_ptr() as *const c_void,
            db_desc.as_raw(),
            db,
        )
    };

    if status != ffi::miopenStatus_t_miopenStatusSuccess {
        return Err(Error::new(status));
    }

    Ok(())
}