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
#![allow(clippy::large_enum_variant)]
include!(concat!(env!("OUT_DIR"), "/tensorflow_proto_gen.rs"));
#[cfg(test)]
mod tests {
#[cfg(feature = "serde-derive")]
mod serde {
use crate::tensorflow;
#[test]
fn test_serde_roundtrip() {
let config_proto = tensorflow::ConfigProto {
gpu_options: Some(tensorflow::GpuOptions {
allow_growth: true,
..Default::default()
}),
..Default::default()
};
let js = serde_json::to_string(&config_proto).unwrap();
let result: tensorflow::ConfigProto = serde_json::from_str(&js).unwrap();
assert_eq!(config_proto, result);
}
#[test]
fn test_deser_with_defaults() {
let config_proto = tensorflow::ConfigProto {
gpu_options: Some(tensorflow::GpuOptions {
allow_growth: true,
..Default::default()
}),
..Default::default()
};
let js = r#"{"gpu_options": {"allow_growth": true}}"#;
let result: tensorflow::ConfigProto = serde_json::from_str(js).unwrap();
assert_eq!(config_proto, result);
}
}
#[cfg(feature = "convert")]
mod convert {
use crate::tensorflow;
use std::convert::{TryFrom, TryInto};
#[test]
fn test_try_from_message() {
let config_proto = tensorflow::ConfigProto {
gpu_options: Some(tensorflow::GpuOptions {
allow_growth: true,
..Default::default()
}),
..Default::default()
};
let bytes = Vec::try_from(&config_proto).unwrap();
assert!(!bytes.is_empty());
}
#[test]
fn test_try_into_bytes() {
let config_proto = tensorflow::ConfigProto {
gpu_options: Some(tensorflow::GpuOptions {
allow_growth: true,
..Default::default()
}),
..Default::default()
};
let r = &config_proto;
let bytes: Vec<_> = r.try_into().unwrap();
assert!(!bytes.is_empty());
}
}
}