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
//! Interface to [TensorFlow][1].
//!
//! [1]: https://www.tensorflow.org
//!
//! ## Example
//!
//! Create a graph in Python:
//!
//! ```python
//! import tensorflow as tf
//!
//! a = tf.placeholder(tf.float32, name='a')
//! b = tf.placeholder(tf.float32, name='b')
//! c = tf.mul(a, b, name='c')
//!
//! tf.train.write_graph(tf.Session().graph_def, '', 'graph.pb', as_text=False)
//! ```
//!
//! Evaluate the graph in Rust:
//!
//! ```
//! use tensorflux::{Buffer, Input, Options, Output, Session, Tensor};
//!
//! macro_rules! ok(($result:expr) => ($result.unwrap()));
//!
//! let graph = "graph.pb"; // c = a * b
//! # let graph = "examples/assets/multiplication.pb";
//! let mut session = ok!(Session::new(&ok!(Options::new())));
//! ok!(session.extend(&ok!(Buffer::load(graph))));
//!
//! let a = ok!(Tensor::new(vec![1f32, 2.0, 3.0], &[3]));
//! let b = ok!(Tensor::new(vec![4f32, 5.0, 6.0], &[3]));
//!
//! let inputs = vec![Input::new("a", a), Input::new("b", b)];
//! let mut outputs = vec![Output::new("c")];
//! ok!(session.run(&inputs, &mut outputs, &[], None, None));
//!
//! let c = ok!(outputs[0].get::<f32>());
//! assert_eq!(&c[..], &[1.0 * 4.0, 2.0 * 5.0, 3.0 * 6.0]);
//! ```
extern crate libc;
extern crate tensorflux_sys as ffi;
extern crate num_complex as num;
pub use Buffer;
pub use Error;
pub use Library;
pub use Options;
pub use ;
pub use Tensor;
pub use Value;
/// A result.
pub type Result<T> = Result;
/// A complex number with 32-bit parts.
pub type c32 = Complex;
/// A complex number with 64-bit parts.
pub type c64 = Complex;