graph_construction/
graph_construction.rs1extern crate deep_core as core;
2
3use core::{
4 graph::{GraphBuilder, TensorDescriptor},
5 operations::{
6 add,
7 dot,
8 leaky_relu
9 },
10};
11
12fn main() {
13 let input_descriptor = TensorDescriptor::create(0).with_shape((3, ));
16 let input_node_id = 0;
17
18 let weights_descriptor = TensorDescriptor::create(1).with_shape((3, 3));
19 let weights_node_id = 1;
20
21 let bias_descriptor = TensorDescriptor::create(2).with_shape((3, ));
22 let bias_node_id = 2;
23
24 let dot_node_id = 1;
25 let add_node_id = 2;
26 let leaky_node_id = 3;
27
28 let graph = GraphBuilder::create()
33 .with_input(input_node_id, input_descriptor)
34 .with_parameter(weights_node_id, weights_descriptor)
35 .with_parameter(bias_node_id, bias_descriptor)
36 .with_operation(dot_node_id, dot::operation())
37 .with_operation(add_node_id, add::operation())
38 .with_operation(leaky_node_id, leaky_relu::operation(0.57))
39 .with_operand(0, input_node_id, dot_node_id, dot::operands::input())
40 .with_operand(1, weights_node_id, dot_node_id, dot::operands::weights())
41 .with_operand(2, dot_node_id, add_node_id, add::operands::input())
42 .with_operand(3, bias_node_id, add_node_id, add::operands::input())
43 .with_operand(4, add_node_id, leaky_node_id, leaky_relu::operands::input())
44 .build(0);
45
46 println!("{:#?}", graph);
47}