Skip to content

Commit e90b26e

Browse files
committed
rename target operation name
1 parent bede4e9 commit e90b26e

3 files changed

Lines changed: 3 additions & 10 deletions

File tree

examples/addition.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ use tensorflow::SessionRunArgs;
1212
use tensorflow::Status;
1313
use tensorflow::Tensor;
1414

15-
#[cfg_attr(feature = "examples_system_alloc", global_allocator)]
16-
#[cfg(feature = "examples_system_alloc")]
17-
static ALLOCATOR: std::alloc::System = std::alloc::System;
18-
1915
fn main() -> Result<(), Box<dyn Error>> {
2016
let filename = "examples/addition/model.pb"; // z = x + y
2117
if !Path::new(filename).exists() {
@@ -49,7 +45,7 @@ fn main() -> Result<(), Box<dyn Error>> {
4945
let mut args = SessionRunArgs::new();
5046
args.add_feed(&graph.operation_by_name_required("x")?, 0, &x);
5147
args.add_feed(&graph.operation_by_name_required("y")?, 0, &y);
52-
let z = args.request_fetch(&graph.operation_by_name_required("Identity")?, 0);
48+
let z = args.request_fetch(&graph.operation_by_name_required("z")?, 0);
5349
session.run(&mut args)?;
5450

5551
// Check our results.

examples/addition/addition.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,16 @@
77

88
@tf.function
99
def add(x, y):
10-
return tf.add(x, y)
10+
tf.add(x, y, name="z")
1111

1212

1313
x = tf.TensorSpec((), dtype=tf.dtypes.int32, name="x")
1414
y = tf.TensorSpec((), dtype=tf.dtypes.int32, name="y")
15+
1516
concrete_function = add.get_concrete_function(x, y)
1617
directory = "examples/addition"
1718
tf.io.write_graph(concrete_function.graph, directory, "model.pb", as_text=False)
1819

19-
# check inputs/outputs node names to refer from Rust later on
20-
print(f"input nodes : {concrete_function.inputs}")
21-
print(f"output nodes : {concrete_function.outputs}")
22-
2320
logdir = "logs/addition"
2421
writer = tf.summary.create_file_writer(logdir)
2522
with writer.as_default():

examples/addition/model.pb

-38 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)