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
cpp! {{
  #include <CNTKLibrary.h>
  #include <cstdio>
  #include <vector>

  using namespace CNTK;
  using namespace std;
}}

type DeviceDescriptorInner = [u32; 2usize];

#[derive(Copy, Clone)]
pub struct DeviceDescriptor {
    pub(super) payload: DeviceDescriptorInner
}

impl DeviceDescriptor {
    pub fn cpu() -> DeviceDescriptor {
        DeviceDescriptor {
            payload: unsafe {
                    cpp!([] -> DeviceDescriptorInner as "DeviceDescriptor" {
                    return DeviceDescriptor::CPUDevice();
                })
            }
        }
    }
}

pub fn set_max_num_cpu_threads(num: usize) {
    unsafe {
        cpp!([num as "size_t"] {
            SetMaxNumCPUThreads(num);
        })
    }
}