pub struct GraphCompileOptions { /* private fields */ }Expand description
Owned BNNS Graph compile-options handle backed by the Swift bridge.
Implementations§
Source§impl GraphCompileOptions
impl GraphCompileOptions
Sourcepub fn new() -> Option<Self>
pub fn new() -> Option<Self>
Examples found in repository?
examples/06_bnns_activation.rs (line 16)
5fn main() {
6 let relu = bnns_relu_f32(&[-2.0_f32, 0.5, 3.0]).expect("relu");
7 assert!(relu
8 .iter()
9 .zip([0.0_f32, 0.5, 3.0])
10 .all(|(actual, expected)| (*actual - expected).abs() < 1.0e-6));
11
12 let sigmoid = bnns_sigmoid_f32(&[0.0_f32, 2.0]).expect("sigmoid");
13 assert!((sigmoid[0] - 0.5).abs() < 1.0e-6);
14 assert!((sigmoid[1] - 0.880_797).abs() < 1.0e-5);
15
16 if let Some(mut options) = BnnsGraphCompileOptions::new() {
17 options
18 .set_target_single_thread(true)
19 .expect("single thread");
20 options
21 .set_generate_debug_info(true)
22 .expect("debug info");
23 options
24 .set_optimization_preference(bnns_graph_optimization_preference::IR_SIZE)
25 .expect("optimization preference");
26 assert!(options.target_single_thread());
27 assert!(options.generate_debug_info());
28 assert_eq!(
29 options.optimization_preference(),
30 bnns_graph_optimization_preference::IR_SIZE
31 );
32 }
33
34 println!("bnns smoke passed: relu={relu:?} sigmoid={sigmoid:?}");
35}Sourcepub fn set_target_single_thread(&mut self, value: bool) -> Result<()>
pub fn set_target_single_thread(&mut self, value: bool) -> Result<()>
Examples found in repository?
examples/06_bnns_activation.rs (line 18)
5fn main() {
6 let relu = bnns_relu_f32(&[-2.0_f32, 0.5, 3.0]).expect("relu");
7 assert!(relu
8 .iter()
9 .zip([0.0_f32, 0.5, 3.0])
10 .all(|(actual, expected)| (*actual - expected).abs() < 1.0e-6));
11
12 let sigmoid = bnns_sigmoid_f32(&[0.0_f32, 2.0]).expect("sigmoid");
13 assert!((sigmoid[0] - 0.5).abs() < 1.0e-6);
14 assert!((sigmoid[1] - 0.880_797).abs() < 1.0e-5);
15
16 if let Some(mut options) = BnnsGraphCompileOptions::new() {
17 options
18 .set_target_single_thread(true)
19 .expect("single thread");
20 options
21 .set_generate_debug_info(true)
22 .expect("debug info");
23 options
24 .set_optimization_preference(bnns_graph_optimization_preference::IR_SIZE)
25 .expect("optimization preference");
26 assert!(options.target_single_thread());
27 assert!(options.generate_debug_info());
28 assert_eq!(
29 options.optimization_preference(),
30 bnns_graph_optimization_preference::IR_SIZE
31 );
32 }
33
34 println!("bnns smoke passed: relu={relu:?} sigmoid={sigmoid:?}");
35}Sourcepub fn target_single_thread(&self) -> bool
pub fn target_single_thread(&self) -> bool
Examples found in repository?
examples/06_bnns_activation.rs (line 26)
5fn main() {
6 let relu = bnns_relu_f32(&[-2.0_f32, 0.5, 3.0]).expect("relu");
7 assert!(relu
8 .iter()
9 .zip([0.0_f32, 0.5, 3.0])
10 .all(|(actual, expected)| (*actual - expected).abs() < 1.0e-6));
11
12 let sigmoid = bnns_sigmoid_f32(&[0.0_f32, 2.0]).expect("sigmoid");
13 assert!((sigmoid[0] - 0.5).abs() < 1.0e-6);
14 assert!((sigmoid[1] - 0.880_797).abs() < 1.0e-5);
15
16 if let Some(mut options) = BnnsGraphCompileOptions::new() {
17 options
18 .set_target_single_thread(true)
19 .expect("single thread");
20 options
21 .set_generate_debug_info(true)
22 .expect("debug info");
23 options
24 .set_optimization_preference(bnns_graph_optimization_preference::IR_SIZE)
25 .expect("optimization preference");
26 assert!(options.target_single_thread());
27 assert!(options.generate_debug_info());
28 assert_eq!(
29 options.optimization_preference(),
30 bnns_graph_optimization_preference::IR_SIZE
31 );
32 }
33
34 println!("bnns smoke passed: relu={relu:?} sigmoid={sigmoid:?}");
35}Sourcepub fn set_generate_debug_info(&mut self, value: bool) -> Result<()>
pub fn set_generate_debug_info(&mut self, value: bool) -> Result<()>
Examples found in repository?
examples/06_bnns_activation.rs (line 21)
5fn main() {
6 let relu = bnns_relu_f32(&[-2.0_f32, 0.5, 3.0]).expect("relu");
7 assert!(relu
8 .iter()
9 .zip([0.0_f32, 0.5, 3.0])
10 .all(|(actual, expected)| (*actual - expected).abs() < 1.0e-6));
11
12 let sigmoid = bnns_sigmoid_f32(&[0.0_f32, 2.0]).expect("sigmoid");
13 assert!((sigmoid[0] - 0.5).abs() < 1.0e-6);
14 assert!((sigmoid[1] - 0.880_797).abs() < 1.0e-5);
15
16 if let Some(mut options) = BnnsGraphCompileOptions::new() {
17 options
18 .set_target_single_thread(true)
19 .expect("single thread");
20 options
21 .set_generate_debug_info(true)
22 .expect("debug info");
23 options
24 .set_optimization_preference(bnns_graph_optimization_preference::IR_SIZE)
25 .expect("optimization preference");
26 assert!(options.target_single_thread());
27 assert!(options.generate_debug_info());
28 assert_eq!(
29 options.optimization_preference(),
30 bnns_graph_optimization_preference::IR_SIZE
31 );
32 }
33
34 println!("bnns smoke passed: relu={relu:?} sigmoid={sigmoid:?}");
35}Sourcepub fn generate_debug_info(&self) -> bool
pub fn generate_debug_info(&self) -> bool
Examples found in repository?
examples/06_bnns_activation.rs (line 27)
5fn main() {
6 let relu = bnns_relu_f32(&[-2.0_f32, 0.5, 3.0]).expect("relu");
7 assert!(relu
8 .iter()
9 .zip([0.0_f32, 0.5, 3.0])
10 .all(|(actual, expected)| (*actual - expected).abs() < 1.0e-6));
11
12 let sigmoid = bnns_sigmoid_f32(&[0.0_f32, 2.0]).expect("sigmoid");
13 assert!((sigmoid[0] - 0.5).abs() < 1.0e-6);
14 assert!((sigmoid[1] - 0.880_797).abs() < 1.0e-5);
15
16 if let Some(mut options) = BnnsGraphCompileOptions::new() {
17 options
18 .set_target_single_thread(true)
19 .expect("single thread");
20 options
21 .set_generate_debug_info(true)
22 .expect("debug info");
23 options
24 .set_optimization_preference(bnns_graph_optimization_preference::IR_SIZE)
25 .expect("optimization preference");
26 assert!(options.target_single_thread());
27 assert!(options.generate_debug_info());
28 assert_eq!(
29 options.optimization_preference(),
30 bnns_graph_optimization_preference::IR_SIZE
31 );
32 }
33
34 println!("bnns smoke passed: relu={relu:?} sigmoid={sigmoid:?}");
35}Sourcepub fn set_optimization_preference(&mut self, preference: u32) -> Result<()>
pub fn set_optimization_preference(&mut self, preference: u32) -> Result<()>
Examples found in repository?
examples/06_bnns_activation.rs (line 24)
5fn main() {
6 let relu = bnns_relu_f32(&[-2.0_f32, 0.5, 3.0]).expect("relu");
7 assert!(relu
8 .iter()
9 .zip([0.0_f32, 0.5, 3.0])
10 .all(|(actual, expected)| (*actual - expected).abs() < 1.0e-6));
11
12 let sigmoid = bnns_sigmoid_f32(&[0.0_f32, 2.0]).expect("sigmoid");
13 assert!((sigmoid[0] - 0.5).abs() < 1.0e-6);
14 assert!((sigmoid[1] - 0.880_797).abs() < 1.0e-5);
15
16 if let Some(mut options) = BnnsGraphCompileOptions::new() {
17 options
18 .set_target_single_thread(true)
19 .expect("single thread");
20 options
21 .set_generate_debug_info(true)
22 .expect("debug info");
23 options
24 .set_optimization_preference(bnns_graph_optimization_preference::IR_SIZE)
25 .expect("optimization preference");
26 assert!(options.target_single_thread());
27 assert!(options.generate_debug_info());
28 assert_eq!(
29 options.optimization_preference(),
30 bnns_graph_optimization_preference::IR_SIZE
31 );
32 }
33
34 println!("bnns smoke passed: relu={relu:?} sigmoid={sigmoid:?}");
35}Sourcepub fn optimization_preference(&self) -> u32
pub fn optimization_preference(&self) -> u32
Examples found in repository?
examples/06_bnns_activation.rs (line 29)
5fn main() {
6 let relu = bnns_relu_f32(&[-2.0_f32, 0.5, 3.0]).expect("relu");
7 assert!(relu
8 .iter()
9 .zip([0.0_f32, 0.5, 3.0])
10 .all(|(actual, expected)| (*actual - expected).abs() < 1.0e-6));
11
12 let sigmoid = bnns_sigmoid_f32(&[0.0_f32, 2.0]).expect("sigmoid");
13 assert!((sigmoid[0] - 0.5).abs() < 1.0e-6);
14 assert!((sigmoid[1] - 0.880_797).abs() < 1.0e-5);
15
16 if let Some(mut options) = BnnsGraphCompileOptions::new() {
17 options
18 .set_target_single_thread(true)
19 .expect("single thread");
20 options
21 .set_generate_debug_info(true)
22 .expect("debug info");
23 options
24 .set_optimization_preference(bnns_graph_optimization_preference::IR_SIZE)
25 .expect("optimization preference");
26 assert!(options.target_single_thread());
27 assert!(options.generate_debug_info());
28 assert_eq!(
29 options.optimization_preference(),
30 bnns_graph_optimization_preference::IR_SIZE
31 );
32 }
33
34 println!("bnns smoke passed: relu={relu:?} sigmoid={sigmoid:?}");
35}Trait Implementations§
Source§impl Drop for GraphCompileOptions
impl Drop for GraphCompileOptions
impl Send for GraphCompileOptions
impl Sync for GraphCompileOptions
Auto Trait Implementations§
impl Freeze for GraphCompileOptions
impl RefUnwindSafe for GraphCompileOptions
impl Unpin for GraphCompileOptions
impl UnsafeUnpin for GraphCompileOptions
impl UnwindSafe for GraphCompileOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more