Skip to content

Commit eabae11

Browse files
committed
TensorFlow protocol & bash script improvement
1. The update proposes improvements to a Bash script that runs a Rust application with multiple command line arguments. The suggested changes include adding comments, using variables for each argument, using double quotes for variables, using descriptive variable names, and adding a shebang for the Bash shell specifically. An updated script is provided as an example. 2. The protocol buffer file with version information for serialized data used in TensorFlow now defines a VersionDef message with fields for the producer version, minimum consumer version, and a list of disallowed consumer versions.
1 parent 834d053 commit eabae11

File tree

3 files changed

+101
-27
lines changed

3 files changed

+101
-27
lines changed

navi/navi/proto/tensorflow/core/framework/versions.proto

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@ syntax = "proto3";
22

33
package tensorflow;
44

5+
// Enable arenas for more efficient memory management
56
option cc_enable_arenas = true;
7+
8+
// Set the outer class name for generated Java code
69
option java_outer_classname = "VersionsProtos";
10+
11+
// Generate multiple Java files for the proto package
712
option java_multiple_files = true;
13+
14+
// Set the Java package name for generated code
815
option java_package = "org.tensorflow.framework";
16+
17+
// Set the Go package name for generated code
918
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/versions_go_proto";
1019

1120
// Version information for a piece of serialized data
@@ -14,20 +23,28 @@ option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framewo
1423
// (GraphDef, etc.), but they all have the same common shape
1524
// described here.
1625
//
17-
// Each consumer has "consumer" and "min_producer" versions (specified
18-
// elsewhere). A consumer is allowed to consume this data if
26+
// Each consumer has a "consumer_version" and a "min_producer_version". A consumer is allowed to consume this data if
1927
//
20-
// producer >= min_producer
21-
// consumer >= min_consumer
22-
// consumer not in bad_consumers
28+
// producer_version >= min_producer_version
29+
// consumer_version >= min_consumer_version
30+
// consumer_version not in bad_consumer_versions
2331
//
2432
message VersionDef {
25-
// The version of the code that produced this data.
26-
int32 producer = 1;
33+
// The version of the code that produced this data.
34+
int32 producer_version = 1;
2735

28-
// Any consumer below this version is not allowed to consume this data.
29-
int32 min_consumer = 2;
36+
// The minimum consumer version required to consume this data.
37+
int32 min_consumer_version = 2;
3038

31-
// Specific consumer versions which are disallowed (e.g. due to bugs).
32-
repeated int32 bad_consumers = 3;
39+
// Specific consumer versions which are disallowed (e.g. due to bugs).
40+
repeated BadConsumerVersion bad_consumer_versions = 3;
3341
}
42+
43+
// Represents a bad consumer version that is not allowed to consume data.
44+
message BadConsumerVersion {
45+
// The version of the bad consumer.
46+
int32 version = 1;
47+
48+
// A description of the issue with the bad consumer version.
49+
string issue_description = 2;
50+
}

navi/navi/scripts/run_onnx.sh

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1-
#!/bin/sh
2-
#RUST_LOG=debug LD_LIBRARY_PATH=so/onnx/lib target/release/navi_onnx --port 30 --num-worker-threads 8 --intra-op-parallelism 8 --inter-op-parallelism 8 \
3-
RUST_LOG=info LD_LIBRARY_PATH=so/onnx/lib cargo run --bin navi_onnx --features onnx -- \
4-
--port 30 --num-worker-threads 8 --intra-op-parallelism 8 --inter-op-parallelism 8 \
5-
--model-check-interval-secs 30 \
6-
--model-dir models/int8 \
7-
--output caligrated_probabilities \
8-
--input "" \
9-
--modelsync-cli "echo" \
10-
--onnx-ep-options use_arena=true
1+
# This script runs the navi_onnx Rust application with command line arguments.
2+
3+
# Set variables for command line arguments
4+
LOG_LEVEL="info"
5+
LIB_PATH="so/onnx/lib"
6+
PORT="30"
7+
NUM_WORKER_THREADS="8"
8+
INTRA_OP_PARALLELISM="8"
9+
INTER_OP_PARALLELISM="8"
10+
MODEL_CHECK_INTERVAL_SECS="30"
11+
MODEL_DIR="models/int8"
12+
OUTPUT="calibrated_probabilities"
13+
INPUT=""
14+
MODEL_SYNC_CLI="echo"
15+
ONNX_EP_OPTIONS="use_arena=true"
16+
17+
# Run the navi_onnx application
18+
RUST_LOG="$LOG_LEVEL" LD_LIBRARY_PATH="$LIB_PATH" cargo run --bin navi_onnx --features onnx -- \
19+
--port "$PORT" \
20+
--num-worker-threads "$NUM_WORKER_THREADS" \
21+
--intra-op-parallelism "$INTRA_OP_PARALLELISM" \
22+
--inter-op-parallelism "$INTER_OP_PARALLELISM" \
23+
--model-check-interval-secs "$MODEL_CHECK_INTERVAL_SECS" \
24+
--model-dir "$MODEL_DIR" \
25+
--output "$OUTPUT" \
26+
--input "$INPUT" \
27+
--modelsync-cli "$MODEL_SYNC_CLI" \
28+
--onnx-ep-options "$ONNX_EP_OPTIONS"

navi/navi/scripts/run_tf2.sh

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,45 @@
1-
#!/bin/sh
2-
RUST_LOG=info LD_LIBRARY_PATH=so/tf2 cargo run --bin navi --features tf -- --port 30 --num-worker-threads 8 --intra-op-parallelism 8 --inter-op-parallelism 8 \
3-
--model-check-interval-secs 30 \
4-
--model-dir models/click/ \
5-
--input "" \
6-
--output output_0
1+
#!/bin/bash
2+
3+
# Run the navi application with the following command line arguments
4+
5+
# Set the log level to info
6+
LOG_LEVEL="info"
7+
8+
# Set the path to the TensorFlow shared library
9+
TF_SO_PATH="so/tf2"
10+
11+
# Set the port number to listen on
12+
PORT="30"
13+
14+
# Set the number of worker threads
15+
NUM_WORKER_THREADS="8"
16+
17+
# Set the number of intra-op parallelism threads
18+
INTRA_OP_PARALLELISM="8"
19+
20+
# Set the number of inter-op parallelism threads
21+
INTER_OP_PARALLELISM="8"
22+
23+
# Set the model check interval in seconds
24+
MODEL_CHECK_INTERVAL_SECS="30"
25+
26+
# Set the path to the model directory
27+
MODEL_DIR="models/click/"
28+
29+
# Set the input value
30+
INPUT=""
31+
32+
# Set the output value
33+
OUTPUT="output_0"
34+
35+
# Run the navi application
36+
RUST_LOG="$LOG_LEVEL" LD_LIBRARY_PATH="$TF_SO_PATH" \
37+
cargo run --bin navi --features tf -- \
38+
--port "$PORT" \
39+
--num-worker-threads "$NUM_WORKER_THREADS" \
40+
--intra-op-parallelism "$INTRA_OP_PARALLELISM" \
41+
--inter-op-parallelism "$INTER_OP_PARALLELISM" \
42+
--model-check-interval-secs "$MODEL_CHECK_INTERVAL_SECS" \
43+
--model-dir "$MODEL_DIR" \
44+
--input "$INPUT" \
45+
--output "$OUTPUT"

0 commit comments

Comments
 (0)