Delete navi directory

This commit is contained in:
dogemanttv 2024-01-10 17:07:37 -06:00 committed by GitHub
parent 510b66c848
commit 61c1dd624f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
127 changed files with 0 additions and 17063 deletions

View File

@ -1,41 +0,0 @@
# Navi: High-Performance Machine Learning Serving Server in Rust
Navi is a high-performance, versatile machine learning serving server implemented in Rust and tailored for production usage. It's designed to efficiently serve within the Twitter tech stack, offering top-notch performance while focusing on core features.
## Key Features
- **Minimalist Design Optimized for Production Use Cases**: Navi delivers ultra-high performance, stability, and availability, engineered to handle real-world application demands with a streamlined codebase.
- **gRPC API Compatibility with TensorFlow Serving**: Seamless integration with existing TensorFlow Serving clients via its gRPC API, enabling easy integration, smooth deployment, and scaling in production environments.
- **Plugin Architecture for Different Runtimes**: Navi's pluggable architecture supports various machine learning runtimes, providing adaptability and extensibility for diverse use cases. Out-of-the-box support is available for TensorFlow and Onnx Runtime, with PyTorch in an experimental state.
## Current State
While Navi's features may not be as comprehensive as its open-source counterparts, its performance-first mindset makes it highly efficient.
- Navi for TensorFlow is currently the most feature-complete, supporting multiple input tensors of different types (float, int, string, etc.).
- Navi for Onnx primarily supports one input tensor of type string, used in Twitter's home recommendation with a proprietary BatchPredictRequest format.
- Navi for Pytorch is compilable and runnable but not yet production-ready in terms of performance and stability.
## Directory Structure
- `navi`: The main code repository for Navi
- `dr_transform`: Twitter-specific converter that converts BatchPredictionRequest Thrift to ndarray
- `segdense`: Twitter-specific config to specify how to retrieve feature values from BatchPredictionRequest
- `thrift_bpr_adapter`: generated thrift code for BatchPredictionRequest
## Content
We have included all *.rs source code files that make up the main Navi binaries for you to examine. However, we have not included the test and benchmark code, or various configuration files, due to data security concerns.
## Run
In navi/navi, you can run the following commands:
- `scripts/run_tf2.sh` for [TensorFlow](https://www.tensorflow.org/)
- `scripts/run_onnx.sh` for [Onnx](https://onnx.ai/)
Do note that you need to create a models directory and create some versions, preferably using epoch time, e.g., `1679693908377`.
so the models structure looks like:
models/
-web_click
- 1809000
- 1809010
## Build
You can adapt the above scripts to build using Cargo.

View File

@ -1,32 +0,0 @@
[package]
name = "dr_transform"
version = "0.1.0"
edition = "2021"
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
json = "0.12.4"
bpr_thrift = { path = "../thrift_bpr_adapter/thrift/"}
segdense = { path = "../segdense/"}
thrift = "0.17.0"
ndarray = "0.15"
base64 = "0.20.0"
npyz = "0.7.2"
log = "0.4.17"
env_logger = "0.9.0"
prometheus = "0.13.1"
once_cell = "1.17.0"
rand = "0.8.5"
itertools = "0.10.5"
anyhow = "1.0.70"
[target.'cfg(not(target_os="linux"))'.dependencies]
ort = {git ="https://github.com/pykeio/ort.git", features=["profiling"], tag="v1.14.6"}
[target.'cfg(target_os="linux")'.dependencies]
ort = {git ="https://github.com/pykeio/ort.git", features=["profiling", "tensorrt", "cuda", "copy-dylibs"], tag="v1.14.6"}
[dev-dependencies]
criterion = "0.3.0"
[[bench]]
name = "bpr_benchmark"
harness = false

View File

@ -1,49 +0,0 @@
use serde::{Deserialize, Serialize};
use serde_json::Error;
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AllConfig {
#[serde(rename = "train_data")]
pub train_data: TrainData,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TrainData {
#[serde(rename = "seg_dense_schema")]
pub seg_dense_schema: SegDenseSchema,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SegDenseSchema {
#[serde(rename = "renamed_features")]
pub renamed_features: RenamedFeatures,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RenamedFeatures {
pub continuous: String,
pub binary: String,
pub discrete: String,
#[serde(rename = "author_embedding")]
pub author_embedding: String,
#[serde(rename = "user_embedding")]
pub user_embedding: String,
#[serde(rename = "user_eng_embedding")]
pub user_eng_embedding: String,
#[serde(rename = "meta__author_id")]
pub meta_author_id: String,
#[serde(rename = "meta__user_id")]
pub meta_user_id: String,
#[serde(rename = "meta__tweet_id")]
pub meta_tweet_id: String,
}
pub fn parse(json_str: &str) -> Result<AllConfig, Error> {
let all_config: AllConfig = serde_json::from_str(json_str)?;
Ok(all_config)
}

View File

@ -1,616 +0,0 @@
use std::collections::BTreeSet;
use std::fmt::{self, Debug, Display};
use std::fs;
use crate::all_config;
use crate::all_config::AllConfig;
use anyhow::{bail, Context};
use bpr_thrift::data::DataRecord;
use bpr_thrift::prediction_service::BatchPredictionRequest;
use bpr_thrift::tensor::GeneralTensor;
use log::debug;
use ndarray::Array2;
use once_cell::sync::OnceCell;
use ort::tensor::InputTensor;
use prometheus::{HistogramOpts, HistogramVec};
use segdense::mapper::{FeatureMapper, MapReader};
use segdense::segdense_transform_spec_home_recap_2022::{DensificationTransformSpec, Root};
use segdense::util;
use thrift::protocol::{TBinaryInputProtocol, TSerializable};
use thrift::transport::TBufferChannel;
pub fn log_feature_match(
dr: &DataRecord,
seg_dense_config: &DensificationTransformSpec,
dr_type: String,
) {
// Note the following algorithm matches features from config using linear search.
// Also the record source is MinDataRecord. This includes only binary and continous features for now.
for (feature_id, feature_value) in dr.continuous_features.as_ref().unwrap() {
debug!(
"{} - Continous Datarecord => Feature ID: {}, Feature value: {}",
dr_type, feature_id, feature_value
);
for input_feature in &seg_dense_config.cont.input_features {
if input_feature.feature_id == *feature_id {
debug!("Matching input feature: {:?}", input_feature)
}
}
}
for feature_id in dr.binary_features.as_ref().unwrap() {
debug!(
"{} - Binary Datarecord => Feature ID: {}",
dr_type, feature_id
);
for input_feature in &seg_dense_config.binary.input_features {
if input_feature.feature_id == *feature_id {
debug!("Found input feature: {:?}", input_feature)
}
}
}
}
pub fn log_feature_matches(drs: &Vec<DataRecord>, seg_dense_config: &DensificationTransformSpec) {
for dr in drs {
log_feature_match(dr, seg_dense_config, String::from("individual"));
}
}
pub trait Converter: Send + Sync + Debug + 'static + Display {
fn convert(&self, input: Vec<Vec<u8>>) -> (Vec<InputTensor>, Vec<usize>);
}
#[derive(Debug)]
#[allow(dead_code)]
pub struct BatchPredictionRequestToTorchTensorConverter {
all_config: AllConfig,
seg_dense_config: Root,
all_config_path: String,
seg_dense_config_path: String,
feature_mapper: FeatureMapper,
user_embedding_feature_id: i64,
user_eng_embedding_feature_id: i64,
author_embedding_feature_id: i64,
discrete_features_to_report: BTreeSet<i64>,
continuous_features_to_report: BTreeSet<i64>,
discrete_feature_metrics: &'static HistogramVec,
continuous_feature_metrics: &'static HistogramVec,
}
impl Display for BatchPredictionRequestToTorchTensorConverter {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"all_config_path: {}, seg_dense_config_path:{}",
self.all_config_path, self.seg_dense_config_path
)
}
}
impl BatchPredictionRequestToTorchTensorConverter {
pub fn new(
model_dir: &str,
model_version: &str,
reporting_feature_ids: Vec<(i64, &str)>,
register_metric_fn: Option<impl Fn(&HistogramVec)>,
) -> anyhow::Result<BatchPredictionRequestToTorchTensorConverter> {
let all_config_path = format!("{}/{}/all_config.json", model_dir, model_version);
let seg_dense_config_path = format!(
"{}/{}/segdense_transform_spec_home_recap_2022.json",
model_dir, model_version
);
let seg_dense_config = util::load_config(&seg_dense_config_path)?;
let all_config = all_config::parse(
&fs::read_to_string(&all_config_path)
.with_context(|| "error loading all_config.json - ")?,
)?;
let feature_mapper = util::load_from_parsed_config(seg_dense_config.clone())?;
let user_embedding_feature_id = Self::get_feature_id(
&all_config
.train_data
.seg_dense_schema
.renamed_features
.user_embedding,
&seg_dense_config,
);
let user_eng_embedding_feature_id = Self::get_feature_id(
&all_config
.train_data
.seg_dense_schema
.renamed_features
.user_eng_embedding,
&seg_dense_config,
);
let author_embedding_feature_id = Self::get_feature_id(
&all_config
.train_data
.seg_dense_schema
.renamed_features
.author_embedding,
&seg_dense_config,
);
static METRICS: OnceCell<(HistogramVec, HistogramVec)> = OnceCell::new();
let (discrete_feature_metrics, continuous_feature_metrics) = METRICS.get_or_init(|| {
let discrete = HistogramVec::new(
HistogramOpts::new(":navi:feature_id:discrete", "Discrete Feature ID values")
.buckets(Vec::from(&[
0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0,
120.0, 130.0, 140.0, 150.0, 160.0, 170.0, 180.0, 190.0, 200.0, 250.0,
300.0, 500.0, 1000.0, 10000.0, 100000.0,
] as &'static [f64])),
&["feature_id"],
)
.expect("metric cannot be created");
let continuous = HistogramVec::new(
HistogramOpts::new(
":navi:feature_id:continuous",
"continuous Feature ID values",
)
.buckets(Vec::from(&[
0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0, 120.0,
130.0, 140.0, 150.0, 160.0, 170.0, 180.0, 190.0, 200.0, 250.0, 300.0, 500.0,
1000.0, 10000.0, 100000.0,
] as &'static [f64])),
&["feature_id"],
)
.expect("metric cannot be created");
register_metric_fn.map(|r| {
r(&discrete);
r(&continuous);
});
(discrete, continuous)
});
let mut discrete_features_to_report = BTreeSet::new();
let mut continuous_features_to_report = BTreeSet::new();
for (feature_id, feature_type) in reporting_feature_ids.iter() {
match *feature_type {
"discrete" => discrete_features_to_report.insert(feature_id.clone()),
"continuous" => continuous_features_to_report.insert(feature_id.clone()),
_ => bail!(
"Invalid feature type {} for reporting metrics!",
feature_type
),
};
}
Ok(BatchPredictionRequestToTorchTensorConverter {
all_config,
seg_dense_config,
all_config_path,
seg_dense_config_path,
feature_mapper,
user_embedding_feature_id,
user_eng_embedding_feature_id,
author_embedding_feature_id,
discrete_features_to_report,
continuous_features_to_report,
discrete_feature_metrics,
continuous_feature_metrics,
})
}
fn get_feature_id(feature_name: &str, seg_dense_config: &Root) -> i64 {
// given a feature name, we get the complex feature type id
for feature in &seg_dense_config.complex_feature_type_transform_spec {
if feature.full_feature_name == feature_name {
return feature.feature_id;
}
}
-1
}
fn parse_batch_prediction_request(bytes: Vec<u8>) -> BatchPredictionRequest {
// parse batch prediction request into a struct from byte array repr.
let mut bc = TBufferChannel::with_capacity(bytes.len(), 0);
bc.set_readable_bytes(&bytes);
let mut protocol = TBinaryInputProtocol::new(bc, true);
BatchPredictionRequest::read_from_in_protocol(&mut protocol).unwrap()
}
fn get_embedding_tensors(
&self,
bprs: &[BatchPredictionRequest],
feature_id: i64,
batch_size: &[usize],
) -> Array2<f32> {
// given an embedding feature id, extract the float tensor array into tensors.
let cols: usize = 200;
let rows: usize = batch_size[batch_size.len() - 1];
let total_size = rows * cols;
let mut working_set = vec![0 as f32; total_size];
let mut bpr_start = 0;
for (bpr, &bpr_end) in bprs.iter().zip(batch_size) {
if bpr.common_features.is_some() {
if bpr.common_features.as_ref().unwrap().tensors.is_some() {
if bpr
.common_features
.as_ref()
.unwrap()
.tensors
.as_ref()
.unwrap()
.contains_key(&feature_id)
{
let source_tensor = bpr
.common_features
.as_ref()
.unwrap()
.tensors
.as_ref()
.unwrap()
.get(&feature_id)
.unwrap();
let tensor = match source_tensor {
GeneralTensor::FloatTensor(float_tensor) =>
//Tensor::of_slice(
{
float_tensor
.floats
.iter()
.map(|x| x.into_inner() as f32)
.collect::<Vec<_>>()
}
_ => vec![0 as f32; cols],
};
// since the tensor is found in common feature, add it in all batches
for row in bpr_start..bpr_end {
for col in 0..cols {
working_set[row * cols + col] = tensor[col];
}
}
}
}
}
// find the feature in individual feature list and add to corresponding batch.
for (index, datarecord) in bpr.individual_features_list.iter().enumerate() {
if datarecord.tensors.is_some()
&& datarecord
.tensors
.as_ref()
.unwrap()
.contains_key(&feature_id)
{
let source_tensor = datarecord
.tensors
.as_ref()
.unwrap()
.get(&feature_id)
.unwrap();
let tensor = match source_tensor {
GeneralTensor::FloatTensor(float_tensor) => float_tensor
.floats
.iter()
.map(|x| x.into_inner() as f32)
.collect::<Vec<_>>(),
_ => vec![0 as f32; cols],
};
for col in 0..cols {
working_set[(bpr_start + index) * cols + col] = tensor[col];
}
}
}
bpr_start = bpr_end;
}
Array2::<f32>::from_shape_vec([rows, cols], working_set).unwrap()
}
// Todo : Refactor, create a generic version with different type and field accessors
// Example paramterize and then instiantiate the following
// (FLOAT --> FLOAT, DataRecord.continuous_feature)
// (BOOL --> INT64, DataRecord.binary_feature)
// (INT64 --> INT64, DataRecord.discrete_feature)
fn get_continuous(&self, bprs: &[BatchPredictionRequest], batch_ends: &[usize]) -> InputTensor {
// These need to be part of model schema
let rows: usize = batch_ends[batch_ends.len() - 1];
let cols: usize = 5293;
let full_size: usize = rows * cols;
let default_val = f32::NAN;
let mut tensor = vec![default_val; full_size];
let mut bpr_start = 0;
for (bpr, &bpr_end) in bprs.iter().zip(batch_ends) {
// Common features
if bpr.common_features.is_some()
&& bpr
.common_features
.as_ref()
.unwrap()
.continuous_features
.is_some()
{
let common_features = bpr
.common_features
.as_ref()
.unwrap()
.continuous_features
.as_ref()
.unwrap();
for feature in common_features {
match self.feature_mapper.get(feature.0) {
Some(f_info) => {
let idx = f_info.index_within_tensor as usize;
if idx < cols {
// Set value in each row
for r in bpr_start..bpr_end {
let flat_index: usize = r * cols + idx;
tensor[flat_index] = feature.1.into_inner() as f32;
}
}
}
None => (),
}
if self.continuous_features_to_report.contains(feature.0) {
self.continuous_feature_metrics
.with_label_values(&[feature.0.to_string().as_str()])
.observe(feature.1.into_inner())
} else if self.discrete_features_to_report.contains(feature.0) {
self.discrete_feature_metrics
.with_label_values(&[feature.0.to_string().as_str()])
.observe(feature.1.into_inner())
}
}
}
// Process the batch of datarecords
for r in bpr_start..bpr_end {
let dr: &DataRecord =
&bpr.individual_features_list[usize::try_from(r - bpr_start).unwrap()];
if dr.continuous_features.is_some() {
for feature in dr.continuous_features.as_ref().unwrap() {
match self.feature_mapper.get(&feature.0) {
Some(f_info) => {
let idx = f_info.index_within_tensor as usize;
let flat_index: usize = r * cols + idx;
if flat_index < tensor.len() && idx < cols {
tensor[flat_index] = feature.1.into_inner() as f32;
}
}
None => (),
}
if self.continuous_features_to_report.contains(feature.0) {
self.continuous_feature_metrics
.with_label_values(&[feature.0.to_string().as_str()])
.observe(feature.1.into_inner() as f64)
} else if self.discrete_features_to_report.contains(feature.0) {
self.discrete_feature_metrics
.with_label_values(&[feature.0.to_string().as_str()])
.observe(feature.1.into_inner() as f64)
}
}
}
}
bpr_start = bpr_end;
}
InputTensor::FloatTensor(
Array2::<f32>::from_shape_vec([rows, cols], tensor)
.unwrap()
.into_dyn(),
)
}
fn get_binary(&self, bprs: &[BatchPredictionRequest], batch_ends: &[usize]) -> InputTensor {
// These need to be part of model schema
let rows: usize = batch_ends[batch_ends.len() - 1];
let cols: usize = 149;
let full_size: usize = rows * cols;
let default_val: i64 = 0;
let mut v = vec![default_val; full_size];
let mut bpr_start = 0;
for (bpr, &bpr_end) in bprs.iter().zip(batch_ends) {
// Common features
if bpr.common_features.is_some()
&& bpr
.common_features
.as_ref()
.unwrap()
.binary_features
.is_some()
{
let common_features = bpr
.common_features
.as_ref()
.unwrap()
.binary_features
.as_ref()
.unwrap();
for feature in common_features {
match self.feature_mapper.get(feature) {
Some(f_info) => {
let idx = f_info.index_within_tensor as usize;
if idx < cols {
// Set value in each row
for r in bpr_start..bpr_end {
let flat_index: usize = r * cols + idx;
v[flat_index] = 1;
}
}
}
None => (),
}
}
}
// Process the batch of datarecords
for r in bpr_start..bpr_end {
let dr: &DataRecord = &bpr.individual_features_list[r - bpr_start];
if dr.binary_features.is_some() {
for feature in dr.binary_features.as_ref().unwrap() {
match self.feature_mapper.get(&feature) {
Some(f_info) => {
let idx = f_info.index_within_tensor as usize;
let flat_index: usize = r * cols + idx;
v[flat_index] = 1;
}
None => (),
}
}
}
}
bpr_start = bpr_end;
}
InputTensor::Int64Tensor(
Array2::<i64>::from_shape_vec([rows, cols], v)
.unwrap()
.into_dyn(),
)
}
#[allow(dead_code)]
fn get_discrete(&self, bprs: &[BatchPredictionRequest], batch_ends: &[usize]) -> InputTensor {
// These need to be part of model schema
let rows: usize = batch_ends[batch_ends.len() - 1];
let cols: usize = 320;
let full_size: usize = rows * cols;
let default_val: i64 = 0;
let mut v = vec![default_val; full_size];
let mut bpr_start = 0;
for (bpr, &bpr_end) in bprs.iter().zip(batch_ends) {
// Common features
if bpr.common_features.is_some()
&& bpr
.common_features
.as_ref()
.unwrap()
.discrete_features
.is_some()
{
let common_features = bpr
.common_features
.as_ref()
.unwrap()
.discrete_features
.as_ref()
.unwrap();
for feature in common_features {
match self.feature_mapper.get(feature.0) {
Some(f_info) => {
let idx = f_info.index_within_tensor as usize;
if idx < cols {
// Set value in each row
for r in bpr_start..bpr_end {
let flat_index: usize = r * cols + idx;
v[flat_index] = *feature.1;
}
}
}
None => (),
}
if self.discrete_features_to_report.contains(feature.0) {
self.discrete_feature_metrics
.with_label_values(&[feature.0.to_string().as_str()])
.observe(*feature.1 as f64)
}
}
}
// Process the batch of datarecords
for r in bpr_start..bpr_end {
let dr: &DataRecord = &bpr.individual_features_list[usize::try_from(r).unwrap()];
if dr.discrete_features.is_some() {
for feature in dr.discrete_features.as_ref().unwrap() {
match self.feature_mapper.get(&feature.0) {
Some(f_info) => {
let idx = f_info.index_within_tensor as usize;
let flat_index: usize = r * cols + idx;
if flat_index < v.len() && idx < cols {
v[flat_index] = *feature.1;
}
}
None => (),
}
if self.discrete_features_to_report.contains(feature.0) {
self.discrete_feature_metrics
.with_label_values(&[feature.0.to_string().as_str()])
.observe(*feature.1 as f64)
}
}
}
}
bpr_start = bpr_end;
}
InputTensor::Int64Tensor(
Array2::<i64>::from_shape_vec([rows, cols], v)
.unwrap()
.into_dyn(),
)
}
fn get_user_embedding(
&self,
bprs: &[BatchPredictionRequest],
batch_ends: &[usize],
) -> InputTensor {
InputTensor::FloatTensor(
self.get_embedding_tensors(bprs, self.user_embedding_feature_id, batch_ends)
.into_dyn(),
)
}
fn get_eng_embedding(
&self,
bpr: &[BatchPredictionRequest],
batch_ends: &[usize],
) -> InputTensor {
InputTensor::FloatTensor(
self.get_embedding_tensors(bpr, self.user_eng_embedding_feature_id, batch_ends)
.into_dyn(),
)
}
fn get_author_embedding(
&self,
bpr: &[BatchPredictionRequest],
batch_ends: &[usize],
) -> InputTensor {
InputTensor::FloatTensor(
self.get_embedding_tensors(bpr, self.author_embedding_feature_id, batch_ends)
.into_dyn(),
)
}
}
impl Converter for BatchPredictionRequestToTorchTensorConverter {
fn convert(&self, batched_bytes: Vec<Vec<u8>>) -> (Vec<InputTensor>, Vec<usize>) {
let bprs = batched_bytes
.into_iter()
.map(|bytes| {
BatchPredictionRequestToTorchTensorConverter::parse_batch_prediction_request(bytes)
})
.collect::<Vec<_>>();
let batch_ends = bprs
.iter()
.map(|bpr| bpr.individual_features_list.len())
.scan(0usize, |acc, e| {
//running total
*acc = *acc + e;
Some(*acc)
})
.collect::<Vec<_>>();
let t1 = self.get_continuous(&bprs, &batch_ends);
let t2 = self.get_binary(&bprs, &batch_ends);
//let _t3 = self.get_discrete(&bprs, &batch_ends);
let t4 = self.get_user_embedding(&bprs, &batch_ends);
let t5 = self.get_eng_embedding(&bprs, &batch_ends);
let t6 = self.get_author_embedding(&bprs, &batch_ends);
(vec![t1, t2, t4, t5, t6], batch_ends)
}
}

View File

@ -1,6 +0,0 @@
pub mod all_config;
pub mod converter;
#[cfg(test)]
mod test;
pub mod util;
pub extern crate ort;

View File

@ -1,32 +0,0 @@
use npyz::WriterBuilder;
use npyz::{AutoSerialize, WriteOptions};
use std::io::BufWriter;
use std::{
fs::File,
io::{self, BufRead},
};
pub fn load_batch_prediction_request_base64(file_name: &str) -> Vec<Vec<u8>> {
let file = File::open(file_name).expect("could not read file");
let mut result = vec![];
for (mut line_count, line) in io::BufReader::new(file).lines().enumerate() {
line_count += 1;
match base64::decode(line.unwrap().trim()) {
Ok(payload) => result.push(payload),
Err(err) => println!("error decoding line {file_name}:{line_count} - {err}"),
}
}
println!("result len: {}", result.len());
result
}
pub fn save_to_npy<T: npyz::Serialize + AutoSerialize>(data: &[T], save_to: String) {
let mut writer = WriteOptions::new()
.default_dtype()
.shape(&[data.len() as u64, 1])
.writer(BufWriter::new(File::create(save_to).unwrap()))
.begin_nd()
.unwrap();
writer.extend(data.to_owned()).unwrap();
writer.finish().unwrap();
}

View File

@ -1,81 +0,0 @@
[package]
name = "navi"
version = "2.0.45"
edition = "2021"
[[bin]]
name = "navi"
path = "src/bin/navi.rs"
required-features=["tf"]
[[bin]]
name = "navi_torch"
path = "src/bin/navi_torch.rs"
required-features=["torch"]
[[bin]]
name = "navi_onnx"
path = "src/bin/navi_onnx.rs"
required-features=["onnx"]
[[bin]]
name = "navi_onnx_test"
path = "src/bin/bin_tests/navi_onnx_test.rs"
[[bin]]
name = "navi_torch_test"
path = "src/bin/bin_tests/navi_torch_test.rs"
required-features=["torch"]
[features]
default=[]
navi_console=[]
torch=["tch"]
onnx=[]
tf=["tensorflow"]
[dependencies]
itertools = "0.10.5"
anyhow = "1.0.57"
arrayvec = "0.7.2"
clap = { version = "4.0.32", features = ["derive"] }
console-subscriber = "0.1.6"
time = { version = "0.3.20", features = ["parsing"] }
env_logger = "0.10.0"
flamegraph = "0.6.1"
fnv = "1.0.7"
futures = { version = "0.3", default-features = false }
image = "0.24.5"
indexmap = "1.8.1"
lazy_static = "1.4"
libloading = "0.7"
log = "0.4.17"
ndarray-rand = "0.14.0"
prometheus = "0.13.1"
prost = "0.9"
prost-types = "0.9"
parking_lot = "0.12.1"
rand = "0.8.5"
rand_pcg = "0.3.1"
random = "0.12.2"
x509-parser = "0.15.0"
sha256 = "1.0.3"
tonic = { version = "0.6.2", features=['compression', 'tls'] }
tokio = { version = "1.17.0", features = ["macros", "rt-multi-thread", "fs", "process"] }
warp = "0.3"
npyz = "0.7.3"
base64 = "0.21.0"
histogram = "0.6.9"
tch = {version = "0.10.3", optional = true}
tensorflow = { version = "0.18.0", optional = true }
once_cell = {version = "1.17.1"}
ndarray = "0.15"
serde = "1.0.154"
serde_json = "1.0.94"
dr_transform = { path = "../dr_transform"}
[build-dependencies]
tonic-build = {version = "0.6.2", features=['prost', "compression"] }
[profile.release]
debug = true
[dev-dependencies]
ndarray-rand = "0.14.0"
tokio-test = "*"
assert_cmd = "2.0"
criterion = "0.4.0"

View File

@ -1,13 +0,0 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
//::compile_protos("proto/tensorflow_serving/apis/prediction_service.proto")?;
tonic_build::configure().compile(
&[
"proto/tensorflow_serving/apis/prediction_service.proto",
"proto/tensorflow/core/protobuf/config.proto",
"proto/tensorflow_serving/apis/prediction_log.proto",
"proto/kfserving/grpc_predict_v2.proto",
],
&["proto"],
)?;
Ok(())
}

View File

@ -1,326 +0,0 @@
// Copyright 2020 kubeflow.org.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package inference;
// Inference Server GRPC endpoints.
service GRPCInferenceService
{
// The ServerLive API indicates if the inference server is able to receive
// and respond to metadata and inference requests.
rpc ServerLive(ServerLiveRequest) returns (ServerLiveResponse) {}
// The ServerReady API indicates if the server is ready for inferencing.
rpc ServerReady(ServerReadyRequest) returns (ServerReadyResponse) {}
// The ModelReady API indicates if a specific model is ready for inferencing.
rpc ModelReady(ModelReadyRequest) returns (ModelReadyResponse) {}
// The ServerMetadata API provides information about the server. Errors are
// indicated by the google.rpc.Status returned for the request. The OK code
// indicates success and other codes indicate failure.
rpc ServerMetadata(ServerMetadataRequest) returns (ServerMetadataResponse) {}
// The per-model metadata API provides information about a model. Errors are
// indicated by the google.rpc.Status returned for the request. The OK code
// indicates success and other codes indicate failure.
rpc ModelMetadata(ModelMetadataRequest) returns (ModelMetadataResponse) {}
// The ModelInfer API performs inference using the specified model. Errors are
// indicated by the google.rpc.Status returned for the request. The OK code
// indicates success and other codes indicate failure.
rpc ModelInfer(ModelInferRequest) returns (ModelInferResponse) {}
}
message ServerLiveRequest {}
message ServerLiveResponse
{
// True if the inference server is live, false if not live.
bool live = 1;
}
message ServerReadyRequest {}
message ServerReadyResponse
{
// True if the inference server is ready, false if not ready.
bool ready = 1;
}
message ModelReadyRequest
{
// The name of the model to check for readiness.
string name = 1;
// The version of the model to check for readiness. If not given the
// server will choose a version based on the model and internal policy.
string version = 2;
}
message ModelReadyResponse
{
// True if the model is ready, false if not ready.
bool ready = 1;
}
message ServerMetadataRequest {}
message ServerMetadataResponse
{
// The server name.
string name = 1;
// The server version.
string version = 2;
// The extensions supported by the server.
repeated string extensions = 3;
}
message ModelMetadataRequest
{
// The name of the model.
string name = 1;
// The version of the model to check for readiness. If not given the
// server will choose a version based on the model and internal policy.
string version = 2;
}
message ModelMetadataResponse
{
// Metadata for a tensor.
message TensorMetadata
{
// The tensor name.
string name = 1;
// The tensor data type.
string datatype = 2;
// The tensor shape. A variable-size dimension is represented
// by a -1 value.
repeated int64 shape = 3;
}
// The model name.
string name = 1;
// The versions of the model available on the server.
repeated string versions = 2;
// The model's platform. See Platforms.
string platform = 3;
// The model's inputs.
repeated TensorMetadata inputs = 4;
// The model's outputs.
repeated TensorMetadata outputs = 5;
}
message ModelInferRequest
{
// An input tensor for an inference request.
message InferInputTensor
{
// The tensor name.
string name = 1;
// The tensor data type.
string datatype = 2;
// The tensor shape.
repeated int64 shape = 3;
// Optional inference input tensor parameters.
map<string, InferParameter> parameters = 4;
// The tensor contents using a data-type format. This field must
// not be specified if "raw" tensor contents are being used for
// the inference request.
InferTensorContents contents = 5;
}
// An output tensor requested for an inference request.
message InferRequestedOutputTensor
{
// The tensor name.
string name = 1;
// Optional requested output tensor parameters.
map<string, InferParameter> parameters = 2;
}
// The name of the model to use for inferencing.
string model_name = 1;
// The version of the model to use for inference. If not given the
// server will choose a version based on the model and internal policy.
string model_version = 2;
// Optional identifier for the request. If specified will be
// returned in the response.
string id = 3;
// Optional inference parameters.
map<string, InferParameter> parameters = 4;
// The input tensors for the inference.
repeated InferInputTensor inputs = 5;
// The requested output tensors for the inference. Optional, if not
// specified all outputs produced by the model will be returned.
repeated InferRequestedOutputTensor outputs = 6;
// The data contained in an input tensor can be represented in "raw"
// bytes form or in the repeated type that matches the tensor's data
// type. To use the raw representation 'raw_input_contents' must be
// initialized with data for each tensor in the same order as
// 'inputs'. For each tensor, the size of this content must match
// what is expected by the tensor's shape and data type. The raw
// data must be the flattened, one-dimensional, row-major order of
// the tensor elements without any stride or padding between the
// elements. Note that the FP16 and BF16 data types must be represented as
// raw content as there is no specific data type for a 16-bit float type.
//
// If this field is specified then InferInputTensor::contents must
// not be specified for any input tensor.
repeated bytes raw_input_contents = 7;
}
message ModelInferResponse
{
// An output tensor returned for an inference request.
message InferOutputTensor
{
// The tensor name.
string name = 1;
// The tensor data type.
string datatype = 2;
// The tensor shape.
repeated int64 shape = 3;
// Optional output tensor parameters.
map<string, InferParameter> parameters = 4;
// The tensor contents using a data-type format. This field must
// not be specified if "raw" tensor contents are being used for
// the inference response.
InferTensorContents contents = 5;
}
// The name of the model used for inference.
string model_name = 1;
// The version of the model used for inference.
string model_version = 2;
// The id of the inference request if one was specified.
string id = 3;
// Optional inference response parameters.
map<string, InferParameter> parameters = 4;
// The output tensors holding inference results.
repeated InferOutputTensor outputs = 5;
// The data contained in an output tensor can be represented in
// "raw" bytes form or in the repeated type that matches the
// tensor's data type. To use the raw representation 'raw_output_contents'
// must be initialized with data for each tensor in the same order as
// 'outputs'. For each tensor, the size of this content must match
// what is expected by the tensor's shape and data type. The raw
// data must be the flattened, one-dimensional, row-major order of
// the tensor elements without any stride or padding between the
// elements. Note that the FP16 and BF16 data types must be represented as
// raw content as there is no specific data type for a 16-bit float type.
//
// If this field is specified then InferOutputTensor::contents must
// not be specified for any output tensor.
repeated bytes raw_output_contents = 6;
}
// An inference parameter value. The Parameters message describes a
// name/value pair, where the name is the name of the parameter
// and the value is a boolean, integer, or string corresponding to
// the parameter.
message InferParameter
{
// The parameter value can be a string, an int64, a boolean
// or a message specific to a predefined parameter.
oneof parameter_choice
{
// A boolean parameter value.
bool bool_param = 1;
// An int64 parameter value.
int64 int64_param = 2;
// A string parameter value.
string string_param = 3;
}
}
// The data contained in a tensor represented by the repeated type
// that matches the tensor's data type. Protobuf oneof is not used
// because oneofs cannot contain repeated fields.
message InferTensorContents
{
// Representation for BOOL data type. The size must match what is
// expected by the tensor's shape. The contents must be the flattened,
// one-dimensional, row-major order of the tensor elements.
repeated bool bool_contents = 1;
// Representation for INT8, INT16, and INT32 data types. The size
// must match what is expected by the tensor's shape. The contents
// must be the flattened, one-dimensional, row-major order of the
// tensor elements.
repeated int32 int_contents = 2;
// Representation for INT64 data types. The size must match what
// is expected by the tensor's shape. The contents must be the
// flattened, one-dimensional, row-major order of the tensor elements.
repeated int64 int64_contents = 3;
// Representation for UINT8, UINT16, and UINT32 data types. The size
// must match what is expected by the tensor's shape. The contents
// must be the flattened, one-dimensional, row-major order of the
// tensor elements.
repeated uint32 uint_contents = 4;
// Representation for UINT64 data types. The size must match what
// is expected by the tensor's shape. The contents must be the
// flattened, one-dimensional, row-major order of the tensor elements.
repeated uint64 uint64_contents = 5;
// Representation for FP32 data type. The size must match what is
// expected by the tensor's shape. The contents must be the flattened,
// one-dimensional, row-major order of the tensor elements.
repeated float fp32_contents = 6;
// Representation for FP64 data type. The size must match what is
// expected by the tensor's shape. The contents must be the flattened,
// one-dimensional, row-major order of the tensor elements.
repeated double fp64_contents = 7;
// Representation for BYTES data type. The size must match what is
// expected by the tensor's shape. The contents must be the flattened,
// one-dimensional, row-major order of the tensor elements.
repeated bytes bytes_contents = 8;
}

View File

@ -1,306 +0,0 @@
// Protocol messages for describing input data Examples for machine learning
// model training or inference.
syntax = "proto3";
package tensorflow;
import "tensorflow/core/example/feature.proto";
option cc_enable_arenas = true;
option java_outer_classname = "ExampleProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.example";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/example";
// LINT.IfChange
// An Example is a mostly-normalized data format for storing data for
// training and inference. It contains a key-value store (features); where
// each key (string) maps to a Feature message (which is oneof packed BytesList,
// FloatList, or Int64List). This flexible and compact format allows the
// storage of large amounts of typed data, but requires that the data shape
// and use be determined by the configuration files and parsers that are used to
// read and write this format. That is, the Example is mostly *not* a
// self-describing format. In TensorFlow, Examples are read in row-major
// format, so any configuration that describes data with rank-2 or above
// should keep this in mind. For example, to store an M x N matrix of Bytes,
// the BytesList must contain M*N bytes, with M rows of N contiguous values
// each. That is, the BytesList value must store the matrix as:
// .... row 0 .... .... row 1 .... // ........... // ... row M-1 ....
//
// An Example for a movie recommendation application:
// features {
// feature {
// key: "age"
// value { float_list {
// value: 29.0
// }}
// }
// feature {
// key: "movie"
// value { bytes_list {
// value: "The Shawshank Redemption"
// value: "Fight Club"
// }}
// }
// feature {
// key: "movie_ratings"
// value { float_list {
// value: 9.0
// value: 9.7
// }}
// }
// feature {
// key: "suggestion"
// value { bytes_list {
// value: "Inception"
// }}
// }
// # Note that this feature exists to be used as a label in training.
// # E.g., if training a logistic regression model to predict purchase
// # probability in our learning tool we would set the label feature to
// # "suggestion_purchased".
// feature {
// key: "suggestion_purchased"
// value { float_list {
// value: 1.0
// }}
// }
// # Similar to "suggestion_purchased" above this feature exists to be used
// # as a label in training.
// # E.g., if training a linear regression model to predict purchase
// # price in our learning tool we would set the label feature to
// # "purchase_price".
// feature {
// key: "purchase_price"
// value { float_list {
// value: 9.99
// }}
// }
// }
//
// A conformant Example data set obeys the following conventions:
// - If a Feature K exists in one example with data type T, it must be of
// type T in all other examples when present. It may be omitted.
// - The number of instances of Feature K list data may vary across examples,
// depending on the requirements of the model.
// - If a Feature K doesn't exist in an example, a K-specific default will be
// used, if configured.
// - If a Feature K exists in an example but contains no items, the intent
// is considered to be an empty tensor and no default will be used.
message Example {
Features features = 1;
}
// A SequenceExample is an Example representing one or more sequences, and
// some context. The context contains features which apply to the entire
// example. The feature_lists contain a key, value map where each key is
// associated with a repeated set of Features (a FeatureList).
// A FeatureList thus represents the values of a feature identified by its key
// over time / frames.
//
// Below is a SequenceExample for a movie recommendation application recording a
// sequence of ratings by a user. The time-independent features ("locale",
// "age", "favorites") describing the user are part of the context. The sequence
// of movies the user rated are part of the feature_lists. For each movie in the
// sequence we have information on its name and actors and the user's rating.
// This information is recorded in three separate feature_list(s).
// In the example below there are only two movies. All three feature_list(s),
// namely "movie_ratings", "movie_names", and "actors" have a feature value for
// both movies. Note, that "actors" is itself a bytes_list with multiple
// strings per movie.
//
// context: {
// feature: {
// key : "locale"
// value: {
// bytes_list: {
// value: [ "pt_BR" ]
// }
// }
// }
// feature: {
// key : "age"
// value: {
// float_list: {
// value: [ 19.0 ]
// }
// }
// }
// feature: {
// key : "favorites"
// value: {
// bytes_list: {
// value: [ "Majesty Rose", "Savannah Outen", "One Direction" ]
// }
// }
// }
// }
// feature_lists: {
// feature_list: {
// key : "movie_ratings"
// value: {
// feature: {
// float_list: {
// value: [ 4.5 ]
// }
// }
// feature: {
// float_list: {
// value: [ 5.0 ]
// }
// }
// }
// }
// feature_list: {
// key : "movie_names"
// value: {
// feature: {
// bytes_list: {
// value: [ "The Shawshank Redemption" ]
// }
// }
// feature: {
// bytes_list: {
// value: [ "Fight Club" ]
// }
// }
// }
// }
// feature_list: {
// key : "actors"
// value: {
// feature: {
// bytes_list: {
// value: [ "Tim Robbins", "Morgan Freeman" ]
// }
// }
// feature: {
// bytes_list: {
// value: [ "Brad Pitt", "Edward Norton", "Helena Bonham Carter" ]
// }
// }
// }
// }
// }
//
// A conformant SequenceExample data set obeys the following conventions:
//
// Context:
// - All conformant context features K must obey the same conventions as
// a conformant Example's features (see above).
// Feature lists:
// - A FeatureList L may be missing in an example; it is up to the
// parser configuration to determine if this is allowed or considered
// an empty list (zero length).
// - If a FeatureList L exists, it may be empty (zero length).
// - If a FeatureList L is non-empty, all features within the FeatureList
// must have the same data type T. Even across SequenceExamples, the type T
// of the FeatureList identified by the same key must be the same. An entry
// without any values may serve as an empty feature.
// - If a FeatureList L is non-empty, it is up to the parser configuration
// to determine if all features within the FeatureList must
// have the same size. The same holds for this FeatureList across multiple
// examples.
// - For sequence modeling, e.g.:
// http://colah.github.io/posts/2015-08-Understanding-LSTMs/
// https://github.com/tensorflow/nmt
// the feature lists represent a sequence of frames.
// In this scenario, all FeatureLists in a SequenceExample have the same
// number of Feature messages, so that the ith element in each FeatureList
// is part of the ith frame (or time step).
// Examples of conformant and non-conformant examples' FeatureLists:
//
// Conformant FeatureLists:
// feature_lists: { feature_list: {
// key: "movie_ratings"
// value: { feature: { float_list: { value: [ 4.5 ] } }
// feature: { float_list: { value: [ 5.0 ] } } }
// } }
//
// Non-conformant FeatureLists (mismatched types):
// feature_lists: { feature_list: {
// key: "movie_ratings"
// value: { feature: { float_list: { value: [ 4.5 ] } }
// feature: { int64_list: { value: [ 5 ] } } }
// } }
//
// Conditionally conformant FeatureLists, the parser configuration determines
// if the feature sizes must match:
// feature_lists: { feature_list: {
// key: "movie_ratings"
// value: { feature: { float_list: { value: [ 4.5 ] } }
// feature: { float_list: { value: [ 5.0, 6.0 ] } } }
// } }
//
// Conformant pair of SequenceExample
// feature_lists: { feature_list: {
// key: "movie_ratings"
// value: { feature: { float_list: { value: [ 4.5 ] } }
// feature: { float_list: { value: [ 5.0 ] } } }
// } }
// and:
// feature_lists: { feature_list: {
// key: "movie_ratings"
// value: { feature: { float_list: { value: [ 4.5 ] } }
// feature: { float_list: { value: [ 5.0 ] } }
// feature: { float_list: { value: [ 2.0 ] } } }
// } }
//
// Conformant pair of SequenceExample
// feature_lists: { feature_list: {
// key: "movie_ratings"
// value: { feature: { float_list: { value: [ 4.5 ] } }
// feature: { float_list: { value: [ 5.0 ] } } }
// } }
// and:
// feature_lists: { feature_list: {
// key: "movie_ratings"
// value: { }
// } }
//
// Conditionally conformant pair of SequenceExample, the parser configuration
// determines if the second feature_lists is consistent (zero-length) or
// invalid (missing "movie_ratings"):
// feature_lists: { feature_list: {
// key: "movie_ratings"
// value: { feature: { float_list: { value: [ 4.5 ] } }
// feature: { float_list: { value: [ 5.0 ] } } }
// } }
// and:
// feature_lists: { }
//
// Non-conformant pair of SequenceExample (mismatched types)
// feature_lists: { feature_list: {
// key: "movie_ratings"
// value: { feature: { float_list: { value: [ 4.5 ] } }
// feature: { float_list: { value: [ 5.0 ] } } }
// } }
// and:
// feature_lists: { feature_list: {
// key: "movie_ratings"
// value: { feature: { int64_list: { value: [ 4 ] } }
// feature: { int64_list: { value: [ 5 ] } }
// feature: { int64_list: { value: [ 2 ] } } }
// } }
//
// Conditionally conformant pair of SequenceExample; the parser configuration
// determines if the feature sizes must match:
// feature_lists: { feature_list: {
// key: "movie_ratings"
// value: { feature: { float_list: { value: [ 4.5 ] } }
// feature: { float_list: { value: [ 5.0 ] } } }
// } }
// and:
// feature_lists: { feature_list: {
// key: "movie_ratings"
// value: { feature: { float_list: { value: [ 4.0 ] } }
// feature: { float_list: { value: [ 5.0, 3.0 ] } }
// } }
message SequenceExample {
Features context = 1;
FeatureLists feature_lists = 2;
}
// LINT.ThenChange(
// https://www.tensorflow.org/code/tensorflow/python/training/training.py)

View File

@ -1,110 +0,0 @@
// Protocol messages for describing features for machine learning model
// training or inference.
//
// There are three base Feature types:
// - bytes
// - float
// - int64
//
// A Feature contains Lists which may hold zero or more values. These
// lists are the base values BytesList, FloatList, Int64List.
//
// Features are organized into categories by name. The Features message
// contains the mapping from name to Feature.
//
// Example Features for a movie recommendation application:
// feature {
// key: "age"
// value { float_list {
// value: 29.0
// }}
// }
// feature {
// key: "movie"
// value { bytes_list {
// value: "The Shawshank Redemption"
// value: "Fight Club"
// }}
// }
// feature {
// key: "movie_ratings"
// value { float_list {
// value: 9.0
// value: 9.7
// }}
// }
// feature {
// key: "suggestion"
// value { bytes_list {
// value: "Inception"
// }}
// }
// feature {
// key: "suggestion_purchased"
// value { int64_list {
// value: 1
// }}
// }
// feature {
// key: "purchase_price"
// value { float_list {
// value: 9.99
// }}
// }
//
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "FeatureProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.example";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/example";
// LINT.IfChange
// Containers to hold repeated fundamental values.
message BytesList {
repeated bytes value = 1;
}
message FloatList {
repeated float value = 1 [packed = true];
}
message Int64List {
repeated int64 value = 1 [packed = true];
}
// Containers for non-sequential data.
message Feature {
// Each feature can be exactly one kind.
oneof kind {
BytesList bytes_list = 1;
FloatList float_list = 2;
Int64List int64_list = 3;
}
}
message Features {
// Map from feature name to feature.
map<string, Feature> feature = 1;
}
// Containers for sequential data.
//
// A FeatureList contains lists of Features. These may hold zero or more
// Feature values.
//
// FeatureLists are organized into categories by name. The FeatureLists message
// contains the mapping from name to FeatureList.
//
message FeatureList {
repeated Feature feature = 1;
}
message FeatureLists {
// Map from feature name to feature list.
map<string, FeatureList> feature_list = 1;
}
// LINT.ThenChange(
// https://www.tensorflow.org/code/tensorflow/python/training/training.py)

View File

@ -1,29 +0,0 @@
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "AllocationDescriptionProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/allocation_description_go_proto";
message AllocationDescription {
// Total number of bytes requested
int64 requested_bytes = 1;
// Total number of bytes allocated if known
int64 allocated_bytes = 2;
// Name of the allocator used
string allocator_name = 3;
// Identifier of the allocated buffer if known
int64 allocation_id = 4;
// Set if this tensor only has one remaining reference
bool has_single_reference = 5;
// Address of the allocation.
uint64 ptr = 6;
}

View File

@ -1,138 +0,0 @@
// Defines the text format for including per-op API definition and
// overrides for client language op code generators.
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/attr_value.proto";
option cc_enable_arenas = true;
option java_outer_classname = "ApiDefProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/api_def_go_proto";
// Used to specify and override the default API & behavior in the
// generated code for client languages, from what you would get from
// the OpDef alone. There will be a set of ApiDefs that are common
// to all client languages, and another set per client language.
// The per-client-language ApiDefs will inherit values from the
// common ApiDefs which it can either replace or modify.
//
// We separate the API definition from the OpDef so we can evolve the
// API while remaining backwards compatible when interpreting old
// graphs. Overrides go in an "api_def.pbtxt" file with a text-format
// ApiDefs message.
//
// WARNING: Be *very* careful changing the API for any existing op --
// you can change the semantics of existing code. These changes may
// need to wait until a major release of TensorFlow to avoid breaking
// our compatibility promises.
message ApiDef {
// Name of the op (in the OpDef) to specify the API for.
string graph_op_name = 1;
// If this op is deprecated, set deprecation message to the message
// that should be logged when this op is used.
// The message should indicate alternative op to use, if any.
string deprecation_message = 12;
// Major version when the op will be deleted. For e.g. set this
// value to 2 if op API should be removed in TensorFlow 2.0 and
// deprecated in versions before that.
int32 deprecation_version = 13;
enum Visibility {
// Normally this is "VISIBLE" unless you are inheriting a
// different value from another ApiDef.
DEFAULT_VISIBILITY = 0;
// Publicly visible in the API.
VISIBLE = 1;
// Do not include this op in the generated API. If visibility is
// set to 'SKIP', other fields are ignored for this op.
SKIP = 2;
// Hide this op by putting it into an internal namespace (or whatever
// is appropriate in the target language).
HIDDEN = 3;
}
Visibility visibility = 2;
// If you specify any endpoint, this will replace all of the
// inherited endpoints. The first endpoint should be the
// "canonical" endpoint, and should not be deprecated (unless all
// endpoints are deprecated).
message Endpoint {
// Name should be either like "CamelCaseName" or
// "Package.CamelCaseName". Client-language-specific ApiDefs may
// use a snake_case convention instead of CamelCase.
string name = 1;
// Set if this endpoint is deprecated. If set to true, a message suggesting
// to use a non-deprecated endpoint instead will be printed. If all
// endpoints are deprecated, set deprecation_message in ApiDef instead.
bool deprecated = 3;
// Major version when an endpoint will be deleted. For e.g. set this
// value to 2 if endpoint should be removed in TensorFlow 2.0 and
// deprecated in versions before that.
int32 deprecation_version = 4;
}
repeated Endpoint endpoint = 3;
message Arg {
string name = 1;
// Change the name used to access this arg in the API from what
// is used in the GraphDef. Note that these names in `backticks`
// will also be replaced in the summary & description fields.
string rename_to = 2;
// Note: this will replace any inherited arg doc. There is no
// current way of modifying arg descriptions (other than replacing
// them entirely) as can be done with op descriptions.
string description = 3;
}
repeated Arg in_arg = 4;
repeated Arg out_arg = 5;
// List of original in_arg names to specify new argument order.
// Length of arg_order should be either empty to keep current order
// or match size of in_arg.
repeated string arg_order = 11;
// Description of the graph-construction-time configuration of this
// Op. That is to say, this describes the attr fields that will
// be specified in the NodeDef.
message Attr {
string name = 1;
// Change the name used to access this attr in the API from what
// is used in the GraphDef. Note that these names in `backticks`
// will also be replaced in the summary & description fields.
string rename_to = 2;
// Specify a new default value to use for this attr. This default
// will be used when creating new graphs, as opposed to the
// default in the OpDef, which will be used when interpreting old
// GraphDefs.
AttrValue default_value = 3;
// Note: this will replace any inherited attr doc, there is no current
// way of modifying attr descriptions as can be done with op descriptions.
string description = 4;
}
repeated Attr attr = 6;
// One-line human-readable description of what the Op does.
string summary = 7;
// Additional, longer human-readable description of what the Op does.
string description = 8;
// Modify an existing/inherited description by adding text to the beginning
// or end.
string description_prefix = 9;
string description_suffix = 10;
}
message ApiDefs {
repeated ApiDef op = 1;
}

View File

@ -1,64 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/tensor.proto";
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/types.proto";
option cc_enable_arenas = true;
option java_outer_classname = "AttrValueProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/attr_value_go_proto";
// Protocol buffer representing the value for an attr used to configure an Op.
// Comment indicates the corresponding attr type. Only the field matching the
// attr type may be filled.
message AttrValue {
// LINT.IfChange
message ListValue {
repeated bytes s = 2; // "list(string)"
repeated int64 i = 3 [packed = true]; // "list(int)"
repeated float f = 4 [packed = true]; // "list(float)"
repeated bool b = 5 [packed = true]; // "list(bool)"
repeated DataType type = 6 [packed = true]; // "list(type)"
repeated TensorShapeProto shape = 7; // "list(shape)"
repeated TensorProto tensor = 8; // "list(tensor)"
repeated NameAttrList func = 9; // "list(attr)"
}
// LINT.ThenChange(https://www.tensorflow.org/code/tensorflow/c/c_api.cc)
oneof value {
bytes s = 2; // "string"
int64 i = 3; // "int"
float f = 4; // "float"
bool b = 5; // "bool"
DataType type = 6; // "type"
TensorShapeProto shape = 7; // "shape"
TensorProto tensor = 8; // "tensor"
ListValue list = 1; // any "list(...)"
// "func" represents a function. func.name is a function's name or
// a primitive op's name. func.attr.first is the name of an attr
// defined for that function. func.attr.second is the value for
// that attr in the instantiation.
NameAttrList func = 10;
// This is a placeholder only used in nodes defined inside a
// function. It indicates the attr value will be supplied when
// the function is instantiated. For example, let us suppose a
// node "N" in function "FN". "N" has an attr "A" with value
// placeholder = "foo". When FN is instantiated with attr "foo"
// set to "bar", the instantiated node N's attr A will have been
// given the value "bar".
string placeholder = 9;
}
}
// A list of attr names and their values. The whole list is attached
// with a string name. E.g., MatMul[T=float].
message NameAttrList {
string name = 1;
map<string, AttrValue> attr = 2;
}

View File

@ -1,89 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/types.proto";
option cc_enable_arenas = true;
option java_outer_classname = "CostGraphProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/cost_graph_go_proto";
message CostGraphDef {
message Node {
// The name of the node. Names are globally unique.
string name = 1;
// The device of the node. Can be empty if the node is mapped to the
// default partition or partitioning hasn't been run yet.
string device = 2;
// The id of the node. Node ids are only unique inside a partition.
int32 id = 3;
// Inputs of this node. They must be executed before this node can be
// executed. An input is a particular output of another node, specified
// by the node id and the output index.
message InputInfo {
int32 preceding_node = 1;
int32 preceding_port = 2;
}
repeated InputInfo input_info = 4;
// Outputs of this node.
message OutputInfo {
int64 size = 1;
// If >= 0, the output is an alias of an input. Note that an alias input
// may itself be an alias. The algorithm will therefore need to follow
// those pointers.
int64 alias_input_port = 2;
TensorShapeProto shape = 3;
DataType dtype = 4;
}
repeated OutputInfo output_info = 5;
// Temporary memory used by this node.
int64 temporary_memory_size = 6;
// Persistent memory used by this node.
int64 persistent_memory_size = 12;
int64 host_temp_memory_size = 10 [deprecated = true];
int64 device_temp_memory_size = 11 [deprecated = true];
int64 device_persistent_memory_size = 16 [deprecated = true];
// Estimate of the computational cost of this node, in microseconds.
int64 compute_cost = 9;
// Analytical estimate of the computational cost of this node, in
// microseconds.
int64 compute_time = 14;
// Analytical estimate of the memory access cost of this node, in
// microseconds.
int64 memory_time = 15;
// If true, the output is permanent: it can't be discarded, because this
// node is part of the "final output". Nodes may depend on final nodes.
bool is_final = 7;
// Ids of the control inputs for this node.
repeated int32 control_input = 8;
// Are the costs inaccurate?
bool inaccurate = 17;
}
repeated Node node = 1;
// Total cost of this graph, typically used for balancing decisions.
message AggregatedCost {
// Aggregated cost value.
float cost = 1;
// Aggregated cost dimension (e.g. 'memory', 'compute', 'network').
string dimension = 2;
}
repeated AggregatedCost cost = 2;
}

View File

@ -1,10 +0,0 @@
syntax = "proto3";
package tensorflow.data;
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/dataset_metadata_go_proto";
// next: 2
message Metadata {
bytes name = 1;
}

View File

@ -1,196 +0,0 @@
syntax = "proto3";
package tensorflow.data;
import "tensorflow/core/framework/model.proto";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/dataset_options_go_proto";
// Represents the type of auto-sharding we enable.
enum AutoShardPolicy {
// AUTO: Attempts FILE-based sharding, falling back to DATA-based sharding.
AUTO = 0;
// FILE: Shards by input files (i.e. each worker will get a set of files to
// process). When this option is selected, make sure that there is at least as
// many files as workers. If there are fewer input files than workers, a
// runtime error will be raised.
FILE = 1;
// DATA: Shards by elements produced by the dataset. Each worker will process
// the whole dataset and discard the portion that is not for itself. Note that
// for this mode to correctly partitions the dataset elements, the dataset
// needs to produce elements in a deterministic order.
DATA = 2;
// HINT: Looks for the presence of `shard(SHARD_HINT, ...)` which is treated
// as a placeholder to replace with `shard(num_workers, worker_index)`.
HINT = 3;
// OFF: No sharding will be performed.
OFF = -1;
}
// next: 5
message AutotuneOptions {
// Whether to automatically tune performance knobs.
oneof optional_enabled {
bool enabled = 1;
}
// When autotuning is enabled (through autotune), determines the CPU budget to
// use. Values greater than the number of schedulable CPU cores are allowed
// but may result in CPU contention.
oneof optional_cpu_budget {
int32 cpu_budget = 2;
}
// When autotuning is enabled (through autotune), determines the RAM budget to
// use. Values greater than the available RAM in bytes may result in OOM. If
// 0, defaults to half of the available RAM in bytes.
oneof optional_ram_budget {
int64 ram_budget = 3;
}
// When autotuning is enabled (through autotune), determines the algorithm to
// use. If not explicitly set by user, autotuning will follow HILL_CLIMB
// algorithm but has more flexibility to tune parameters more aggressively,
// in which case the behavior is implementation specific and may change over
// time.
oneof optional_autotune_algorithm {
model.AutotuneAlgorithm autotune_algorithm = 4;
}
}
// next: 2
message CardinalityOptions {
enum ComputeLevel {
CARDINALITY_COMPUTE_UNSPECIFIED = 0;
// Cardinality will only be computed if it can be determined in a cheap
// manner (ie. without reading from file sources). If the cardinality would
// be nontrivial to compute, Cardinality() will return UNKNOWN_CARDINALITY.
CARDINALITY_COMPUTE_LOW = 1;
// Moderate effort will be made to determine cardinality, such as reading
// index data from source files. If significant work is needed to compute
// cardinality (e.g. reading entire source file contents or executing user
// defined functions), Cardinality() will return UNKNOWN_CARDINALITY.
CARDINALITY_COMPUTE_MODERATE = 2;
}
ComputeLevel compute_level = 1;
}
// next: 3
message DistributeOptions {
AutoShardPolicy auto_shard_policy = 1;
// The number of devices attached to this input pipeline.
oneof optional_num_devices {
int32 num_devices = 2;
}
}
// next: 18
message OptimizationOptions {
// Whether to apply default graph optimizations. If False, only graph
// optimizations that have been explicitly enabled will be applied.
oneof optional_apply_default_optimizations {
bool apply_default_optimizations = 1;
}
reserved 2;
reserved 3;
reserved 4;
reserved 5;
// Whether to fuse filter transformations.
oneof optional_filter_fusion {
bool filter_fusion = 6;
}
// NOTE: field id 7 deleted in June 2021.
reserved 7;
// NOTE: field id 8 deleted in June 2021.
reserved 8;
// Whether to fuse map and batch transformations.
oneof optional_map_and_batch_fusion {
bool map_and_batch_fusion = 9;
}
// Whether to fuse map and filter transformations.
oneof optional_map_and_filter_fusion {
bool map_and_filter_fusion = 10;
}
// Whether to fuse map transformations.
oneof optional_map_fusion {
bool map_fusion = 11;
}
// Whether to parallelize stateless map transformations.
oneof optional_map_parallelization {
bool map_parallelization = 12;
}
// NOTE: field id 13 deleted in June 2021.
reserved 13;
// Whether to eliminate no-op transformations.
oneof optional_noop_elimination {
bool noop_elimination = 14;
}
// Whether to parallelize copying of batch elements. This optimization is
// highly experimental and can cause performance degradation (e.g. when the
// parallelization overhead exceeds the benefits of performing the data copies
// in parallel). You should only enable this optimization if a) your input
// pipeline is bottlenecked on batching and b) you have validated that this
// optimization improves performance.
oneof optional_parallel_batch {
bool parallel_batch = 15;
}
// Field id 16 was removed in 06/2021.
reserved 16;
// Whether to fuse shuffle and repeat transformations.
oneof optional_shuffle_and_repeat_fusion {
bool shuffle_and_repeat_fusion = 17;
}
}
// next: 3
message ThreadingOptions {
// If set, it overrides the maximum degree of intra-op parallelism.
oneof optional_max_intra_op_parallelism {
int32 max_intra_op_parallelism = 1;
}
// If set, the dataset will use a private threadpool of the given size.
oneof optional_private_threadpool_size {
int32 private_threadpool_size = 2;
}
}
// Represents how to handle external state during serialization.
enum ExternalStatePolicy {
POLICY_WARN = 0;
POLICY_IGNORE = 1;
POLICY_FAIL = 2;
}
// Message stored with Dataset objects to control how datasets are processed and
// optimized.
//
// next: 8
message Options {
// Whether the outputs need to be produced in deterministic order.
oneof optional_deterministic {
bool deterministic = 1;
}
// The distribution strategy options associated with the dataset.
AutotuneOptions autotune_options = 7;
// The distribution strategy options associated with the dataset.
DistributeOptions distribute_options = 2;
// The optimization options associated with the dataset.
OptimizationOptions optimization_options = 3;
// Whether to introduce 'slack' in the last `prefetch` of the input pipeline,
// if it exists. This may reduce CPU contention with accelerator host-side
// activity at the start of a step. The slack frequency is determined by the
// number of devices attached to this input pipeline.
oneof optional_slack {
bool slack = 4;
}
// The threading options associated with the dataset.
ThreadingOptions threading_options = 5;
// This option can be used to override the default policy for how to handle
// external state when serializing a dataset or checkpointing its iterator.
// There are three settings available - IGNORE: External state is ignored
// without a warning; WARN: External state is ignored and a warning is logged;
// FAIL: External state results in an error.
oneof optional_external_state_policy {
ExternalStatePolicy external_state_policy = 6;
}
}

View File

@ -1,58 +0,0 @@
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "DeviceAttributesProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/device_attributes_go_proto";
message InterconnectLink {
int32 device_id = 1;
string type = 2;
int32 strength = 3;
}
message LocalLinks {
repeated InterconnectLink link = 1;
}
message DeviceLocality {
// Optional bus locality of device. Default value of 0 means
// no specific locality. Specific localities are indexed from 1.
int32 bus_id = 1;
// Optional NUMA locality of device.
int32 numa_node = 2;
// Optional local interconnect links to other devices.
LocalLinks links = 3;
}
message DeviceAttributes {
// Fully specified name of the device within a cluster.
string name = 1;
// String representation of device_type.
string device_type = 2;
// Memory capacity of device in bytes.
int64 memory_limit = 4;
// Platform-specific data about device that may be useful
// for supporting efficient data transfers.
DeviceLocality locality = 5;
// A device is assigned a global unique number each time it is
// initialized. "incarnation" should never be 0.
fixed64 incarnation = 6;
// String representation of the physical device that this device maps to.
string physical_device_desc = 7;
// A physical device ID for use in XLA DeviceAssignments, unique across
// clients in a multi-client setup. Set to -1 if unavailable, non-negative
// otherwise.
int64 xla_global_id = 8;
}

View File

@ -1,276 +0,0 @@
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "FullTypeProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/full_type_go_proto";
// Experimental. Represents the complete type information of a TensorFlow value.
enum FullTypeId {
// The default represents an uninitialized values.
TFT_UNSET = 0;
// Type symbols. Used to construct more complex type expressions like
// algebraic data types.
// Type variables may serve as placeholder for any other type ID in type
// templates.
//
// Examples:
// TFT_DATASET[TFT_VAR["T"]] is a Dataset returning a type indicated by "T".
// TFT_TENSOR[TFT_VAR["T"]] is a Tensor of n element type indicated by "T".
// TFT_TENSOR[TFT_VAR["T"]], TFT_TENSOR[TFT_VAR["T"]] are two tensors of
// identical element types.
// TFT_TENSOR[TFT_VAR["P"]], TFT_TENSOR[TFT_VAR["Q"]] are two tensors of
// independent element types.
//
TFT_VAR = 1;
// Wildcard type. Describes a parameter of unknown type. In TensorFlow, that
// can mean either a "Top" type (accepts any type), or a dynamically typed
// object whose type is unknown in context.
// Important: "unknown" does not necessarily mean undeterminable!
TFT_ANY = 2;
// The algebraic product type. This is an algebraic type that may be used just
// for logical grouping. Not to confused with TFT_TUPLE which describes a
// concrete object of several elements.
//
// Example:
// TFT_DATASET[TFT_PRODUCT[TFT_TENSOR[TFT_INT32], TFT_TENSOR[TFT_FLOAT64]]]
// is a Dataset producing two tensors, an integer one and a float one.
//
TFT_PRODUCT = 3;
// Represents a named field, with the name stored in the attribute.
//
// Parametrization:
// TFT_NAMED[<type>]{<name>}
// * <type> is the type of the field
// * <name> is the field name, as string (thpugh can theoretically be an int
// as well)
//
// Example:
// TFT_RECORD[
// TFT_NAMED[TFT_TENSOR[TFT_INT32]]{'foo'},
// TFT_NAMED[TFT_TENSOR[TFT_FLOAT32]]{'bar'},
// ]
// is a structure with two fields, an int tensor "foo" and a float tensor
// "bar".
TFT_NAMED = 4;
// Template definition. Expands the variables by repeating a template as
// arguments of container.
//
// Parametrization:
// TFT_FOR_EACH[<container_type>, <template>, <expansions>]
// * <container_type> is the type of the container that the template will be
// expanded into
// * <template> is any type definition that potentially contains type
// variables
// * <expansions> is a TFT_VAR and may include more types in the future
//
// Example:
// TFT_FOR_EACH[
// TFT_PRODUCT,
// TFT_TENSOR[TFT_VAR["t"]],
// TFT_VAR["t"]
// ]
// will substitute a T = TFT_INT32 to TFT_PRODUCT[TFT_TENSOR[TFT_INT32]]
// and a T = (TFT_INT32, TFT_INT64) to
// TFT_PRODUCT[TFT_TENSOR[TFT_INT32], TFT_TENSOR[TFT_INT64]].
TFT_FOR_EACH = 20;
// Callable types describe functions and ops.
//
// Parametrization:
// TFT_CALLABLE[<arg type>, <return type>]
// * <arg type> is the type of the arguments; TFT_PRODUCT represents
// multiple
// arguments.
// * <return type> is the return type; TFT_PRODUCT represents multiple
// return values (that means that callables returning multiple things
// don't necessarily return a single tuple).
//
// Example:
// TFT_CALLABLE[
// TFT_ANY,
// TFT_PRODUCT[TFT_TENSOR[TFT_INT32], TFT_TENSOR[TFT_FLOAT64]],
// ]
// is a callable with unspecified (for now) input arguments, and
// two return values of type tensor.
//
TFT_CALLABLE = 100;
// Concrete type IDs, representing "proper" data types that can describe
// runtime TensorFlow objects.
// The usual Tensor. This is a parametric type.
//
// Parametrization:
// TFT_TENSOR[<element type>, <shape type>]
// * <element type> is currently limited to one of the element types
// defined below.
// * <shape type> is not yet defined, and may only be TFT_UNKNOWN for now.
//
// A TFT_SHAPE type will be defined in the future.
//
// Example:
// TFT_TENSOR[TFT_INT32, TFT_UNKNOWN]
// is a Tensor of int32 element type and unknown shape.
//
// TODO(mdan): Define TFT_SHAPE and add more examples.
TFT_TENSOR = 1000;
// Array (or tensorflow::TensorList in the variant type registry).
// Note: this is not to be confused with the deprecated `TensorArray*` ops
// which are not supported by FullType.
// This type represents a random-access list whose elements can be
// described by a single type. Although immutable, Array is expected to
// support efficient mutation semantics (i.e. element update) in the
// user-facing API.
// The element type may be generic or even TFT_ANY for a heterogenous list.
//
// Parametrization:
// TFT_ARRAY[<element type>]
// * <element type> may be any concrete type.
//
// Examples:
// TFT_ARRAY[TFT_TENSOR[TFT_INT32]] is a TensorArray holding int32 Tensors
// of any shape.
// TFT_ARRAY[TFT_TENSOR[TFT_UNKNOWN]] is a TensorArray holding Tensors of
// mixed element types.
// TFT_ARRAY[TFT_UNKNOWN] is a TensorArray holding any element type.
// TFT_ARRAY[] is equivalent to TFT_ARRAY[TFT_UNKNOWN].
// TFT_ARRAY[TFT_ARRAY[]] is an array or arrays (of unknown types).
TFT_ARRAY = 1001;
// Optional (or tensorflow::OptionalVariant in the variant type registry).
// This type represents a value that may either hold an element of a single
// specified type, or nothing at all.
//
// Parametrization:
// TFT_OPTIONAL[<element type>]
// * <element type> may be any concrete type.
//
// Examples:
// TFT_OPTIONAL[TFT_TENSOR[TFT_INT32]] is an Optional holding an int32
// Tensor of any shape.
TFT_OPTIONAL = 1002;
// Literal types describe compile-time constant values.
// Literal types may also participate in dependent types.
//
// Parametrization:
// TFT_LITERAL[<value type>]{<value>}
// * <value type> may be any concrete type compatible that can hold <value>
// * <value> is the type's attribute, and holds the actual literal value
//
// Examples:
// TFT_LITERAL[TFT_INT32]{1} is the compile-time constant 1.
TFT_LITERAL = 1003;
// Type attributes. These always appear in the parametrization of a type,
// never alone. For example, there is no such thing as a "bool" TensorFlow
// object (for now).
// The bool element type.
// TODO(mdan): Quantized types, legacy representations (e.g. ref)
TFT_BOOL = 200;
// Integer element types.
TFT_UINT8 = 201;
TFT_UINT16 = 202;
TFT_UINT32 = 203;
TFT_UINT64 = 204;
TFT_INT8 = 205;
TFT_INT16 = 206;
TFT_INT32 = 207;
TFT_INT64 = 208;
// Floating-point element types.
TFT_HALF = 209;
TFT_FLOAT = 210;
TFT_DOUBLE = 211;
TFT_BFLOAT16 = 215;
// Complex element types.
// TODO(mdan): Represent as TFT_COMPLEX[TFT_DOUBLE] instead?
TFT_COMPLEX64 = 212;
TFT_COMPLEX128 = 213;
// The string element type.
TFT_STRING = 214;
// Other types that we don't know yet whether they will become part of the
// core type system or be consisdered third-party (and consequently moved to
// user-defined type mechanisms). Presently, they are effectively in the core
// type system, because key compilation passes like Placer account for their
// existence.
// Datasets created by tf.data ops and APIs. Datasets have generator/iterable
// semantics, that is, one can construct an iterator from them. Like
// Array, they are considered to return elements that can be described
// by a single type. Unlike Array, they do not support random access or
// mutation, and can potentially produce an infinite number of elements.
// A datasets can produce logical structures (e.g. multiple elements). This
// is expressed using TFT_PRODUCT.
//
//
// Parametrization: TFT_ARRAY[<element type>].
// * <element type> may be a concrete type or a type symbol. It represents
// the data type of the elements produced by the dataset.
//
// Examples:
// TFT_DATSET[TFT_TENSOR[TFT_INT32]] is a Dataset producing single int32
// Tensors of unknown shape.
// TFT_DATSET[TFT_PRODUCT[TFT_TENSOR[TFT_INT32], TFT_TENSOR[TFT_FLOAT32]] is
// a Dataset producing pairs of Tensors, one integer and one float.
// Note: The high ID number is to prepare for the eventuality that Datasets
// will be supported by user types in the future.
TFT_DATASET = 10102;
// A ragged tensor created by tf.ragged ops and APIs.
//
// Parametrization: TFT_RAGGED[<element_type>].
TFT_RAGGED = 10103;
// A mutex lock tensor, produced by tf.raw_ops.MutexLock.
// Unlike strict execution models, where ownership of a lock is denoted by
// "running after the lock has been acquired", in non-strict mode, lock
// ownership is in the true sense: "the op argument representing the lock is
// available".
// Mutex locks are the dynamic counterpart of control dependencies.
// TODO(mdan): Properly document this thing.
//
// Parametrization: TFT_MUTEX_LOCK[].
TFT_MUTEX_LOCK = 10202;
// The equivalent of a Tensor with DT_VARIANT dtype, kept here to simplify
// translation. This type should not normally appear after type inference.
// Note that LEGACY_VARIANT != ANY: TENSOR[INT32] is a subtype of ANY, but is
// not a subtype of LEGACY_VARIANT.
TFT_LEGACY_VARIANT = 10203;
}
// Highly experimental and very likely to change.
// This encoding uses tags instead of dedicated messages for regularity. In
// particular the encoding imposes no restrictions on what the parameters of any
// type should be, which in particular needs to be true for type symbols.
message FullTypeDef {
// The principal type represented by this object. This may be a concrete type
// (Tensor, Dataset) a type variable (used for dependent types) a type
// symbol (Any, Union). See FullTypeId for details.
FullTypeId type_id = 1;
repeated FullTypeDef args = 2;
// Literal values of this type object, if the the type admits one.
// For example, a type variable admits a string attribute - its name.
// Shape-related types may admit int attributes - their static shape values.
// Fields for more data types to be added as needed.
oneof attr {
string s = 3;
int64 i = 4;
// TODO(mdan): list/tensor, map? Need to reconcile with TFT_RECORD, etc.
}
}

View File

@ -1,136 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/attr_value.proto";
import "tensorflow/core/framework/node_def.proto";
import "tensorflow/core/framework/op_def.proto";
option cc_enable_arenas = true;
option java_outer_classname = "FunctionProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/function_go_proto";
// A library is a set of named functions.
message FunctionDefLibrary {
repeated FunctionDef function = 1;
repeated GradientDef gradient = 2;
repeated RegisteredGradient registered_gradients = 3;
}
// A function can be instantiated when the runtime can bind every attr
// with a value. When a GraphDef has a call to a function, it must
// have binding for every attr defined in the signature.
//
// TODO(zhifengc):
// * device spec, etc.
message FunctionDef {
// The definition of the function's name, arguments, return values,
// attrs etc.
OpDef signature = 1;
// Attributes specific to this function definition.
map<string, AttrValue> attr = 5;
// Attributes for function arguments. These attributes are the same set of
// valid attributes as to _Arg nodes.
message ArgAttrs {
map<string, AttrValue> attr = 1;
}
map<uint32, ArgAttrs> arg_attr = 7;
// Unique IDs for each resource argument, used to track aliasing resources. If
// Argument A and Argument B alias each other, then
// resource_arg_unique_ids[A.index] == resource_arg_unique_ids[B.index].
//
// If this field is empty, none of the arguments could alias; otherwise, every
// resource argument should have an entry in this field.
//
// When instantiated, the unique IDs will be attached to the _Arg nodes'
// "_resource_arg_unique_id" attribute.
map<uint32, uint32> resource_arg_unique_id = 8;
// NOTE: field id 2 deleted on Jan 11, 2017, GraphDef version 21.
reserved 2;
// In both of the following fields, there is the need to specify an
// output that is used as either the input to another node (in
// `node_def`) or as a return value of the function (in `ret`).
// Unlike the NodeDefs in GraphDef, we need to be able to specify a
// list in some cases (instead of just single outputs). Also, we
// need to be able to deal with lists of unknown length (so the
// output index may not be known at function definition time). So
// we use the following format instead:
// * "fun_in" where "fun_in" is the name of a function input arg in
// the `signature` field above. This represents that input, whether
// it is a single tensor or a list.
// * "fun_in:0" gives the first element of a function input arg (a
// non-list input is considered a list of length 1 for these
// purposes).
// * "node:out" where "node" is the name of a node in `node_def` and
// "out" is the name one of its op's output arguments (the name
// comes from the OpDef of the node's op). This represents that
// node's output, whether it is a single tensor or a list.
// Note: We enforce that an op's output arguments are never
// renamed in the backwards-compatibility test.
// * "node:out:0" gives the first element of a node output arg (a
// non-list output is considered a list of length 1 for these
// purposes).
//
// NOT CURRENTLY SUPPORTED (but may be in the future):
// * "node:out:-1" gives last element in a node output list
// * "node:out:1:" gives a list with all but the first element in a
// node output list
// * "node:out::-1" gives a list with all but the last element in a
// node output list
// The body of the function. Unlike the NodeDefs in a GraphDef, attrs
// may have values of type `placeholder` and the `input` field uses
// the "output" format above.
// By convention, "op" in node_def is resolved by consulting with a
// user-defined library first. If not resolved, "func" is assumed to
// be a builtin op.
repeated NodeDef node_def = 3;
// A mapping from the output arg names from `signature` to the
// outputs from `node_def` that should be returned by the function.
map<string, string> ret = 4;
// A mapping from control output names from `signature` to node names in
// `node_def` which should be control outputs of this function.
map<string, string> control_ret = 6;
}
// GradientDef defines the gradient function of a function defined in
// a function library.
//
// A gradient function g (specified by gradient_func) for a function f
// (specified by function_name) must follow the following:
//
// The function 'f' must be a numerical function which takes N inputs
// and produces M outputs. Its gradient function 'g', which is a
// function taking N + M inputs and produces N outputs.
//
// I.e. if we have
// (y1, y2, ..., y_M) = f(x1, x2, ..., x_N),
// then, g is
// (dL/dx1, dL/dx2, ..., dL/dx_N) = g(x1, x2, ..., x_N,
// dL/dy1, dL/dy2, ..., dL/dy_M),
// where L is a scalar-value function of (x1, x2, ..., xN) (e.g., the
// loss function). dL/dx_i is the partial derivative of L with respect
// to x_i.
message GradientDef {
string function_name = 1; // The function name.
string gradient_func = 2; // The gradient function's name.
}
// RegisteredGradient stores a gradient function that is registered in the
// gradients library and used in the ops of a function in the function library.
// Unlike GradientDef, these gradients are identified by op type, and not
// directly linked to any function.
message RegisteredGradient {
string gradient_func = 1; // The gradient function's name.
string registered_op_type = 2; // The gradient function's registered op type.
}

View File

@ -1,56 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/function.proto";
import "tensorflow/core/framework/node_def.proto";
import "tensorflow/core/framework/versions.proto";
option cc_enable_arenas = true;
option java_outer_classname = "GraphProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/graph_go_proto";
// Represents the graph of operations
message GraphDef {
repeated NodeDef node = 1;
// Compatibility versions of the graph. See core/public/version.h for version
// history. The GraphDef version is distinct from the TensorFlow version, and
// each release of TensorFlow will support a range of GraphDef versions.
VersionDef versions = 4;
// Deprecated single version field; use versions above instead. Since all
// GraphDef changes before "versions" was introduced were forward
// compatible, this field is entirely ignored.
int32 version = 3 [deprecated = true];
// "library" provides user-defined functions.
//
// Naming:
// * library.function.name are in a flat namespace.
// NOTE: We may need to change it to be hierarchical to support
// different orgs. E.g.,
// { "/google/nn", { ... }},
// { "/google/vision", { ... }}
// { "/org_foo/module_bar", { ... }}
// map<string, FunctionDefLib> named_lib;
// * If node[i].op is the name of one function in "library",
// node[i] is deemed as a function call. Otherwise, node[i].op
// must be a primitive operation supported by the runtime.
//
//
// Function call semantics:
//
// * The callee may start execution as soon as some of its inputs
// are ready. The caller may want to use Tuple() mechanism to
// ensure all inputs are ready in the same time.
//
// * The consumer of return values may start executing as soon as
// the return values the consumer depends on are ready. The
// consumer may want to use Tuple() mechanism to ensure the
// consumer does not start until all return values of the callee
// function are ready.
FunctionDefLibrary library = 2;
}

View File

@ -1,71 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/types.proto";
option cc_enable_arenas = true;
option java_outer_classname = "GraphTransferInfoProto";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/graph_transfer_info_go_proto";
message GraphTransferNodeInput {
int32 node_id = 1;
int32 output_port = 2;
}
message GraphTransferNodeInfo {
string name = 1;
int32 node_id = 2;
string type_name = 3;
int32 soc_op_id = 4;
int32 padding_id = 5;
int32 input_count = 6;
int32 output_count = 7;
}
message GraphTransferConstNodeInfo {
string name = 1;
int32 node_id = 2;
repeated int64 shape = 3;
bytes data = 4;
DataType dtype = 5;
}
message GraphTransferNodeInputInfo {
int32 node_id = 1;
repeated GraphTransferNodeInput node_input = 2;
}
message GraphTransferNodeOutputInfo {
int32 node_id = 1;
repeated int32 max_byte_size = 2;
}
message GraphTransferGraphInputNodeInfo {
string name = 1;
repeated int64 shape = 2;
DataType dtype = 3;
}
message GraphTransferGraphOutputNodeInfo {
string name = 1;
repeated int64 shape = 2;
DataType dtype = 3;
}
// Protocol buffer representing a handle to a tensorflow resource. Handles are
// not valid across executions, but can be serialized back and forth from within
// a single run.
message GraphTransferInfo {
enum Destination {
NOP = 0;
HEXAGON = 1;
}
repeated GraphTransferNodeInfo node_info = 1;
repeated GraphTransferConstNodeInfo const_node_info = 2;
repeated GraphTransferNodeInputInfo node_input_info = 3;
repeated GraphTransferNodeOutputInfo node_output_info = 4;
// Input Node parameters of transferred graph
repeated GraphTransferGraphInputNodeInfo graph_input_node_info = 5;
repeated GraphTransferGraphOutputNodeInfo graph_output_node_info = 6;
// Destination of graph transfer
Destination destination = 7;
}

View File

@ -1,48 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/attr_value.proto";
option cc_enable_arenas = true;
option java_outer_classname = "KernelDefProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/kernel_def_go_proto";
message KernelDef {
// Must match the name of an Op.
string op = 1;
// Type of device this kernel runs on.
string device_type = 2;
message AttrConstraint {
// Name of an attr from the Op.
string name = 1;
// A list of values that this kernel supports for this attr.
// Like OpDef.AttrDef.allowed_values, except for kernels instead of Ops.
AttrValue allowed_values = 2;
}
repeated AttrConstraint constraint = 3;
// Names of the Op's input_/output_args that reside in host memory
// instead of device memory.
repeated string host_memory_arg = 4;
// This allows experimental kernels to be registered for an op that
// won't be used unless the user specifies a "_kernel" attr with
// value matching this.
string label = 5;
// Prioritization of kernel amongst different devices. By default we assume
// priority is 0. The higher the priority the better. By default (i.e. if
// this is not set), we prefer GPU kernels over CPU.
int32 priority = 6;
}
// A collection of KernelDefs
message KernelList {
repeated KernelDef kernel = 1;
}

View File

@ -1,95 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/tensor_description.proto";
option cc_enable_arenas = true;
option java_outer_classname = "LogMemoryProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/log_memory_go_proto";
message MemoryLogStep {
// Process-unique step id.
int64 step_id = 1;
// Handle describing the feeds and fetches of the step.
string handle = 2;
}
message MemoryLogTensorAllocation {
// Process-unique step id.
int64 step_id = 1;
// Name of the kernel making the allocation as set in GraphDef,
// e.g., "affine2/weights/Assign".
string kernel_name = 2;
// Allocated tensor details.
TensorDescription tensor = 3;
}
message MemoryLogTensorDeallocation {
// Id of the tensor buffer being deallocated, used to match to a
// corresponding allocation.
int64 allocation_id = 1;
// Name of the allocator used.
string allocator_name = 2;
}
message MemoryLogTensorOutput {
// Process-unique step id.
int64 step_id = 1;
// Name of the kernel producing an output as set in GraphDef, e.g.,
// "affine2/weights/Assign".
string kernel_name = 2;
// Index of the output being set.
int32 index = 3;
// Output tensor details.
TensorDescription tensor = 4;
}
message MemoryLogRawAllocation {
// Process-unique step id.
int64 step_id = 1;
// Name of the operation making the allocation.
string operation = 2;
// Number of bytes in the allocation.
int64 num_bytes = 3;
// Address of the allocation.
uint64 ptr = 4;
// Id of the tensor buffer being allocated, used to match to a
// corresponding deallocation.
int64 allocation_id = 5;
// Name of the allocator used.
string allocator_name = 6;
}
message MemoryLogRawDeallocation {
// Process-unique step id.
int64 step_id = 1;
// Name of the operation making the deallocation.
string operation = 2;
// Id of the tensor buffer being deallocated, used to match to a
// corresponding allocation.
int64 allocation_id = 3;
// Name of the allocator used.
string allocator_name = 4;
// True if the deallocation is queued and will be performed later,
// e.g. for GPU lazy freeing of buffers.
bool deferred = 5;
}

View File

@ -1,134 +0,0 @@
syntax = "proto3";
package tensorflow.data.model;
option cc_enable_arenas = true;
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/model_go_proto";
// Class of a node in the performance model.
enum NodeClass {
UNKNOWN = 0;
INTERLEAVE_MANY = 1;
ASYNC_INTERLEAVE_MANY = 2;
KNOWN_RATIO = 3;
ASYNC_KNOWN_RATIO = 4;
UNKNOWN_RATIO = 5;
}
// Algorithm used for model autotuning optimization.
enum AutotuneAlgorithm {
DEFAULT = 0;
HILL_CLIMB = 1;
GRADIENT_DESCENT = 2;
MAX_PARALLELISM = 3;
}
// Protocol buffer representing the data used by the autotuning modeling
// framework.
message ModelProto {
// General representation of a node in the model.
message Node {
// Unique node ID.
int64 id = 1;
// Human-readable name of the node.
string name = 2;
// An indication whether autotuning is enabled for this node.
bool autotune = 3;
// The number of bytes stored in this node's buffer.
int64 buffered_bytes = 4;
// The number of elements stored in this node's buffer.
int64 buffered_elements = 5;
// The number of bytes consumed by the node.
int64 bytes_consumed = 6;
// The number of bytes produced by the node.
int64 bytes_produced = 7;
// The number of elements produced by the node.
int64 num_elements = 8;
// The aggregate processing time spent in this node.
int64 processing_time = 9;
// An indication whether this node records metrics about produced and
// consumed elements.
bool record_metrics = 10;
// Represents a node parameter.
message Parameter {
// Human-readable name of the parameter.
string name = 1;
// Identifies the model value of the parameter. This can be different from
// the actual value (e.g. during optimization search).
double value = 2;
// The actual value of the parameter.
double state_value = 3;
// Minimum value of the parameter.
double min = 4;
// Maximum value of the parameter.
double max = 5;
// Identifies whether the parameter should participate in autotuning.
bool tunable = 6;
}
// Parameters of this node.
repeated Parameter parameters = 11;
// Statistic of inputs processing time history.
double input_processing_time_sum = 12;
int64 input_processing_time_count = 13;
// IDs of inputs of this node.
repeated int64 inputs = 14;
// Class of this node.
NodeClass node_class = 15;
// Ratio of input to output elements. This is only used by KNOWN_RATIO and
// ASYNC_KNOWN_RATIO nodes.
double ratio = 16;
// Ratio identifies how many parallelism calls are introduced by one
// buffered element. This is only used by ASYNC_KNOWN_RATIO nodes.
double memory_ratio = 17;
}
// Map of node IDs to nodes of this model.
map<int64, Node> nodes = 1;
// ID of the output node of this model.
int64 output = 2;
// Counter for node IDs of this model.
int64 id_counter = 3;
reserved 4;
// Contains parameters of the model autotuning optimization.
message OptimizationParams {
// Algorithm used for autotuning optimization.
AutotuneAlgorithm algorithm = 1;
// Number of available logical threads.
int64 cpu_budget = 2;
// Amount of available memory in bytes.
int64 ram_budget = 3;
// Time between two consecutive `GetNext` calls to the iterator represented
// by the output node.
double model_input_time = 4;
}
OptimizationParams optimization_params = 5;
}

View File

@ -1,95 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/attr_value.proto";
import "tensorflow/core/framework/full_type.proto";
option cc_enable_arenas = true;
option java_outer_classname = "NodeProto";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/node_def_go_proto";
message NodeDef {
// The name given to this operator. Used for naming inputs,
// logging, visualization, etc. Unique within a single GraphDef.
// Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_>./]*".
string name = 1;
// The operation name. There may be custom parameters in attrs.
// Op names starting with an underscore are reserved for internal use.
string op = 2;
// Each input is "node:src_output" with "node" being a string name and
// "src_output" indicating which output tensor to use from "node". If
// "src_output" is 0 the ":0" suffix can be omitted. Regular inputs
// may optionally be followed by control inputs that have the format
// "^node".
repeated string input = 3;
// A (possibly partial) specification for the device on which this
// node should be placed.
// The expected syntax for this string is as follows:
//
// DEVICE_SPEC ::= PARTIAL_SPEC
//
// PARTIAL_SPEC ::= ("/" CONSTRAINT) *
// CONSTRAINT ::= ("job:" JOB_NAME)
// | ("replica:" [1-9][0-9]*)
// | ("task:" [1-9][0-9]*)
// | ("device:" [A-Za-z]* ":" ([1-9][0-9]* | "*") )
//
// Valid values for this string include:
// * "/job:worker/replica:0/task:1/device:GPU:3" (full specification)
// * "/job:worker/device:GPU:3" (partial specification)
// * "" (no specification)
//
// If the constraints do not resolve to a single device (or if this
// field is empty or not present), the runtime will attempt to
// choose a device automatically.
string device = 4;
// Operation-specific graph-construction-time configuration.
// Note that this should include all attrs defined in the
// corresponding OpDef, including those with a value matching
// the default -- this allows the default to change and makes
// NodeDefs easier to interpret on their own. However, if
// an attr with a default is not specified in this list, the
// default will be used.
// The "names" (keys) must match the regexp "[a-z][a-z0-9_]+" (and
// one of the names from the corresponding OpDef's attr field).
// The values must have a type matching the corresponding OpDef
// attr's type field.
// TODO(josh11b): Add some examples here showing best practices.
map<string, AttrValue> attr = 5;
message ExperimentalDebugInfo {
// Opaque string inserted into error messages created by the runtime.
//
// This is intended to store the list of names of the nodes from the
// original graph that this node was derived. For example if this node, say
// C, was result of a fusion of 2 nodes A and B, then 'original_node' would
// be {A, B}. This information can be used to map errors originating at the
// current node to some top level source code.
repeated string original_node_names = 1;
// This is intended to store the list of names of the functions from the
// original graph that this node was derived. For example if this node, say
// C, was result of a fusion of node A in function FA and node B in function
// FB, then `original_funcs` would be {FA, FB}. If the node is in the top
// level graph, the `original_func` is empty. This information, with the
// `original_node_names` can be used to map errors originating at the
// current ndoe to some top level source code.
repeated string original_func_names = 2;
}
// This stores debug information associated with the node.
ExperimentalDebugInfo experimental_debug_info = 6;
// The complete type of this node. Experimental and subject to change.
// Currently, the field only contains the return types of the node. That will
// extend in the future to contain the entire signature of the node, as a
// function type.
FullTypeDef experimental_type = 7;
}

View File

@ -1,193 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/attr_value.proto";
import "tensorflow/core/framework/full_type.proto";
import "tensorflow/core/framework/resource_handle.proto";
import "tensorflow/core/framework/types.proto";
option cc_enable_arenas = true;
option java_outer_classname = "OpDefProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/op_def_go_proto";
// Defines an operation. A NodeDef in a GraphDef specifies an Op by
// using the "op" field which should match the name of a OpDef.
// LINT.IfChange
message OpDef {
// Op names starting with an underscore are reserved for internal use.
// Names should be CamelCase and match the regexp "[A-Z][a-zA-Z0-9>_]*".
string name = 1;
// For describing inputs and outputs.
message ArgDef {
// Name for the input/output. Should match the regexp "[a-z][a-z0-9_]*".
string name = 1;
// Human readable description.
string description = 2;
// Describes the type of one or more tensors that are accepted/produced
// by this input/output arg. The only legal combinations are:
// * For a single tensor: either the "type" field is set or the
// "type_attr" field is set to the name of an attr with type "type".
// * For a sequence of tensors with the same type: the "number_attr"
// field will be set to the name of an attr with type "int", and
// either the "type" or "type_attr" field will be set as for
// single tensors.
// * For a sequence of tensors, the "type_list_attr" field will be set
// to the name of an attr with type "list(type)".
DataType type = 3;
string type_attr = 4; // if specified, attr must have type "type"
string number_attr = 5; // if specified, attr must have type "int"
// If specified, attr must have type "list(type)", and none of
// type, type_attr, and number_attr may be specified.
string type_list_attr = 6;
// The handle data for resource inputs.
repeated ResourceHandleProto.DtypeAndShape handle_data = 7;
// For inputs: if true, the inputs are required to be refs.
// By default, inputs can be either refs or non-refs.
// For outputs: if true, outputs are refs, otherwise they are not.
bool is_ref = 16;
// Experimental. Full type declaration for this argument.
// The full type specification combines type, type_attr, type_list_attr,
// etc. into a unified representation.
// This declaration may contain non-concrete types (for example,
// Tensor<TypeVar<'T'>> is a valid type declaration.
//
// Note: this is a transient field. The long-term aim is to represent the
// entire OpDef as a single type: a callable. In that context, this field is
// just the type of a single argument.
FullTypeDef experimental_full_type = 17;
}
// Description of the input(s).
repeated ArgDef input_arg = 2;
// Description of the output(s).
repeated ArgDef output_arg = 3;
// Named control outputs for this operation. Useful only for composite
// operations (i.e. functions) which want to name different control outputs.
repeated string control_output = 20;
// Description of the graph-construction-time configuration of this
// Op. That is to say, this describes the attr fields that will
// be specified in the NodeDef.
message AttrDef {
// A descriptive name for the argument. May be used, e.g. by the
// Python client, as a keyword argument name, and so should match
// the regexp "[a-z][a-z0-9_]+".
string name = 1;
// One of the type names from attr_value.proto ("string", "list(string)",
// "int", etc.).
string type = 2;
// A reasonable default for this attribute if the user does not supply
// a value. If not specified, the user must supply a value.
AttrValue default_value = 3;
// Human-readable description.
string description = 4;
// TODO(josh11b): bool is_optional?
// --- Constraints ---
// These constraints are only in effect if specified. Default is no
// constraints.
// For type == "int", this is a minimum value. For "list(___)"
// types, this is the minimum length.
bool has_minimum = 5;
int64 minimum = 6;
// The set of allowed values. Has type that is the "list" version
// of the "type" field above (uses the "list" field of AttrValue).
// If type == "type" or "list(type)" above, then the "type" field
// of "allowed_values.list" has the set of allowed DataTypes.
// If type == "string" or "list(string)", then the "s" field of
// "allowed_values.list" has the set of allowed strings.
AttrValue allowed_values = 7;
}
repeated AttrDef attr = 4;
// Optional deprecation based on GraphDef versions.
OpDeprecation deprecation = 8;
// One-line human-readable description of what the Op does.
string summary = 5;
// Additional, longer human-readable description of what the Op does.
string description = 6;
// -------------------------------------------------------------------------
// Which optimizations this operation can participate in.
// True if the operation is commutative ("op(a,b) == op(b,a)" for all inputs)
bool is_commutative = 18;
// If is_aggregate is true, then this operation accepts N >= 2
// inputs and produces 1 output all of the same type. Should be
// associative and commutative, and produce output with the same
// shape as the input. The optimizer may replace an aggregate op
// taking input from multiple devices with a tree of aggregate ops
// that aggregate locally within each device (and possibly within
// groups of nearby devices) before communicating.
// TODO(josh11b): Implement that optimization.
bool is_aggregate = 16; // for things like add
// Other optimizations go here, like
// can_alias_input, rewrite_when_output_unused, partitioning_strategy, etc.
// -------------------------------------------------------------------------
// Optimization constraints.
// Ops are marked as stateful if their behavior depends on some state beyond
// their input tensors (e.g. variable reading op) or if they have
// a side-effect (e.g. printing or asserting ops). Equivalently, stateless ops
// must always produce the same output for the same input and have
// no side-effects.
//
// By default Ops may be moved between devices. Stateful ops should
// either not be moved, or should only be moved if that state can also
// be moved (e.g. via some sort of save / restore).
// Stateful ops are guaranteed to never be optimized away by Common
// Subexpression Elimination (CSE).
bool is_stateful = 17; // for things like variables, queue
// -------------------------------------------------------------------------
// Non-standard options.
// By default, all inputs to an Op must be initialized Tensors. Ops
// that may initialize tensors for the first time should set this
// field to true, to allow the Op to take an uninitialized Tensor as
// input.
bool allows_uninitialized_input = 19; // for Assign, etc.
// Indicates whether the op implementation uses distributed communication.
// If True, the op is allowed to return errors for network disconnection and
// trigger TF network failure handling logics.
bool is_distributed_communication = 21;
}
// LINT.ThenChange(
// https://www.tensorflow.org/code/tensorflow/core/framework/op_def_util.cc)
// Information about version-dependent deprecation of an op
message OpDeprecation {
// First GraphDef version at which the op is disallowed.
int32 version = 1;
// Explanation of why it was deprecated and what to use instead.
string explanation = 2;
}
// A collection of OpDefs
message OpList {
repeated OpDef op = 1;
}

View File

@ -1,18 +0,0 @@
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "ReaderBaseProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/reader_base_go_proto";
// For serializing and restoring the state of ReaderBase, see
// reader_base.h for details.
message ReaderBaseState {
int64 work_started = 1;
int64 work_finished = 2;
int64 num_records_produced = 3;
bytes current_work = 4;
}

View File

@ -1,45 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/types.proto";
option cc_enable_arenas = true;
option java_outer_classname = "ResourceHandle";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/resource_handle_go_proto";
// Protocol buffer representing a handle to a tensorflow resource. Handles are
// not valid across executions, but can be serialized back and forth from within
// a single run.
message ResourceHandleProto {
// Unique name for the device containing the resource.
string device = 1;
// Container in which this resource is placed.
string container = 2;
// Unique name of this resource.
string name = 3;
// Hash code for the type of the resource. Is only valid in the same device
// and in the same execution.
uint64 hash_code = 4;
// For debug-only, the name of the type pointed to by this handle, if
// available.
string maybe_type_name = 5;
// Protocol buffer representing a pair of (data type, tensor shape).
message DtypeAndShape {
DataType dtype = 1;
TensorShapeProto shape = 2;
}
// Data types and shapes for the underlying resource.
repeated DtypeAndShape dtypes_and_shapes = 6;
reserved 7;
}

View File

@ -1,88 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/allocation_description.proto";
import "tensorflow/core/framework/tensor_description.proto";
option cc_enable_arenas = true;
option java_outer_classname = "StepStatsProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/step_stats_go_proto";
// An allocation/de-allocation operation performed by the allocator.
message AllocationRecord {
// The timestamp of the operation.
int64 alloc_micros = 1;
// Number of bytes allocated, or de-allocated if negative.
int64 alloc_bytes = 2;
}
message AllocatorMemoryUsed {
string allocator_name = 1;
// These are per-node allocator memory stats.
int64 total_bytes = 2;
int64 peak_bytes = 3;
// The bytes that are not deallocated.
int64 live_bytes = 4;
// The allocation and deallocation timeline.
repeated AllocationRecord allocation_records = 6;
// These are snapshots of the overall allocator memory stats.
// The number of live bytes currently allocated by the allocator.
int64 allocator_bytes_in_use = 5;
}
// Output sizes recorded for a single execution of a graph node.
message NodeOutput {
int32 slot = 1;
TensorDescription tensor_description = 3;
}
// For memory tracking.
message MemoryStats {
int64 temp_memory_size = 1;
int64 persistent_memory_size = 3;
repeated int64 persistent_tensor_alloc_ids = 5;
int64 device_temp_memory_size = 2 [deprecated = true];
int64 device_persistent_memory_size = 4 [deprecated = true];
repeated int64 device_persistent_tensor_alloc_ids = 6 [deprecated = true];
}
// Time/size stats recorded for a single execution of a graph node.
message NodeExecStats {
// TODO(tucker): Use some more compact form of node identity than
// the full string name. Either all processes should agree on a
// global id (cost_id?) for each node, or we should use a hash of
// the name.
string node_name = 1;
int64 all_start_micros = 2;
int64 op_start_rel_micros = 3;
int64 op_end_rel_micros = 4;
int64 all_end_rel_micros = 5;
repeated AllocatorMemoryUsed memory = 6;
repeated NodeOutput output = 7;
string timeline_label = 8;
int64 scheduled_micros = 9;
uint32 thread_id = 10;
repeated AllocationDescription referenced_tensor = 11;
MemoryStats memory_stats = 12;
int64 all_start_nanos = 13;
int64 op_start_rel_nanos = 14;
int64 op_end_rel_nanos = 15;
int64 all_end_rel_nanos = 16;
int64 scheduled_nanos = 17;
}
message DeviceStepStats {
string device = 1;
repeated NodeExecStats node_stats = 2;
// Its key is thread id.
map<uint32, string> thread_names = 3;
}
message StepStats {
repeated DeviceStepStats dev_stats = 1;
}

View File

@ -1,149 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/tensor.proto";
option cc_enable_arenas = true;
option java_outer_classname = "SummaryProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/summary_go_proto";
// Metadata associated with a series of Summary data
message SummaryDescription {
// Hint on how plugins should process the data in this series.
// Supported values include "scalar", "histogram", "image", "audio"
string type_hint = 1;
}
// Serialization format for histogram module in
// core/lib/histogram/histogram.h
message HistogramProto {
double min = 1;
double max = 2;
double num = 3;
double sum = 4;
double sum_squares = 5;
// Parallel arrays encoding the bucket boundaries and the bucket values.
// bucket(i) is the count for the bucket i. The range for
// a bucket is:
// i == 0: -DBL_MAX .. bucket_limit(0)
// i != 0: bucket_limit(i-1) .. bucket_limit(i)
repeated double bucket_limit = 6 [packed = true];
repeated double bucket = 7 [packed = true];
}
// A SummaryMetadata encapsulates information on which plugins are able to make
// use of a certain summary value.
message SummaryMetadata {
message PluginData {
// The name of the plugin this data pertains to.
string plugin_name = 1;
// The content to store for the plugin. The best practice is for this to be
// a binary serialized protocol buffer.
bytes content = 2;
}
// Data that associates a summary with a certain plugin.
PluginData plugin_data = 1;
// Display name for viewing in TensorBoard.
string display_name = 2;
// Longform readable description of the summary sequence. Markdown supported.
string summary_description = 3;
// Class of data stored in this time series. Required for compatibility with
// TensorBoard's generic data facilities (`DataProvider`, et al.). This value
// imposes constraints on the dtype and shape of the corresponding tensor
// values. See `DataClass` docs for details.
DataClass data_class = 4;
}
enum DataClass {
// Unknown data class, used (implicitly) for legacy data. Will not be
// processed by data ingestion pipelines.
DATA_CLASS_UNKNOWN = 0;
// Scalar time series. Each `Value` for the corresponding tag must have
// `tensor` set to a rank-0 tensor of type `DT_FLOAT` (float32).
DATA_CLASS_SCALAR = 1;
// Tensor time series. Each `Value` for the corresponding tag must have
// `tensor` set. The tensor value is arbitrary, but should be small to
// accommodate direct storage in database backends: an upper bound of a few
// kilobytes is a reasonable rule of thumb.
DATA_CLASS_TENSOR = 2;
// Blob sequence time series. Each `Value` for the corresponding tag must
// have `tensor` set to a rank-1 tensor of bytestring dtype.
DATA_CLASS_BLOB_SEQUENCE = 3;
}
// A Summary is a set of named values to be displayed by the
// visualizer.
//
// Summaries are produced regularly during training, as controlled by
// the "summary_interval_secs" attribute of the training operation.
// Summaries are also produced at the end of an evaluation.
message Summary {
message Image {
// Dimensions of the image.
int32 height = 1;
int32 width = 2;
// Valid colorspace values are
// 1 - grayscale
// 2 - grayscale + alpha
// 3 - RGB
// 4 - RGBA
// 5 - DIGITAL_YUV
// 6 - BGRA
int32 colorspace = 3;
// Image data in encoded format. All image formats supported by
// image_codec::CoderUtil can be stored here.
bytes encoded_image_string = 4;
}
message Audio {
// Sample rate of the audio in Hz.
float sample_rate = 1;
// Number of channels of audio.
int64 num_channels = 2;
// Length of the audio in frames (samples per channel).
int64 length_frames = 3;
// Encoded audio data and its associated RFC 2045 content type (e.g.
// "audio/wav").
bytes encoded_audio_string = 4;
string content_type = 5;
}
message Value {
// This field is deprecated and will not be set.
string node_name = 7;
// Tag name for the data. Used by TensorBoard plugins to organize data. Tags
// are often organized by scope (which contains slashes to convey
// hierarchy). For example: foo/bar/0
string tag = 1;
// Contains metadata on the summary value such as which plugins may use it.
// Take note that many summary values may lack a metadata field. This is
// because the FileWriter only keeps a metadata object on the first summary
// value with a certain tag for each tag. TensorBoard then remembers which
// tags are associated with which plugins. This saves space.
SummaryMetadata metadata = 9;
// Value associated with the tag.
oneof value {
float simple_value = 2;
bytes obsolete_old_style_histogram = 3;
Image image = 4;
HistogramProto histo = 5;
Audio audio = 6;
TensorProto tensor = 8;
}
}
// Set of values for the summary.
repeated Value value = 1;
}

View File

@ -1,96 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/resource_handle.proto";
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/types.proto";
option cc_enable_arenas = true;
option java_outer_classname = "TensorProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_go_proto";
// Protocol buffer representing a tensor.
message TensorProto {
DataType dtype = 1;
// Shape of the tensor. TODO(touts): sort out the 0-rank issues.
TensorShapeProto tensor_shape = 2;
// Only one of the representations below is set, one of "tensor_contents" and
// the "xxx_val" attributes. We are not using oneof because as oneofs cannot
// contain repeated fields it would require another extra set of messages.
// Version number.
//
// In version 0, if the "repeated xxx" representations contain only one
// element, that element is repeated to fill the shape. This makes it easy
// to represent a constant Tensor with a single value.
int32 version_number = 3;
// Serialized raw tensor content from either Tensor::AsProtoTensorContent or
// memcpy in tensorflow::grpc::EncodeTensorToByteBuffer. This representation
// can be used for all tensor types. The purpose of this representation is to
// reduce serialization overhead during RPC call by avoiding serialization of
// many repeated small items.
bytes tensor_content = 4;
// Type specific representations that make it easy to create tensor protos in
// all languages. Only the representation corresponding to "dtype" can
// be set. The values hold the flattened representation of the tensor in
// row major order.
// DT_HALF, DT_BFLOAT16. Note that since protobuf has no int16 type, we'll
// have some pointless zero padding for each value here.
repeated int32 half_val = 13 [packed = true];
// DT_FLOAT.
repeated float float_val = 5 [packed = true];
// DT_DOUBLE.
repeated double double_val = 6 [packed = true];
// DT_INT32, DT_INT16, DT_UINT16, DT_INT8, DT_UINT8.
repeated int32 int_val = 7 [packed = true];
// DT_STRING
repeated bytes string_val = 8;
// DT_COMPLEX64. scomplex_val(2*i) and scomplex_val(2*i+1) are real
// and imaginary parts of i-th single precision complex.
repeated float scomplex_val = 9 [packed = true];
// DT_INT64
repeated int64 int64_val = 10 [packed = true];
// DT_BOOL
repeated bool bool_val = 11 [packed = true];
// DT_COMPLEX128. dcomplex_val(2*i) and dcomplex_val(2*i+1) are real
// and imaginary parts of i-th double precision complex.
repeated double dcomplex_val = 12 [packed = true];
// DT_RESOURCE
repeated ResourceHandleProto resource_handle_val = 14;
// DT_VARIANT
repeated VariantTensorDataProto variant_val = 15;
// DT_UINT32
repeated uint32 uint32_val = 16 [packed = true];
// DT_UINT64
repeated uint64 uint64_val = 17 [packed = true];
}
// Protocol buffer representing the serialization format of DT_VARIANT tensors.
message VariantTensorDataProto {
// Name of the type of objects being serialized.
string type_name = 1;
// Portions of the object that are not Tensors.
bytes metadata = 2;
// Tensors contained within objects being serialized.
repeated TensorProto tensors = 3;
}

View File

@ -1,24 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/allocation_description.proto";
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/types.proto";
option cc_enable_arenas = true;
option java_outer_classname = "TensorDescriptionProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_description_go_proto";
message TensorDescription {
// Data type of tensor elements
DataType dtype = 1;
// Shape of the tensor.
TensorShapeProto shape = 2;
// Information about the size and allocator used for the data
AllocationDescription allocation_description = 4;
}

View File

@ -1,46 +0,0 @@
// Protocol buffer representing the shape of tensors.
syntax = "proto3";
option cc_enable_arenas = true;
option java_outer_classname = "TensorShapeProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_shape_go_proto";
package tensorflow;
// Dimensions of a tensor.
message TensorShapeProto {
// One dimension of the tensor.
message Dim {
// Size of the tensor in that dimension.
// This value must be >= -1, but values of -1 are reserved for "unknown"
// shapes (values of -1 mean "unknown" dimension). Certain wrappers
// that work with TensorShapeProto may fail at runtime when deserializing
// a TensorShapeProto containing a dim value of -1.
int64 size = 1;
// Optional name of the tensor dimension.
string name = 2;
};
// Dimensions of the tensor, such as {"input", 30}, {"output", 40}
// for a 30 x 40 2D tensor. If an entry has size -1, this
// corresponds to a dimension of unknown size. The names are
// optional.
//
// The order of entries in "dim" matters: It indicates the layout of the
// values in the tensor in-memory representation.
//
// The first entry in "dim" is the outermost dimension used to layout the
// values, the last entry is the innermost dimension. This matches the
// in-memory layout of RowMajor Eigen tensors.
//
// If "dim.size()" > 0, "unknown_rank" must be false.
repeated Dim dim = 2;
// If true, the number of dimensions in the shape is unknown.
//
// If true, "dim.size()" must be 0.
bool unknown_rank = 3;
};

View File

@ -1,39 +0,0 @@
// Protocol buffer representing slices of a tensor
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "TensorSliceProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_slice_go_proto";
// Can only be interpreted if you know the corresponding TensorShape.
message TensorSliceProto {
// Extent of the slice in one dimension.
message Extent {
// Either both or no attributes must be set. When no attribute is set
// means: All data in that dimension.
// Start index of the slice, starting at 0.
int64 start = 1;
// Length of the slice: if the length is missing or -1 we will
// interpret this as "everything in this dimension". We use
// "oneof" to preserve information about whether the length is
// present without changing the serialization format from the
// prior proto2 version of this proto.
oneof has_length {
int64 length = 2;
}
}
// Extent of the slice in all tensor dimensions.
//
// Must have one entry for each of the dimension of the tensor that this
// slice belongs to. The order of sizes is the same as the order of
// dimensions in the TensorShape.
repeated Extent extent = 1;
}

View File

@ -1,77 +0,0 @@
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "TypesProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/types_go_proto";
// (== suppress_warning documentation-presence ==)
// LINT.IfChange
enum DataType {
// Not a legal value for DataType. Used to indicate a DataType field
// has not been set.
DT_INVALID = 0;
// Data types that all computation devices are expected to be
// capable to support.
DT_FLOAT = 1;
DT_DOUBLE = 2;
DT_INT32 = 3;
DT_UINT8 = 4;
DT_INT16 = 5;
DT_INT8 = 6;
DT_STRING = 7;
DT_COMPLEX64 = 8; // Single-precision complex
DT_INT64 = 9;
DT_BOOL = 10;
DT_QINT8 = 11; // Quantized int8
DT_QUINT8 = 12; // Quantized uint8
DT_QINT32 = 13; // Quantized int32
DT_BFLOAT16 = 14; // Float32 truncated to 16 bits. Only for cast ops.
DT_QINT16 = 15; // Quantized int16
DT_QUINT16 = 16; // Quantized uint16
DT_UINT16 = 17;
DT_COMPLEX128 = 18; // Double-precision complex
DT_HALF = 19;
DT_RESOURCE = 20;
DT_VARIANT = 21; // Arbitrary C++ data types
DT_UINT32 = 22;
DT_UINT64 = 23;
// Do not use! These are only for parameters. Every enum above
// should have a corresponding value below (verified by types_test).
DT_FLOAT_REF = 101;
DT_DOUBLE_REF = 102;
DT_INT32_REF = 103;
DT_UINT8_REF = 104;
DT_INT16_REF = 105;
DT_INT8_REF = 106;
DT_STRING_REF = 107;
DT_COMPLEX64_REF = 108;
DT_INT64_REF = 109;
DT_BOOL_REF = 110;
DT_QINT8_REF = 111;
DT_QUINT8_REF = 112;
DT_QINT32_REF = 113;
DT_BFLOAT16_REF = 114;
DT_QINT16_REF = 115;
DT_QUINT16_REF = 116;
DT_UINT16_REF = 117;
DT_COMPLEX128_REF = 118;
DT_HALF_REF = 119;
DT_RESOURCE_REF = 120;
DT_VARIANT_REF = 121;
DT_UINT32_REF = 122;
DT_UINT64_REF = 123;
}
// LINT.ThenChange(
// https://www.tensorflow.org/code/tensorflow/c/tf_datatype.h,
// https://www.tensorflow.org/code/tensorflow/go/tensor.go,
// https://www.tensorflow.org/code/tensorflow/core/framework/tensor.cc,
// https://www.tensorflow.org/code/tensorflow/core/framework/types.h,
// https://www.tensorflow.org/code/tensorflow/core/framework/types.cc,
// https://www.tensorflow.org/code/tensorflow/python/framework/dtypes.py,
// https://www.tensorflow.org/code/tensorflow/python/framework/function.py)

View File

@ -1,84 +0,0 @@
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "VariableProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/variable_go_proto";
// Indicates when a distributed variable will be synced.
enum VariableSynchronization {
// `AUTO`: Indicates that the synchronization will be determined by the
// current `DistributionStrategy` (eg. With `MirroredStrategy` this would be
// `ON_WRITE`).
VARIABLE_SYNCHRONIZATION_AUTO = 0;
// `NONE`: Indicates that there will only be one copy of the variable, so
// there is no need to sync.
VARIABLE_SYNCHRONIZATION_NONE = 1;
// `ON_WRITE`: Indicates that the variable will be updated across devices
// every time it is written.
VARIABLE_SYNCHRONIZATION_ON_WRITE = 2;
// `ON_READ`: Indicates that the variable will be aggregated across devices
// when it is read (eg. when checkpointing or when evaluating an op that uses
// the variable).
VARIABLE_SYNCHRONIZATION_ON_READ = 3;
}
// Indicates how a distributed variable will be aggregated.
enum VariableAggregation {
// `NONE`: This is the default, giving an error if you use a
// variable-update operation with multiple replicas.
VARIABLE_AGGREGATION_NONE = 0;
// `SUM`: Add the updates across replicas.
VARIABLE_AGGREGATION_SUM = 1;
// `MEAN`: Take the arithmetic mean ("average") of the updates across
// replicas.
VARIABLE_AGGREGATION_MEAN = 2;
// `ONLY_FIRST_REPLICA`: This is for when every replica is performing the same
// update, but we only want to perform the update once. Used, e.g., for the
// global step counter.
VARIABLE_AGGREGATION_ONLY_FIRST_REPLICA = 3;
}
// Protocol buffer representing a Variable.
message VariableDef {
// Name of the variable tensor.
string variable_name = 1;
// Name of the tensor holding the variable's initial value.
string initial_value_name = 6;
// Name of the initializer op.
string initializer_name = 2;
// Name of the snapshot tensor.
string snapshot_name = 3;
// Support for saving variables as slices of a larger variable.
SaveSliceInfoDef save_slice_info_def = 4;
// Whether to represent this as a ResourceVariable.
bool is_resource = 5;
// Whether this variable should be trained.
bool trainable = 7;
// Indicates when a distributed variable will be synced.
VariableSynchronization synchronization = 8;
// Indicates how a distributed variable will be aggregated.
VariableAggregation aggregation = 9;
}
message SaveSliceInfoDef {
// Name of the full variable of which this is a slice.
string full_name = 1;
// Shape of the full variable.
repeated int64 full_shape = 2;
// Offset of this variable into the full variable.
repeated int64 var_offset = 3;
// Shape of this variable.
repeated int64 var_shape = 4;
}

View File

@ -1,33 +0,0 @@
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "VersionsProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/versions_go_proto";
// Version information for a piece of serialized data
//
// There are different types of versions for each type of data
// (GraphDef, etc.), but they all have the same common shape
// described here.
//
// Each consumer has "consumer" and "min_producer" versions (specified
// elsewhere). A consumer is allowed to consume this data if
//
// producer >= min_producer
// consumer >= min_consumer
// consumer not in bad_consumers
//
message VersionDef {
// The version of the code that produced this data.
int32 producer = 1;
// Any consumer below this version is not allowed to consume this data.
int32 min_consumer = 2;
// Specific consumer versions which are disallowed (e.g. due to bugs).
repeated int32 bad_consumers = 3;
}

View File

@ -1,106 +0,0 @@
// This file defines protos that store the results of autotuning various
// operations.
//
// They are in proto format because we want to log them structured. They offer
// tremendous statistical, testing, and debugging value.
syntax = "proto3";
package tensorflow;
import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
import "tensorflow/stream_executor/dnn.proto";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
message CudnnVersion {
int32 major = 1;
int32 minor = 2;
int32 patch = 3;
}
message ComputeCapability {
int32 major = 1;
int32 minor = 2;
}
message AutotuneResult {
enum FailureKind {
UNKNOWN = 0;
// Algorithm wrote memory outside its output buffers.
REDZONE_MODIFIED = 1;
// Algorithm gave a different result from a reference algorithm.
WRONG_RESULT = 2;
// Algorithm was rejected for failing to run or for known bugs.
DISQUALIFIED = 3;
}
message FailureResult {
FailureKind kind = 1;
string msg = 2;
// For failure_kind == WRONG_RESULT, this field indicates the reference
// configuration that we compared against.
//
// Note that the reference algorithm isn't always correct. However,
// empirically it's more correct, as it's "algo 0", less fancy than the
// compared one.
oneof key {
ConvKey reference_conv = 11;
GemmKey reference_gemm = 12;
CudaConvPlanKey reference_cuda_conv_plan = 14;
stream_executor.dnn.AlgorithmProto reference_algorithm = 15;
}
int64 buffer_address = 13;
}
// Legacy and unused in new data; superseded by AlgorithmProto.
message ConvKey {
int64 algorithm = 1;
bool tensor_ops_enabled = 2;
}
message GemmKey {
int64 algorithm = 1;
}
// Legacy and unused in new data; superseded by AlgorithmProto.
message CudaConvPlanKey {
string exec_plan_id = 1;
}
int64 scratch_bytes = 8;
google.protobuf.Duration run_time = 9;
FailureResult failure = 7;
oneof key {
ConvKey conv = 5;
GemmKey gemm = 6;
CudaConvPlanKey cuda_conv_plan = 15;
stream_executor.dnn.AlgorithmProto algorithm = 16;
}
// Next ID: 17
}
message AutotuningLog {
google.protobuf.Any instr = 1;
// Records all auto-tuning results per algorithm.
repeated AutotuneResult results = 2;
CudnnVersion cudnn_version = 3;
ComputeCapability compute_capability = 4;
// stream_executor::DeviceDescription::pci_bus_id.
string device_pci_bus_id = 5;
string blas_version = 6;
// Next ID: 7
}

View File

@ -1,47 +0,0 @@
syntax = "proto3";
package tensorflow;
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Some of the data from AllocatorStats
message MemAllocatorStats {
int64 num_allocs = 1;
int64 bytes_in_use = 2;
int64 peak_bytes_in_use = 3;
int64 largest_alloc_size = 4;
float fragmentation_metric = 5;
}
message MemChunk {
uint64 address = 1;
int64 size = 2;
int64 requested_size = 3;
int32 bin = 4;
string op_name = 5;
uint64 freed_at_count = 6;
uint64 action_count = 7;
bool in_use = 8;
uint64 step_id = 9;
}
message BinSummary {
int32 bin = 1;
int64 total_bytes_in_use = 2;
int64 total_bytes_in_bin = 3;
int64 total_chunks_in_use = 4;
int64 total_chunks_in_bin = 5;
}
message SnapShot {
uint64 action_count = 1;
int64 size = 2;
}
message MemoryDump {
string allocator_name = 1;
repeated BinSummary bin_summary = 2;
repeated MemChunk chunk = 3;
repeated SnapShot snap_shot = 4;
MemAllocatorStats stats = 5;
}

View File

@ -1,84 +0,0 @@
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "ClusterProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.distruntime";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// This file contains protos to be used when defining a TensorFlow
// cluster.
//
// EXAMPLES
// --------
//
// 1. A single-process cluster, containing "/job:local/task:0".
//
// Cluster:
// job { name: 'local' tasks { key: 0 value: 'localhost:2222' } }
//
// Server:
// cluster { $CLUSTER } job_name: 'local' task_index: 0
//
// 2. A two-process cluster, containing "/job:local/task:{0,1}".
//
// Cluster:
// job { name: 'local' tasks { key: 0 value: 'localhost:2222' }
// tasks { key: 1 value: 'localhost:2223' } }
//
// Servers:
// cluster { $CLUSTER } job_name: 'local' task_index: 0
// cluster { $CLUSTER } job_name: 'local' task_index: 1
//
// 3. A two-job cluster, containing "/job:worker/task:{0,1,2}" and
// "/job:ps/task:{0,1}".
//
// Cluster:
// job { name: 'worker' tasks { key: 0 value: 'worker1:2222' }
// tasks { key: 1 value: 'worker2:2222' }
// tasks { key: 2 value: 'worker3:2222' } }
// job { name: 'ps' tasks { key: 0 value: 'ps0:2222' }
// tasks { key: 1 value: 'ps1:2222' } }
//
// Servers:
// cluster { $CLUSTER } job_name: 'worker' task_index: 0
// cluster { $CLUSTER } job_name: 'worker' task_index: 1
// cluster { $CLUSTER } job_name: 'worker' task_index: 2
// cluster { $CLUSTER } job_name: 'ps' task_index: 0
// cluster { $CLUSTER } job_name: 'ps' task_index: 1
// Defines a single job in a TensorFlow cluster.
message JobDef {
// The name of this job.
string name = 1;
// Mapping from task ID to "hostname:port" string.
//
// If the `name` field contains "worker", and the `tasks` map contains a
// mapping from 7 to "example.org:2222", then the device prefix
// "/job:worker/task:7" will be assigned to "example.org:2222".
map<int32, string> tasks = 2;
}
// Defines a TensorFlow cluster as a set of jobs.
message ClusterDef {
// The jobs that comprise the cluster.
repeated JobDef job = 1;
}

View File

@ -1,16 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/protobuf/struct.proto";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Metadata for CompositeTensorVariant, used when serializing as Variant.
//
// We define a new message here (rather than directly using TypeSpecProto for
// the metadata string) to retain flexibility to change the metadata encoding
// to support additional features.
message CompositeTensorVariantMetadata {
TypeSpecProto type_spec_proto = 1;
}

View File

@ -1,902 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/cost_graph.proto";
import "tensorflow/core/framework/graph.proto";
import "tensorflow/core/framework/step_stats.proto";
import "tensorflow/core/protobuf/cluster.proto";
import "tensorflow/core/protobuf/coordination_config.proto";
import "tensorflow/core/protobuf/debug.proto";
import "tensorflow/core/protobuf/rewriter_config.proto";
option cc_enable_arenas = true;
option java_outer_classname = "ConfigProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
message GPUOptions {
// Fraction of the available GPU memory to allocate for each process.
// 1 means to allocate all of the GPU memory, 0.5 means the process
// allocates up to ~50% of the available GPU memory.
//
// GPU memory is pre-allocated unless the allow_growth option is enabled.
//
// If greater than 1.0, uses CUDA unified memory to potentially oversubscribe
// the amount of memory available on the GPU device by using host memory as a
// swap space. Accessing memory not available on the device will be
// significantly slower as that would require memory transfer between the host
// and the device. Options to reduce the memory requirement should be
// considered before enabling this option as this may come with a negative
// performance impact. Oversubscription using the unified memory requires
// Pascal class or newer GPUs and it is currently only supported on the Linux
// operating system. See
// https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#um-requirements
// for the detailed requirements.
double per_process_gpu_memory_fraction = 1;
// If true, the allocator does not pre-allocate the entire specified
// GPU memory region, instead starting small and growing as needed.
bool allow_growth = 4;
// The type of GPU allocation strategy to use.
//
// Allowed values:
// "": The empty string (default) uses a system-chosen default
// which may change over time.
//
// "BFC": A "Best-fit with coalescing" algorithm, simplified from a
// version of dlmalloc.
string allocator_type = 2;
// Delay deletion of up to this many bytes to reduce the number of
// interactions with gpu driver code. If 0, the system chooses
// a reasonable default (several MBs).
int64 deferred_deletion_bytes = 3;
// A comma-separated list of GPU ids that determines the 'visible'
// to 'virtual' mapping of GPU devices. For example, if TensorFlow
// can see 8 GPU devices in the process, and one wanted to map
// visible GPU devices 5 and 3 as "/device:GPU:0", and "/device:GPU:1",
// then one would specify this field as "5,3". This field is similar in
// spirit to the CUDA_VISIBLE_DEVICES environment variable, except
// it applies to the visible GPU devices in the process.
//
// NOTE:
// 1. The GPU driver provides the process with the visible GPUs
// in an order which is not guaranteed to have any correlation to
// the *physical* GPU id in the machine. This field is used for
// remapping "visible" to "virtual", which means this operates only
// after the process starts. Users are required to use vendor
// specific mechanisms (e.g., CUDA_VISIBLE_DEVICES) to control the
// physical to visible device mapping prior to invoking TensorFlow.
// 2. In the code, the ids in this list are also called "platform GPU id"s,
// and the 'virtual' ids of GPU devices (i.e. the ids in the device
// name "/device:GPU:<id>") are also called "TF GPU id"s. Please
// refer to third_party/tensorflow/core/common_runtime/gpu/gpu_id.h
// for more information.
string visible_device_list = 5;
// In the event polling loop sleep this many microseconds between
// PollEvents calls, when the queue is not empty. If value is not
// set or set to 0, gets set to a non-zero default.
int32 polling_active_delay_usecs = 6;
// This field is deprecated and ignored.
int32 polling_inactive_delay_msecs = 7;
// Force all tensors to be gpu_compatible. On a GPU-enabled TensorFlow,
// enabling this option forces all CPU tensors to be allocated with Cuda
// pinned memory. Normally, TensorFlow will infer which tensors should be
// allocated as the pinned memory. But in case where the inference is
// incomplete, this option can significantly speed up the cross-device memory
// copy performance as long as it fits the memory.
// Note that this option is not something that should be
// enabled by default for unknown or very large models, since all Cuda pinned
// memory is unpageable, having too much pinned memory might negatively impact
// the overall host system performance.
bool force_gpu_compatible = 8;
message Experimental {
// Configuration for breaking down a visible GPU into multiple "virtual"
// devices.
message VirtualDevices {
// Per "virtual" device memory limit, in MB. The number of elements in
// the list is the number of virtual devices to create on the
// corresponding visible GPU (see "virtual_devices" below).
// If empty, it will create single virtual device taking all available
// memory from the device.
//
// For the concept of "visible" and "virtual" GPU, see the comments for
// "visible_device_list" above for more information.
repeated float memory_limit_mb = 1;
// Priority values to use with the virtual devices. Use the cuda function
// cudaDeviceGetStreamPriorityRange to query for valid range of values for
// priority.
//
// On a P4000 GPU with cuda 10.1, the priority range reported was 0 for
// least priority and -1 for greatest priority.
//
// If this field is not specified, then the virtual devices will be
// created with the default. If this field has values set, then the size
// of this must match with the above memory_limit_mb.
repeated int32 priority = 2;
}
// The multi virtual device settings. If empty (not set), it will create
// single virtual device on each visible GPU, according to the settings
// in "visible_device_list" above. Otherwise, the number of elements in the
// list must be the same as the number of visible GPUs (after
// "visible_device_list" filtering if it is set), and the string represented
// device names (e.g. /device:GPU:<id>) will refer to the virtual
// devices and have the <id> field assigned sequentially starting from 0,
// according to the order they appear in this list and the "memory_limit"
// list inside each element. For example,
// visible_device_list = "1,0"
// virtual_devices { memory_limit: 1GB memory_limit: 2GB }
// virtual_devices {}
// will create three virtual devices as:
// /device:GPU:0 -> visible GPU 1 with 1GB memory
// /device:GPU:1 -> visible GPU 1 with 2GB memory
// /device:GPU:2 -> visible GPU 0 with all available memory
//
// NOTE:
// 1. It's invalid to set both this and "per_process_gpu_memory_fraction"
// at the same time.
// 2. Currently this setting is per-process, not per-session. Using
// different settings in different sessions within same process will
// result in undefined behavior.
repeated VirtualDevices virtual_devices = 1;
// If true, uses CUDA unified memory for memory allocations. If
// per_process_gpu_memory_fraction option is greater than 1.0, then unified
// memory is used regardless of the value for this field. See comments for
// per_process_gpu_memory_fraction field for more details and requirements
// of the unified memory. This option is useful to oversubscribe memory if
// multiple processes are sharing a single GPU while individually using less
// than 1.0 per process memory fraction.
bool use_unified_memory = 2;
// If > 1, the number of device-to-device copy streams to create
// for each GPUDevice. Default value is 0, which is automatically
// converted to 1.
int32 num_dev_to_dev_copy_streams = 3;
// If non-empty, defines a good GPU ring order on a single worker based on
// device interconnect. This assumes that all workers have the same GPU
// topology. Specify as a comma-separated string, e.g. "3,2,1,0,7,6,5,4".
// This ring order is used by the RingReducer implementation of
// CollectiveReduce, and serves as an override to automatic ring order
// generation in OrderTaskDeviceMap() during CollectiveParam resolution.
string collective_ring_order = 4;
// If true then extra work is done by GPUDevice and GPUBFCAllocator to
// keep track of when GPU memory is freed and when kernels actually
// complete so that we can know when a nominally free memory chunk
// is really not subject to pending use.
bool timestamped_allocator = 5;
// reserved id: 6
// Parameters for GPUKernelTracker. By default no kernel tracking is done.
// Note that timestamped_allocator is only effective if some tracking is
// specified.
//
// If kernel_tracker_max_interval = n > 0, then a tracking event
// is inserted after every n kernels without an event.
int32 kernel_tracker_max_interval = 7;
// If kernel_tracker_max_bytes = n > 0, then a tracking event is
// inserted after every series of kernels allocating a sum of
// memory >= n. If one kernel allocates b * n bytes, then one
// event will be inserted after it, but it will count as b against
// the pending limit.
int32 kernel_tracker_max_bytes = 8;
// If kernel_tracker_max_pending > 0 then no more than this many
// tracking events can be outstanding at a time. An attempt to
// launch an additional kernel will stall until an event
// completes.
int32 kernel_tracker_max_pending = 9;
// BFC Allocator can return an allocated chunk of memory upto 2x the
// requested size. For virtual devices with tight memory constraints, and
// proportionately large allocation requests, this can lead to a significant
// reduction in available memory. The threshold below controls when a chunk
// should be split if the chunk size exceeds requested memory size. It is
// expressed as a fraction of total available memory for the tf device. For
// example setting it to 0.05 would imply a chunk needs to be split if its
// size exceeds the requested memory by 5% of the total virtual device/gpu
// memory size.
double internal_fragmentation_fraction = 10;
// When true, use CUDA cudaMallocAsync API instead of TF gpu allocator.
bool use_cuda_malloc_async = 11;
// By default, BFCAllocator may sleep when it runs out of memory, in the
// hopes that another thread will free up memory in the meantime. Setting
// this to true disables the sleep; instead we'll OOM immediately.
bool disallow_retry_on_allocation_failure = 12;
}
// Everything inside experimental is subject to change and is not subject
// to API stability guarantees in
// https://www.tensorflow.org/guide/version_compat.
Experimental experimental = 9;
}
// Options passed to the graph optimizer
message OptimizerOptions {
// If true, optimize the graph using common subexpression elimination.
// Note: the optimization Level L1 will override this setting to true. So in
// order to disable common subexpression elimination the opt_level has to be
// set to L0.
bool do_common_subexpression_elimination = 1;
// If true, perform constant folding optimization on the graph.
// Note: the optimization Level L1 will override this setting to true. So in
// order to disable constant folding the opt_level has to be set to L0.
bool do_constant_folding = 2;
// Constant folding optimization replaces tensors whose values can be
// predetermined, with constant nodes. To avoid inserting too large constants,
// the size of each constant created can be limited. If this value is zero, a
// default limit of 10 MiB will be applied. If constant folding optimization
// is disabled, this value is ignored.
int64 max_folded_constant_in_bytes = 6;
// If true, perform function inlining on the graph.
bool do_function_inlining = 4;
// Optimization level
enum Level {
// L1 is the default level.
// Optimization performed at L1 :
// 1. Common subexpression elimination
// 2. Constant folding
L1 = 0;
// No optimizations
L0 = -1;
}
// Overall optimization level. The actual optimizations applied will be the
// logical OR of the flags that this level implies and any flags already set.
Level opt_level = 3;
// Control the use of the compiler/jit. Experimental.
enum GlobalJitLevel {
DEFAULT = 0; // Default setting ("off" now, but later expected to be "on")
OFF = -1;
// The following settings turn on compilation, with higher values being
// more aggressive. Higher values may reduce opportunities for parallelism
// and may use more memory. (At present, there is no distinction, but this
// is expected to change.)
ON_1 = 1;
ON_2 = 2;
}
GlobalJitLevel global_jit_level = 5;
// CPU code will be autoclustered only if global_jit_level >= ON_1 and either:
// - this flag is true, or
// - TF_XLA_FLAGS contains --tf_xla_cpu_global_jit=true.
bool cpu_global_jit = 7;
}
message GraphOptions {
// Removed, use optimizer_options below.
reserved "skip_common_subexpression_elimination";
reserved 1;
// If true, use control flow to schedule the activation of Recv nodes.
// (Currently ignored.)
bool enable_recv_scheduling = 2;
// Options controlling how graph is optimized.
OptimizerOptions optimizer_options = 3;
// The number of steps to run before returning a cost model detailing
// the memory usage and performance of each node of the graph. 0 means
// no cost model.
int64 build_cost_model = 4;
// The number of steps to skip before collecting statistics for the
// cost model.
int64 build_cost_model_after = 9;
// Annotate each Node with Op output shape data, to the extent it can
// be statically inferred.
bool infer_shapes = 5;
// Only place the subgraphs that are run, rather than the entire graph.
//
// This is useful for interactive graph building, where one might
// produce graphs that cannot be placed during the debugging
// process. In particular, it allows the client to continue work in
// a session after adding a node to a graph whose placement
// constraints are unsatisfiable.
bool place_pruned_graph = 6;
// If true, transfer float values between processes as bfloat16.
bool enable_bfloat16_sendrecv = 7;
// If > 0, record a timeline every this many steps.
// EXPERIMENTAL: This currently has no effect in MasterSession.
int32 timeline_step = 8;
// Options that control the type and amount of graph rewriting.
// Not currently configurable via the public Python API (i.e. there is no API
// stability guarantee if you import RewriterConfig explicitly).
RewriterConfig rewrite_options = 10;
}
message ThreadPoolOptionProto {
// The number of threads in the pool.
//
// 0 means the system picks a value based on where this option proto is used
// (see the declaration of the specific field for more info).
int32 num_threads = 1;
// The global name of the threadpool.
//
// If empty, then the threadpool is made and used according to the scope it's
// in - e.g., for a session threadpool, it is used by that session only.
//
// If non-empty, then:
// - a global threadpool associated with this name is looked
// up or created. This allows, for example, sharing one threadpool across
// many sessions (e.g., like the default behavior, if
// inter_op_parallelism_threads is not configured), but still partitioning
// into a large and small pool.
// - if the threadpool for this global_name already exists, then it is an
// error if the existing pool was created using a different num_threads
// value as is specified on this call.
// - threadpools created this way are never garbage collected.
string global_name = 2;
}
message RPCOptions {
// If true, always use RPC to contact the session target.
//
// If false (the default option), TensorFlow may use an optimized
// transport for client-master communication that avoids the RPC
// stack. This option is primarily for used testing the RPC stack.
bool use_rpc_for_inprocess_master = 1;
// The compression algorithm to be used. One of "deflate", "gzip".
string compression_algorithm = 2;
// If compression_algorithm is set, the compression level to be used.
// From 0 (no compression), up to 3.
int32 compression_level = 3;
// Setting cache_rpc_response to true will enable sender side caching of
// response for RecvTensorAsync and RecvBufAsync to allow receiver to retry
// requests . This is only necessary when the network fabric is experiencing a
// significant error rate. Without it we'll fail a step on an network error,
// while with it we'll be able to complete long steps (like complex
// initializations) in the face of some network errors during RecvTensor.
bool cache_rpc_response = 4;
// Disables TCP connection sharing when opening a new RPC channel.
bool disable_session_connection_sharing = 5;
// Setting num_channels_per_target > 0 allows uses of multiple channels to
// communicate to the same target. This can be used to improve the aggregate
// throughput on high speed links (e.g 100G) where single connection is not
// sufficient to maximize link utilization. Note that a single RPC only goes
// on a single channel, this only helps in situations where there are multiple
// transfers to the same target overlapping in time.
int32 num_channels_per_target = 6;
}
// Metadata about the session.
//
// This can be used by the runtime and the Ops for debugging, monitoring, etc.
//
// The (name, version) tuple is expected to be a unique identifier for
// sessions within the same process.
//
// NOTE: This is currently used and propagated only by the direct session.
message SessionMetadata {
string name = 1;
// The version is optional. If set, needs to be >= 0.
int64 version = 2;
}
// Session configuration parameters.
// The system picks appropriate values for fields that are not set.
message ConfigProto {
// Map from device type name (e.g., "CPU" or "GPU" ) to maximum
// number of devices of that type to use. If a particular device
// type is not found in the map, the system picks an appropriate
// number.
map<string, int32> device_count = 1;
// The execution of an individual op (for some op types) can be
// parallelized on a pool of intra_op_parallelism_threads.
// 0 means the system picks an appropriate number.
//
// If you create an ordinary session, e.g., from Python or C++,
// then there is exactly one intra op thread pool per process.
// The first session created determines the number of threads in this pool.
// All subsequent sessions reuse/share this one global pool.
//
// There are notable exceptions to the default behavior described above:
// 1. There is an environment variable for overriding this thread pool,
// named TF_OVERRIDE_GLOBAL_THREADPOOL.
// 2. When connecting to a server, such as a remote `tf.train.Server`
// instance, then this option will be ignored altogether.
int32 intra_op_parallelism_threads = 2;
// Nodes that perform blocking operations are enqueued on a pool of
// inter_op_parallelism_threads available in each process.
//
// 0 means the system picks an appropriate number.
// Negative means all operations are performed in caller's thread.
//
// Note that the first Session created in the process sets the
// number of threads for all future sessions unless use_per_session_threads is
// true or session_inter_op_thread_pool is configured.
int32 inter_op_parallelism_threads = 5;
// If true, use a new set of threads for this session rather than the global
// pool of threads. Only supported by direct sessions.
//
// If false, use the global threads created by the first session, or the
// per-session thread pools configured by session_inter_op_thread_pool.
//
// This option is deprecated. The same effect can be achieved by setting
// session_inter_op_thread_pool to have one element, whose num_threads equals
// inter_op_parallelism_threads.
bool use_per_session_threads = 9;
// This option is experimental - it may be replaced with a different mechanism
// in the future.
//
// Configures session thread pools. If this is configured, then RunOptions for
// a Run call can select the thread pool to use.
//
// The intended use is for when some session invocations need to run in a
// background pool limited to a small number of threads:
// - For example, a session may be configured to have one large pool (for
// regular compute) and one small pool (for periodic, low priority work);
// using the small pool is currently the mechanism for limiting the inter-op
// parallelism of the low priority work. Note that it does not limit the
// parallelism of work spawned by a single op kernel implementation.
// - Using this setting is normally not needed in training, but may help some
// serving use cases.
// - It is also generally recommended to set the global_name field of this
// proto, to avoid creating multiple large pools. It is typically better to
// run the non-low-priority work, even across sessions, in a single large
// pool.
repeated ThreadPoolOptionProto session_inter_op_thread_pool = 12;
// Assignment of Nodes to Devices is recomputed every placement_period
// steps until the system warms up (at which point the recomputation
// typically slows down automatically).
int32 placement_period = 3;
// When any filters are present sessions will ignore all devices which do not
// match the filters. Each filter can be partially specified, e.g. "/job:ps"
// "/job:worker/replica:3", etc.
repeated string device_filters = 4;
// Options that apply to all GPUs.
GPUOptions gpu_options = 6;
// Whether soft placement is allowed. If allow_soft_placement is true,
// an op will be placed on CPU if
// 1. there's no GPU implementation for the OP
// or
// 2. no GPU devices are known or registered
// or
// 3. need to co-locate with reftype input(s) which are from CPU.
bool allow_soft_placement = 7;
// Whether device placements should be logged.
bool log_device_placement = 8;
// Options that apply to all graphs.
GraphOptions graph_options = 10;
// Global timeout for all blocking operations in this session. If non-zero,
// and not overridden on a per-operation basis, this value will be used as the
// deadline for all blocking operations.
int64 operation_timeout_in_ms = 11;
// Options that apply when this session uses the distributed runtime.
RPCOptions rpc_options = 13;
// Optional list of all workers to use in this session.
ClusterDef cluster_def = 14;
// If true, any resources such as Variables used in the session will not be
// shared with other sessions. However, when clusterspec propagation is
// enabled, this field is ignored and sessions are always isolated.
bool isolate_session_state = 15;
// When true, WorkerSessions are created with device attributes from the
// full cluster.
// This is helpful when a worker wants to partition a graph
// (for example during a PartitionedCallOp).
bool share_cluster_devices_in_session = 17;
// Everything inside Experimental is subject to change and is not subject
// to API stability guarantees in
// https://www.tensorflow.org/guide/version_compat.
message Experimental {
// Task name for group resolution.
string collective_group_leader = 1;
// We removed the flag client_handles_error_formatting. Marking the tag
// number as reserved.
// TODO(shikharagarwal): Should we just remove this tag so that it can be
// used in future for other purpose?
reserved 2;
// Which executor to use, the default executor will be used
// if it is an empty string or "DEFAULT"
string executor_type = 3;
// Guidance to formatting of large RecvBuf fields for transfer.
// Any positive value sets the max chunk size. 0 defaults to 4096.
// Any negative value indicates no max, i.e. one chunk only.
int32 recv_buf_max_chunk = 4;
// If true, and supported by the platform, the runtime will attempt to
// use NUMA affinity where applicable. One consequence will be the
// existence of as many CPU devices as there are available NUMA nodes.
bool use_numa_affinity = 5;
// If true, make collective op execution order sequential and deterministic
// for potentially concurrent collective instances.
bool collective_deterministic_sequential_execution = 6;
// If true, use NCCL for CollectiveOps. This feature is highly
// experimental.
bool collective_nccl = 7;
// In the following, session state means the value of a variable, elements
// in a hash table, or any other resource, accessible by worker sessions
// held by a TF server.
//
// When ClusterSpec propagation is enabled, the value of
// isolate_session_state is ignored when deciding whether to share session
// states in a TF server (for backwards compatibility reasons).
// - If share_session_state_in_clusterspec_propagation is true, the session
// states are shared.
// - If share_session_state_in_clusterspec_propagation is false, session
// states are isolated.
//
// When clusterspec propagation is not used, the value of
// share_session_state_in_clusterspec_propagation is ignored when deciding
// whether to share session states in a TF server.
// - If isolate_session_state is true, session states are isolated.
// - If isolate_session_state is false, session states are shared.
//
// TODO(b/129330037): Add a single API that consistently treats
// isolate_session_state and ClusterSpec propagation.
bool share_session_state_in_clusterspec_propagation = 8;
// If using a direct session, disable spinning while waiting for work in
// the thread pool. This may result in higher latency for completing ops,
// but in the case where there is a lot of spinning may result in lower
// CPU usage.
bool disable_thread_spinning = 9;
// This was promoted to a non-experimental API. Please use
// ConfigProto.share_cluster_devices_in_session instead.
bool share_cluster_devices_in_session = 10;
// Metadata about the session.
//
// If set, this can be used by the runtime and the Ops for debugging,
// monitoring, etc.
//
// NOTE: This is currently used and propagated only by the direct session.
SessionMetadata session_metadata = 11;
// If true, the session may treat the graph as being static for optimization
// purposes.
//
// If this option is set to true when a session is created, the full
// GraphDef must be passed in a single call to Session::Create(), and
// Session::Extend() may not be supported.
bool optimize_for_static_graph = 12;
// This field will eventually be deprecated and replaced by
// mlir_bridge_rollout (b/166038521).
//
// Whether to enable the MLIR-based TF->XLA bridge.
//
// This is a replacement to the existing bridge, and not ready for
// production usage yet.
// If this option is set to true when a session is created, MLIR is used to
// perform the set of graph transformations to put the graph in a form that
// can be executed with delegation of some computations to an accelerator.
// This builds on the model of XLA where a subset of the graph is
// encapsulated and attached to a "compile" operation, whose result is fed
// to an "execute" operation. The kernel for these operations is responsible
// to lower the encapsulated graph to a particular device.
bool enable_mlir_bridge = 13;
// An enum that describes the state of the MLIR bridge rollout.
enum MlirBridgeRollout {
// If this field is left unspecified, the MLIR bridge may be selectively
// enabled on a per graph basis.
MLIR_BRIDGE_ROLLOUT_UNSPECIFIED = 0;
// Enabling the MLIR bridge enables it for all graphs in this session.
MLIR_BRIDGE_ROLLOUT_ENABLED = 1;
// Disabling the MLIR bridge disables it for all graphs in this session.
MLIR_BRIDGE_ROLLOUT_DISABLED = 2;
// Enable the MLIR bridge on a per graph basis based on an analysis of
// the features used in the graph. If the features used by the graph are
// supported by the MLIR bridge, the MLIR bridge will be used to run the
// graph.
MLIR_BRIDGE_ROLLOUT_SAFE_MODE_ENABLED = 3;
// Enable the MLIR bridge in a fallback mode on a per graph basis based
// on an analysis of the features used in the graph.
// Running the MLIR bridge in the fallback mode means that it is
// executed and it commits all the changes to the TF graph in case
// of success. And it does not in case of failures and let the old bridge
// to process the TF graph.
MLIR_BRIDGE_ROLLOUT_SAFE_MODE_FALLBACK_ENABLED = 4;
}
// This field is underdevelopment, for now use enable_mlir_bridge
// (b/166038521).
//
// Whether to enable the MLIR-based TF->XLA bridge.
MlirBridgeRollout mlir_bridge_rollout = 17;
// Whether to enable the MLIR-based Graph optimizations.
//
// This will become a part of standard Tensorflow graph optimization
// pipeline, currently this is only used for gradual migration and testing
// new passes that are replacing existing optimizations in Grappler.
bool enable_mlir_graph_optimization = 16;
// If true, the session will not store an additional copy of the graph for
// each subgraph.
//
// If this option is set to true when a session is created, the
// `RunOptions.output_partition_graphs` options must not be set.
bool disable_output_partition_graphs = 14;
// Minimum number of batches run through the XLA graph before XLA fusion
// autotuner is enabled. Default value of zero disables the autotuner.
//
// The XLA fusion autotuner can improve performance by executing a heuristic
// search on the compiler parameters.
int64 xla_fusion_autotuner_thresh = 15;
// Whether runtime execution uses TFRT.
bool use_tfrt = 18;
// The field "coordination_service was previously specified as a string;
// this has been replaced with a message below.
reserved 19;
// We removed the flag fetch_remote_devices_in_multi_client. Marking the tag
// number as reserved.
reserved 20;
// Whether functional control flow op lowering should be disabled. This is
// useful when executing within a portable runtime where control flow op
// kernels may not be loaded due to selective registration.
bool disable_functional_ops_lowering = 21;
// Provides a hint to XLA auto clustering to prefer forming a single large
// cluster that encompases most of the graph.
bool xla_prefer_single_graph_cluster = 22;
// Distributed coordination service configurations.
CoordinationServiceConfig coordination_config = 23;
// Next: 24
}
Experimental experimental = 16;
// Next: 18
}
// Options for a single Run() call.
message RunOptions {
// TODO(pbar) Turn this into a TraceOptions proto which allows
// tracing to be controlled in a more orthogonal manner?
enum TraceLevel {
NO_TRACE = 0;
SOFTWARE_TRACE = 1;
HARDWARE_TRACE = 2;
FULL_TRACE = 3;
}
TraceLevel trace_level = 1;
// Time to wait for operation to complete in milliseconds.
int64 timeout_in_ms = 2;
// The thread pool to use, if session_inter_op_thread_pool is configured.
// To use the caller thread set this to -1 - this uses the caller thread
// to execute Session::Run() and thus avoids a context switch. Using the
// caller thread to execute Session::Run() should be done ONLY for simple
// graphs, where the overhead of an additional context switch is
// comparable with the overhead of Session::Run().
int32 inter_op_thread_pool = 3;
// Whether the partition graph(s) executed by the executor(s) should be
// outputted via RunMetadata.
bool output_partition_graphs = 5;
// EXPERIMENTAL. Options used to initialize DebuggerState, if enabled.
DebugOptions debug_options = 6;
// When enabled, causes tensor allocation information to be included in
// the error message when the Run() call fails because the allocator ran
// out of memory (OOM).
//
// Enabling this option can slow down the Run() call.
bool report_tensor_allocations_upon_oom = 7;
// Everything inside Experimental is subject to change and is not subject
// to API stability guarantees in
// https://www.tensorflow.org/guide/version_compat.
message Experimental {
// If non-zero, declares that this graph is going to use collective
// ops and must synchronize step_ids with any other graph with this
// same group_key value (in a distributed computation where tasks
// run disjoint graphs).
int64 collective_graph_key = 1;
// If true, then operations (using the inter-op pool) across all
// session::run() calls will be centrally scheduled, optimizing for (median
// and tail) latency.
// Consider using this option for CPU-bound workloads like inference.
bool use_run_handler_pool = 2;
// Options for run handler thread pool.
message RunHandlerPoolOptions {
// Priority of the request. The run handler thread pool will schedule ops
// based on the priority number. The larger number means higher priority.
int64 priority = 1;
}
RunHandlerPoolOptions run_handler_pool_options = 3;
}
Experimental experimental = 8;
reserved 4;
}
// Metadata output (i.e., non-Tensor) for a single Run() call.
message RunMetadata {
// Statistics traced for this step. Populated if tracing is turned on via the
// "RunOptions" proto.
// EXPERIMENTAL: The format and set of events may change in future versions.
StepStats step_stats = 1;
// The cost graph for the computation defined by the run call.
CostGraphDef cost_graph = 2;
// Graphs of the partitions executed by executors.
repeated GraphDef partition_graphs = 3;
message FunctionGraphs {
// TODO(nareshmodi): Include some sort of function/cache-key identifier?
repeated GraphDef partition_graphs = 1;
GraphDef pre_optimization_graph = 2;
GraphDef post_optimization_graph = 3;
}
// This is only populated for graphs that are run as functions in TensorFlow
// V2. There will be an entry below for each function that is traced.
// The main use cases of the post_optimization_graph and the partition_graphs
// is to give the caller insight into the graphs that were actually run by the
// runtime. Additional information (such as those in step_stats) will match
// these graphs.
// We also include the pre_optimization_graph since it is usually easier to
// read, and is helpful in situations where the caller wants to get a high
// level idea of what the built graph looks like (since the various graph
// optimization passes might change the structure of the graph significantly).
repeated FunctionGraphs function_graphs = 4;
}
// Defines a connection between two tensors in a `GraphDef`.
message TensorConnection {
// A tensor name. The value of this tensor will be substituted for
// the tensor named in `to_tensor`.
string from_tensor = 1;
// A tensor name. The value of this tensor will be bound to the
// value of the tensor named in `from_tensor`.
string to_tensor = 2;
}
// Defines a subgraph in another `GraphDef` as a set of feed points and nodes
// to be fetched or executed.
//
// Compare with the arguments to `Session::Run()`.
message CallableOptions {
// Tensors to be fed in the callable. Each feed is the name of a tensor.
repeated string feed = 1;
// Fetches. A list of tensor names. The caller of the callable expects a
// tensor to be returned for each fetch[i] (see RunStepResponse.tensor). The
// order of specified fetches does not change the execution order.
repeated string fetch = 2;
// Target Nodes. A list of node names. The named nodes will be run by the
// callable but their outputs will not be returned.
repeated string target = 3;
// Options that will be applied to each run.
RunOptions run_options = 4;
// Tensors to be connected in the callable. Each TensorConnection denotes
// a pair of tensors in the graph, between which an edge will be created
// in the callable.
repeated TensorConnection tensor_connection = 5;
// The Tensor objects fed in the callable and fetched from the callable
// are expected to be backed by host (CPU) memory by default.
//
// The options below allow changing that - feeding tensors backed by
// device memory, or returning tensors that are backed by device memory.
//
// The maps below map the name of a feed/fetch tensor (which appears in
// 'feed' or 'fetch' fields above), to the fully qualified name of the device
// owning the memory backing the contents of the tensor.
//
// For example, creating a callable with the following options:
//
// CallableOptions {
// feed: "a:0"
// feed: "b:0"
//
// fetch: "x:0"
// fetch: "y:0"
//
// feed_devices: {
// "a:0": "/job:localhost/replica:0/task:0/device:GPU:0"
// }
//
// fetch_devices: {
// "y:0": "/job:localhost/replica:0/task:0/device:GPU:0"
// }
// }
//
// means that the Callable expects:
// - The first argument ("a:0") is a Tensor backed by GPU memory.
// - The second argument ("b:0") is a Tensor backed by host memory.
// and of its return values:
// - The first output ("x:0") will be backed by host memory.
// - The second output ("y:0") will be backed by GPU memory.
//
// FEEDS:
// It is the responsibility of the caller to ensure that the memory of the fed
// tensors will be correctly initialized and synchronized before it is
// accessed by operations executed during the call to Session::RunCallable().
//
// This is typically ensured by using the TensorFlow memory allocators
// (Device::GetAllocator()) to create the Tensor to be fed.
//
// Alternatively, for CUDA-enabled GPU devices, this typically means that the
// operation that produced the contents of the tensor has completed, i.e., the
// CUDA stream has been synchronized (e.g., via cuCtxSynchronize() or
// cuStreamSynchronize()).
map<string, string> feed_devices = 6;
map<string, string> fetch_devices = 7;
// By default, RunCallable() will synchronize the GPU stream before returning
// fetched tensors on a GPU device, to ensure that the values in those tensors
// have been produced. This simplifies interacting with the tensors, but
// potentially incurs a performance hit.
//
// If this options is set to true, the caller is responsible for ensuring
// that the values in the fetched tensors have been produced before they are
// used. The caller can do this by invoking `Device::Sync()` on the underlying
// device(s), or by feeding the tensors back to the same Session using
// `feed_devices` with the same corresponding device name.
bool fetch_skip_sync = 8;
// Next: 9
}

View File

@ -1,91 +0,0 @@
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "ControlFlowProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Control flow context related protocol buffers.
// Protocol buffer representing the values in ControlFlowContext.
message ValuesDef {
// Value names that have been seen in this context.
repeated string values = 1;
// Value names referenced by but external to this context.
map<string, string> external_values = 2;
}
// Container for any kind of control flow context. Any other control flow
// contexts that are added below should also be added here.
message ControlFlowContextDef {
oneof ctxt {
CondContextDef cond_ctxt = 1;
WhileContextDef while_ctxt = 2;
}
}
// Protocol buffer representing a CondContext object.
message CondContextDef {
// Name of the context.
string context_name = 1;
// Name of the pred tensor.
string pred_name = 2;
// Name of the pivot tensor.
string pivot_name = 3;
// Branch prediction. 0 or 1.
int32 branch = 4;
// Values and external values in control flow context.
ValuesDef values_def = 5;
// Contexts contained inside this context (e.g. nested conds).
repeated ControlFlowContextDef nested_contexts = 6;
}
// Protocol buffer representing a WhileContext object.
message WhileContextDef {
// Name of the context.
string context_name = 1;
// The number of iterations allowed to run in parallel.
int32 parallel_iterations = 2;
// Whether backprop is enabled for this while loop.
bool back_prop = 3;
// Whether GPU-CPU memory swap is enabled for this loop.
bool swap_memory = 4;
// Name of the pivot tensor.
string pivot_name = 5;
// Name of the pivot_for_pred tensor.
string pivot_for_pred_name = 6;
// Name of the pivot_for_body tensor.
string pivot_for_body_name = 7;
// List of names for exit tensors.
repeated string loop_exit_names = 8;
// List of names for enter tensors.
repeated string loop_enter_names = 10;
// Values and external values in control flow context.
ValuesDef values_def = 9;
// Optional name of the maximum_iterations tensor.
string maximum_iterations_name = 11;
// Contexts contained inside this context (e.g. nested whiles).
repeated ControlFlowContextDef nested_contexts = 12;
// Next available id: 13.
}

View File

@ -1,33 +0,0 @@
// This is used for convolution logging. Also see
// tensorflow/core/protobuf/autotuing.h
syntax = "proto3";
package tensorflow;
import "tensorflow/stream_executor/dnn.proto";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// A convolution. Currently it's only used for logging. In the future, we may
// want to use it in the API as well.
message ConvolutionProto {
stream_executor.dnn.ConvolutionKind kind = 1;
stream_executor.dnn.TensorDescriptorProto input = 2;
stream_executor.dnn.TensorDescriptorProto filter = 3;
stream_executor.dnn.TensorDescriptorProto output = 4;
stream_executor.dnn.ConvolutionDescriptorProto conv_desc = 5;
// result = conv_scale * conv(...) + side_value_scale * side_value.
// side_value is an arbitrary buffer if activation is not none. Otherwise, it
// has to be the result buffer (using its old values).
double conv_scale = 6;
double side_value_scale = 7;
stream_executor.dnn.ActivationMode activation = 8;
int64 input_address = 9;
int64 filter_address = 10;
int64 output_address = 11;
int64 bias_address = 12;
int64 side_input_address = 13;
}

View File

@ -1,32 +0,0 @@
syntax = "proto3";
package tensorflow;
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Coordination service configuration parameters.
// The system picks appropriate values for fields that are not set.
message CoordinationServiceConfig {
// Type of coordination service implementation to enable.
// For example, setting the service type as "standalone" starts a service
// instance on the leader task to provide the coordination services such as
// heartbeats and consistent key-value store.
string service_type = 1;
// Address where the coordination service instance is hosted.
string service_leader = 2;
// Whether to enable the health check mechanism.
bool enable_health_check = 3;
// Maximum wait time for all members in the cluster to be registered.
int64 cluster_register_timeout_in_ms = 4;
// Heartbeat timeout, if a worker does not record heartbeat in this time
// window, it will be considered disconnected.
int64 heartbeat_timeout_in_ms = 5;
// The list of jobs that partipate in the coordination service. If empty, all
// jobs will be included in the coordination service by default.
repeated string coordinated_jobs = 6;
}

View File

@ -1,256 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/compiler/xla/pjrt/distributed/protocol.proto";
import "tensorflow/core/framework/device_attributes.proto";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Represents a remote worker task, specified by job name and task id.
message CoordinatedTask {
string job_name = 1;
int32 task_id = 2;
}
// Status payload for all coordination service errors.
// Note: an empty proto may be set if the error is triggered by the task's own
// agent calls (i.e. not propagated by the service from another remote task).
message CoordinationServiceError {
// Removed fields which used to specify the error origin.
reserved 1, 2;
// If true, error is reported via the agent API by the user (and not an
// internal service error).
bool is_reported_error = 3;
// Denotes which task hit the error. If unset, the error originated from the
// same task that is processing this error.
CoordinatedTask source_task = 4;
}
// Represent device information from different runtimes.
message TfDeviceList {
repeated DeviceAttributes devices = 1;
}
message XlaDeviceList {
xla.GlobalTopologyProto devices = 1;
}
message CoordinationServiceDeviceInfo {
oneof type {
TfDeviceList tf = 1;
XlaDeviceList xla = 2;
}
}
// Request and response messages for registering a worker to the cluster leader.
// Use `job` and `task` to represent the role of the worker, and use
// `incarnation` to uniquely identify a worker process. Leader responds with its
// `incarnation` to identify a leader process.
message RegisterWorkerRequest {
// Removed fields which used to specify the task.
reserved 1, 2;
fixed64 incarnation = 3;
// Moved the field `local_device_attributes` from this request message to
// WaitForAllTasksRequest defined below.
reserved 4;
CoordinatedTask source_task = 5;
}
message RegisterWorkerResponse {
fixed64 leader_incarnation = 1;
}
// Request and response messages for sending heartbeats.
message HeartbeatRequest {
// Removed fields which used to specify the remote task.
reserved 1, 2;
fixed64 incarnation = 3;
CoordinatedTask source_task = 4;
}
message HeartbeatResponse {
fixed64 leader_incarnation = 1;
// If there are failures in cluster, use additional metadata in response to
// broadcast error code and message to other workers.
}
// Request and response messages for waiting for all tasks.
message WaitForAllTasksRequest {
// Removed fields which used to specify the remote task.
reserved 1, 2;
// Removed field that specifically used TF device info.
reserved 3;
// All local device attributes on the request sender.
CoordinationServiceDeviceInfo local_device_info = 4;
CoordinatedTask source_task = 5;
}
message WaitForAllTasksResponse {
fixed64 leader_incarnation = 1;
// Removed field that specifically used TF device info.
reserved 2;
// All devices in the cluster.
CoordinationServiceDeviceInfo cluster_device_info = 3;
}
// Request and response messages for reporting errors to task.
message ReportErrorToAgentRequest {
int32 error_code = 1;
string error_message = 2;
// Removed fields that are embedded in payload.
reserved 3, 4;
CoordinationServiceError error_payload = 5;
}
message ReportErrorToAgentResponse {}
// Request and response messages for reporting errors to service instance.
message ReportErrorToServiceRequest {
int32 error_code = 1;
string error_message = 2;
// Removed fields which used to specify the error origin.
reserved 3, 4;
CoordinatedTask error_origin = 5;
}
message ReportErrorToServiceResponse {}
// Message for configuration key value.
// Key is structured like Unix file system, with multiple levels of directory
// names separated by the slash ('/') characters.
message KeyValueEntry {
string key = 1;
bytes value = 2;
}
// Request and response messages for inserting configuration key-value data.
message InsertKeyValueRequest {
KeyValueEntry kv = 1;
}
message InsertKeyValueResponse {}
// Request and response messages for getting configuration key-value data.
message GetKeyValueRequest {
string key = 1;
}
message GetKeyValueResponse {
KeyValueEntry kv = 1;
}
// Request and response messages for deleting configuration key-value data.
// When is_directory is true, delete key-values recursively under `key`.
message DeleteKeyValueRequest {
string key = 1;
bool is_directory = 2;
}
message DeleteKeyValueResponse {}
// Request and response messages for generic sync barriers.
message BarrierRequest {
string barrier_id = 1;
int64 barrier_timeout_in_ms = 2;
// Denotes list of tasks that will wait for the barrier. If unspecified, it
// implies that the entire cluster is participating in the barrier.
repeated CoordinatedTask tasks = 3;
// Task that is making the request.
CoordinatedTask source_task = 4;
}
message BarrierResponse {}
// Request and response messages for cancelling generic sync barriers.
message CancelBarrierRequest {
string barrier_id = 1;
// Task that is making the request.
CoordinatedTask source_task = 2;
}
message CancelBarrierResponse {}
// Coordination Service defines a TensorFlow service that controls and
// coordinates distributed execution in a cluster of multiple workers.
//
// The service keeps track of the cluster configuration and the state of cluster
// members or the leader depending on the role of the current worker. The
// distributed runtime leverages this service to coordinate and perform cluster
// initialization, check the healthiness of workers, and propagate error
// messages to the cluster.
service CoordinationService {
// Register task to coordination service so that the service starts to track
// liveness of the task. RPC blocks and returns only when it registers to
// the service successfully, or error happens in the registering process.
rpc RegisterWorker(RegisterWorkerRequest) returns (RegisterWorkerResponse);
// Heartbeat message from task to coordination service. Heartbeat is sent from
// a task to refresh its timestamp on leader to avoid it becoming stale.
// RPC responds immediately after refreshing the timestamp on leader.
rpc Heartbeat(HeartbeatRequest) returns (HeartbeatResponse);
// Wait for all tasks in the cluster to be up and running. The RPC request
// only gets responded when all workers are registered, or some error occurs.
rpc WaitForAllTasks(WaitForAllTasksRequest) returns (WaitForAllTasksResponse);
// Report error to the task. RPC sets the receiving instance of coordination
// service agent to error state permanently.
// TODO(b/195990880): Consider splitting this into a different RPC service.
rpc ReportErrorToAgent(ReportErrorToAgentRequest)
returns (ReportErrorToAgentResponse);
// Report task error to coordination service. RPC sets the service-side task
// state to error, and propagate the error to other tasks in the cluster.
rpc ReportErrorToService(ReportErrorToServiceRequest)
returns (ReportErrorToServiceResponse);
// Insert configuration key-value that will be accessible to all cluster
// workers. The key can be formatted as Unix file path with hierarchy. The
// coordination service key-value store should only be used for cluster
// configuration data.
rpc InsertKeyValue(InsertKeyValueRequest) returns (InsertKeyValueResponse);
// Get configuration key-value. The request blocks until the key-value data
// becomes available (i.e., set by a worker in the cluster).
rpc GetKeyValue(GetKeyValueRequest) returns (GetKeyValueResponse);
// Delete configuration key-value. If is_directory is set in request,
// recursively clean up all key-values under the path specified by `key`.
rpc DeleteKeyValue(DeleteKeyValueRequest) returns (DeleteKeyValueResponse);
// Blocks until all (or a subset of) tasks are at the barrier or the barrier
// fails.
//
// `barrier_id` should be unique across barriers. Once the barrier has passed
// or failed, subsequent calls will not block, and immediately respond with
// the previous response.
//
// The first WaitAtBarrier() call received by the service for a particular
// barrier id is special in that it determines the barrier deadline based on
// timeout duration.
// However, if subsequent calls by different agents specify a different set of
// `tasks` for the same `barrier_id`, the barrier will fail instantly.
//
// If no tasks are specified (default), the barrier will block for all the
// connected tasks.
//
// Possible service errors:
// - DeadlineExceeded: Timed out waiting for specified tasks at the barrier.
// Deadline is determined by the server timestamp when it receives the
// first WaitAtBarrier() + timeout duration.
// - Cancelled: One of the tasks called CancelBarrier().
// - Aborted: Service is shutting down.
// - Internal: Any participating task is in ERROR state.
// - InvalidArgument: (1) Conflicting tasks specified by different agents
// for the same barrier, (2) one of the participating tasks is not in
// the cluster, or (3) task making the request is not included in the
// list of participating tasks.
rpc Barrier(BarrierRequest) returns (BarrierResponse);
// Aborts the barrier if it is ongoing.
// Current and future WaitAtBarrier() calls with the same id will return a
// CANCELLED error status.
// Possible service errors:
// - FailedPrecondition: Barrier has already been passed.
// - NotFound: No barrier with the specified id is found.
rpc CancelBarrier(CancelBarrierRequest) returns (CancelBarrierResponse);
}

View File

@ -1,24 +0,0 @@
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "CriticalSectionProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Protocol buffer representing a CriticalSection.
message CriticalSectionDef {
// Name of the critical section handle.
string critical_section_name = 1;
}
// Protocol buffer representing a CriticalSection execution.
message CriticalSectionExecutionDef {
// Name of the critical section handle.
string execute_in_critical_section_name = 1;
// Whether this operation requires exclusive access to its resources,
// (i.e., no other CriticalSections may request the same resources).
bool exclusive_resource_access = 2;
}

View File

@ -1,88 +0,0 @@
syntax = "proto3";
package tensorflow.data;
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Next tag: 2
message ProcessingModeDef {
// Specifies how data is sharded among tf.data service workers.
enum ShardingPolicy {
// No sharding will be performed. Each worker produces the entire dataset
// without any sharding. With this mode, the best practice is to shuffle the
// dataset nondeterministically so that workers process the dataset in
// different orders.
OFF = 0;
// The input dataset is dynamically split among workers at runtime. Each
// worker gets the next split when it reads data from the dispatcher. There
// is no fixed sharding with this mode.
DYNAMIC = 1;
// The following are static sharding policies. The semantics are similar to
// `tf.data.experimental.AutoShardPolicy`. These policies require:
// * The tf.data service cluster has a fixed size, and you need to specify
// the workers in DispatcherConfig.
// * Each client only reads from the local tf.data service worker.
//
// Shards by input files (each worker will get a set of files to process).
// When this option is selected, make sure that there is at least as many
// files as workers. If there are fewer input files than workers, a runtime
// error will be raised.
FILE = 2;
// Shards by elements produced by the dataset. Each worker will process the
// whole dataset and discard the portion that is not for itself. Note that
// for this mode to correctly partitions the dataset elements, the dataset
// needs to produce elements in a deterministic order.
DATA = 3;
// Attempts FILE-based sharding, falling back to DATA-based sharding on
// failures.
FILE_OR_DATA = 4;
// Looks for the presence of `shard(SHARD_HINT, ...)` which is treated as a
// placeholder to replace with `shard(num_workers, worker_index)`.
HINT = 5;
}
ShardingPolicy sharding_policy = 1;
}
// tf.data service deployment mode.
enum DeploymentMode {
DEPLOYMENT_MODE_UNSPECIFIED = 0;
// tf.data service workers colocate with TF workers.
DEPLOYMENT_MODE_COLOCATED = 1;
// tf.data service workers run in dedicated tf.data hosts.
DEPLOYMENT_MODE_REMOTE = 2;
// tf.data service workers run in colocated TF hosts and dedicated tf.data
// hosts.
DEPLOYMENT_MODE_HYBRID = 3;
}
// Metadata related to tf.data service datasets.
// Next tag: 4
message DataServiceMetadata {
oneof optional_element_spec {
// Serialized element spec.
bytes element_spec = 1;
}
enum Compression {
COMPRESSION_UNSPECIFIED = 0;
// No compression.
COMPRESSION_OFF = 1;
// Snappy compression as defined in tensorflow/core/platform/snappy.h.
COMPRESSION_SNAPPY = 2;
}
Compression compression = 2;
// Cardinality of the dataset.
int64 cardinality = 3;
}
// Data service config available to the client through GetDataServiceConfig RPC.
// Next tag: 2
message DataServiceConfig {
DeploymentMode deployment_mode = 1;
}

View File

@ -1,94 +0,0 @@
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "DebugProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Option for watching a node in TensorFlow Debugger (tfdbg).
message DebugTensorWatch {
// Name of the node to watch.
// Use "*" for wildcard. But note: currently, regex is not supported in
// general.
string node_name = 1;
// Output slot to watch.
// The semantics of output_slot == -1 is that all outputs of the node
// will be watched (i.e., a wildcard).
// Other negative values of output_slot are invalid and will lead to
// errors currently.
int32 output_slot = 2;
// Name(s) of the debugging op(s).
// One or more than one probes on a tensor.
// e.g., {"DebugIdentity", "DebugNanCount"}
repeated string debug_ops = 3;
// URL(s) for debug targets(s).
//
// Supported URL formats are:
// - file:///foo/tfdbg_dump: Writes out Event content to file
// /foo/tfdbg_dump. Assumes all directories can be created if they don't
// already exist.
// - grpc://localhost:11011: Sends an RPC request to an EventListener
// service running at localhost:11011 with the event.
// - memcbk:///event_key: Routes tensors to clients using the
// callback registered with the DebugCallbackRegistry for event_key.
//
// Each debug op listed in debug_ops will publish its output tensor (debug
// signal) to all URLs in debug_urls.
//
// N.B. Session::Run() supports concurrent invocations of the same inputs
// (feed keys), outputs and target nodes. If such concurrent invocations
// are to be debugged, the callers of Session::Run() must use distinct
// debug_urls to make sure that the streamed or dumped events do not overlap
// among the invocations.
// TODO(cais): More visible documentation of this in g3docs.
repeated string debug_urls = 4;
// Do not error out if debug op creation fails (e.g., due to dtype
// incompatibility). Instead, just log the failure.
bool tolerate_debug_op_creation_failures = 5;
}
// Options for initializing DebuggerState in TensorFlow Debugger (tfdbg).
message DebugOptions {
// Debugging options
repeated DebugTensorWatch debug_tensor_watch_opts = 4;
// Caller-specified global step count.
// Note that this is distinct from the session run count and the executor
// step count.
int64 global_step = 10;
// Whether the total disk usage of tfdbg is to be reset to zero
// in this Session.run call. This is used by wrappers and hooks
// such as the local CLI ones to indicate that the dumped tensors
// are cleaned up from the disk after each Session.run.
bool reset_disk_byte_usage = 11;
}
message DebuggedSourceFile {
// The host name on which a source code file is located.
string host = 1;
// Path to the source code file.
string file_path = 2;
// The timestamp at which the source code file is last modified.
int64 last_modified = 3;
// Byte size of the file.
int64 bytes = 4;
// Line-by-line content of the source code file.
repeated string lines = 5;
}
message DebuggedSourceFiles {
// A collection of source code files.
repeated DebuggedSourceFile source_files = 1;
}

View File

@ -1,300 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/tensor.proto";
import "tensorflow/core/protobuf/graph_debug_info.proto";
option cc_enable_arenas = true;
option java_outer_classname = "DebugEventProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.util";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Available modes for extracting debugging information from a Tensor.
// TODO(cais): Document the detailed column names and semantics in a separate
// markdown file once the implementation settles.
enum TensorDebugMode {
UNSPECIFIED = 0;
// Only records what tensors are computed, eagerly or in graphs.
// No information regarding the value of the tensor is available.
NO_TENSOR = 1;
// A minimalist health summary for float-type tensors.
// Contains information only about the presence/absence of pathological
// values including Infinity and NaN.
// Applicable only to float dtypes.
CURT_HEALTH = 2;
// A concise health summary for float-type tensors.
// Contains more information that CURT_HEALTH.
// Infinity and NaN are treated differently.
// Applicable only to float and integer dtypes.
CONCISE_HEALTH = 3;
// A detailed health summary.
// Contains further detailed information than `CONCISE_HEALTH`.
// Information about device, dtype and shape are included.
// Counts for various types of values (Infinity, NaN, negative, zero,
// positive) are included.
// Applicable to float, integer and boolean dtypes.
FULL_HEALTH = 4;
// Provides full runtime shape information, up to a maximum rank, beyond
// which the dimension sizes are truncated.
SHAPE = 5;
// Full numeric summary.
// Including device, dtype, shape, counts of various types of values
// (Infinity, NaN, negative, zero, positive), and summary statistics
// (minimum, maximum, mean and variance).
// Applicable to float, integer and boolean dtypes.
FULL_NUMERICS = 6;
// Full tensor value.
FULL_TENSOR = 7;
// Reduce the elements of a tensor to a rank-1 tensor of shape [3], in which
// - the 1st element is -inf if any element of the tensor is -inf,
// or zero otherwise.
// - the 2nd element is +inf if any element of the tensor is +inf,
// or zero otherwise.
// - the 3rd element is nan if any element of the tensor is nan, or zero
// otherwise.
REDUCE_INF_NAN_THREE_SLOTS = 8;
}
// An Event related to the debugging of a TensorFlow program.
message DebugEvent {
// Timestamp in seconds (with microsecond precision).
double wall_time = 1;
// Step of training (if available).
int64 step = 2;
oneof what {
// Metadata related to this debugging data.
DebugMetadata debug_metadata = 3;
// The content of a source file.
SourceFile source_file = 4;
// A stack frame (filename, line number and column number, function name and
// code string) with ID.
StackFrameWithId stack_frame_with_id = 6;
// The creation of an op within a graph (e.g., a FuncGraph compiled from
// a Python function).
GraphOpCreation graph_op_creation = 7;
// Information about a debugged graph.
DebuggedGraph debugged_graph = 8;
// Execution of an op or a Graph (e.g., a tf.function).
Execution execution = 9;
// A graph execution trace: Contains information about the intermediate
// tensors computed during the graph execution.
GraphExecutionTrace graph_execution_trace = 10;
// The ID of the graph (i.e., FuncGraph) executed here: applicable only
// to the execution of a FuncGraph.
string graph_id = 11;
// A device on which debugger-instrumented ops and/or tensors reside.
DebuggedDevice debugged_device = 12;
}
}
// Metadata about the debugger and the debugged TensorFlow program.
message DebugMetadata {
// Version of TensorFlow.
string tensorflow_version = 1;
// Version of the DebugEvent file format.
// Has a format of "debug.Event:<number>", e.g., "debug.Event:1".
string file_version = 2;
// A unique ID for the current run of tfdbg.
// A run of tfdbg is defined as a TensorFlow job instrumented by tfdbg.
// Multiple hosts in a distributed TensorFlow job instrumented by tfdbg
// have the same ID.
string tfdbg_run_id = 3;
}
// Content of a source file involved in the execution of the debugged TensorFlow
// program.
message SourceFile {
// Path to the file.
string file_path = 1;
// Name of the host on which the file is located.
string host_name = 2;
// Line-by-line content of the file.
repeated string lines = 3;
}
// A stack frame with ID.
message StackFrameWithId {
// A unique ID for the stack frame: A UUID-like string.
string id = 1;
// Stack frame, i.e., a frame of a stack trace, containing information
// regarding the file name, line number, function name, code content
// of the line, and column number (if available).
GraphDebugInfo.FileLineCol file_line_col = 2;
}
// Code location information: A stack trace with host-name information.
// Instead of encoding the detailed stack trace, this proto refers to IDs of
// stack frames stored as `StackFrameWithId` protos.
message CodeLocation {
// Host name on which the source files are located.
string host_name = 1;
// ID to a stack frame, each of which is pointed to
// by a unique ID. The ordering of the frames is consistent with Python's
// `traceback.extract_tb()`.
repeated string stack_frame_ids = 2;
}
// The creation of an op in a TensorFlow Graph (e.g., FuncGraph in TF2).
message GraphOpCreation {
// Type of the op (e.g., "MatMul").
string op_type = 1;
// Name of the op (e.g., "Dense/MatMul_1").
string op_name = 2;
// Name of the graph that the op is a part of (if available).
string graph_name = 3;
// Unique ID of the graph (generated by debugger).
// This is the ID of the immediately-enclosing graph.
string graph_id = 4;
// Name of the device that the op is assigned to (if available).
string device_name = 5;
// Names of the input tensors to the op.
repeated string input_names = 6;
// Number of output tensors emitted by the op.
int32 num_outputs = 7;
// The unique ID for code location (stack trace) of the op's creation.
CodeLocation code_location = 8;
// Unique IDs for the output tensors of this op.
repeated int32 output_tensor_ids = 9;
}
// A debugger-instrumented graph.
message DebuggedGraph {
// An ID for the graph.
// This can be used up to look up graph names. Generated by the debugger.
string graph_id = 1;
// Name of the graph (if available).
string graph_name = 2;
// Names of the instrumented ops. This can be used to look up op name
// based on the numeric-summary tensors (2nd column).
repeated string instrumented_ops = 3;
// Original (uninstrumented) GraphDef (if available).
bytes original_graph_def = 4;
// An encoded version of a GraphDef.
// This graph may include the debugger-inserted ops.
bytes instrumented_graph_def = 5;
// IDs of the immediate enclosing context (graph), if any.
string outer_context_id = 6;
}
// A device on which ops and/or tensors are instrumented by the debugger.
message DebuggedDevice {
// Name of the device.
string device_name = 1;
// A debugger-generated ID for the device. Guaranteed to be unique within
// the scope of the debugged TensorFlow program, including single-host and
// multi-host settings.
// TODO(cais): Test the uniqueness guarantee in multi-host settings.
int32 device_id = 2;
}
// Data relating to the eager execution of an op or a Graph.
// For a op that generates N output tensors (N >= 0), only one
// Execution proto will be used to describe the execution event.
message Execution {
// Op type (e.g., "MatMul").
// In the case of a Graph, this is the name of the Graph.
string op_type = 1;
// Number of output tensors.
int32 num_outputs = 2;
// The graph that's executed: applicable only to the eager
// execution of a FuncGraph.
string graph_id = 3;
// IDs of the input tensors (if available).
repeated int64 input_tensor_ids = 4;
// IDs of the output tensors (if availbable).
// If specified, must have the same length as tensor_protos.
repeated int64 output_tensor_ids = 5;
// Type of the tensor value encapsulated in this proto.
TensorDebugMode tensor_debug_mode = 6;
// Output Tensor values in the type described by `tensor_value_type`.
// The length of this should match `num_outputs`.
repeated TensorProto tensor_protos = 7;
// Stack trace of the eager execution.
CodeLocation code_location = 8;
// Debugged-generated IDs of the devices on which the output tensors reside.
// To look up details about the device (e.g., name), cross-reference this
// field with the DebuggedDevice messages.
repeated int32 output_tensor_device_ids = 9;
// TODO(cais): When backporting to V1 Session.run() support, add more fields
// such as fetches and feeds.
}
// Data relating to an execution of a Graph (e.g., an eager execution of a
// FuncGraph).
// The values of the intermediate tensors computed in the graph are recorded
// in this proto. A graph execution may correspond to one or more pieces of
// `GraphExecutionTrace`, depending on whether the instrumented tensor values
// are summarized in an aggregated or separate fashion.
message GraphExecutionTrace {
// Unique ID of the context that the executed op(s) belong to (e.g., a
// compiled concrete tf.function).
string tfdbg_context_id = 1;
// Name of the op (applicable only in the case of the `FULL_TENSOR` trace
// level).
string op_name = 2;
// Output slot of the tensor (applicable only in the case of the `FULL_TENSOR`
// trace level).
int32 output_slot = 3;
// Type of the tensor value encapsulated in this proto.
TensorDebugMode tensor_debug_mode = 4;
// Tensor value in the type described by `tensor_value_type`.
// This tensor may summarize the value of a single intermediate op of the
// graph, or those of multiple intermediate tensors.
TensorProto tensor_proto = 5;
// Name of the device that the op belongs to.
string device_name = 6;
}

View File

@ -1,73 +0,0 @@
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "DeviceFiltersProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.distruntime";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// This file contains protos to be used when defining a TensorFlow
// cluster.
//
// Configure device filters for remote tasks in the cluster. When associated
// with a ClusterDef in setting up the cluster, a remote task will ignore all
// devices which do not match any of its filters. Device filters must be
// configured at the cluster startup, and cannot be updated once the cluster is
// up and running.
//
// EXAMPLES
// --------
//
// A two-job cluster with the following ClusterDef:
//
// Cluster:
// job { name: 'worker' tasks { key: 0 value: 'worker1:2222' }
// tasks { key: 1 value: 'worker2:2222' } }
// job { name: 'ps' tasks { key: 0 value: 'ps0:2222' }
// tasks { key: 1 value: 'ps1:2222' } }
//
// Set device filters to isolate worker tasks:
//
// ClusterDeviceFilters:
// job { name: 'worker' tasks { key: 0
// value: device_filter '/job:ps'
// device_filter '/job:worker/task:0' }
// tasks { key: 1
// value: device_filter '/job:ps'
// device_filter '/job:worker/task:1' } }
// Defines the device filters for a remote task.
message TaskDeviceFilters {
repeated string device_filters = 1;
}
// Defines the device filters for tasks in a job.
message JobDeviceFilters {
// The name of this job.
string name = 1;
// Mapping from task ID to task device filters.
map<int32, TaskDeviceFilters> tasks = 2;
}
// Defines the device filters for jobs in a cluster.
message ClusterDeviceFilters {
repeated JobDeviceFilters jobs = 1;
}

View File

@ -1,58 +0,0 @@
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "DevicePropertiesProtos";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
message DeviceProperties {
// Device type (CPU, GPU, ...)
string type = 1;
// Vendor (Intel, nvidia, ...)
string vendor = 2;
// Model (Haswell, K40, ...)
string model = 3;
// Core Frequency in Mhz
int64 frequency = 4;
// Number of cores
int64 num_cores = 5;
// Version of the tools and libraries used with this device (e.g. gcc 4.9,
// cudnn 5.1)
map<string, string> environment = 6;
// Number of registers per core.
int64 num_registers = 7;
// L1 cache size in bytes
int64 l1_cache_size = 8;
// L2 cache size in bytes
int64 l2_cache_size = 9;
// L3 cache size in bytes
int64 l3_cache_size = 10;
// Shared memory size per multiprocessor in bytes. This field is
// applicable to GPUs only.
int64 shared_memory_size_per_multiprocessor = 11;
// Memory size in bytes
int64 memory_size = 12;
// Memory bandwidth in KB/s
int64 bandwidth = 13;
}
message NamedDevice {
string name = 1;
DeviceProperties properties = 2;
}

View File

@ -1,24 +0,0 @@
syntax = "proto3";
package tensorflow.distributed_runtime;
option cc_enable_arenas = true;
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Used to serialize and transmit tensorflow::Status payloads through
// grpc::Status `error_details` since grpc::Status lacks payload API.
// TODO(b/204231601): Use GRPC API once supported.
message GrpcPayloadContainer {
map<string, bytes> payloads = 1;
}
// If included as a payload, this message flags the Status to have lost payloads
// during the GRPC transmission.
// URI: "type.googleapis.com/tensorflow.distributed_runtime.GrpcPayloadsLost"
message GrpcPayloadsLost {}
// If included as a payload, this message flags the Status to be a possible
// outcome of a worker restart.
// URI:
// "type.googleapis.com/tensorflow.distributed_runtime.WorkerPossiblyRestarted"
message WorkerPossiblyRestarted {}

View File

@ -1,344 +0,0 @@
syntax = "proto3";
package tensorflow.eager;
import "tensorflow/core/framework/attr_value.proto";
import "tensorflow/core/framework/device_attributes.proto";
import "tensorflow/core/framework/function.proto";
import "tensorflow/core/framework/tensor.proto";
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/versions.proto";
import "tensorflow/core/protobuf/remote_tensor_handle.proto";
import "tensorflow/core/protobuf/tensorflow_server.proto";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// A proto representation of an eager operation.
message Operation {
// A unique identifier for the operation. Set by the client so that the client
// can uniquely identify the outputs of the scheduled operation.
//
// In the initial implementation, sending duplicate IDs has undefined
// behaviour, but additional constraints may be placed upon this in the
// future.
int64 id = 1;
string name = 2;
message Input {
oneof item {
RemoteTensorHandle remote_handle = 1;
TensorProto tensor = 2;
}
}
repeated Input op_inputs = 10;
// Control Operation IDs that will be respected when ops are re-ordered by
// async execution. If async execution (+ op re-ordering) is not enabled, this
// should have no effect.
repeated int64 control_op_ids = 4;
map<string, AttrValue> attrs = 5;
string device = 6;
// Indicates whether the op is a component of a multi-device function.
bool is_component_function = 7;
// Set when is_component_function is true. It's initially generated
// when we create an FunctionLibraryRuntime::Options (negative value) and used
// to create Rendezvous for function execution. All components of a
// multi-device function should use the same step id to make sure that they
// can communicate through Send/Recv ops.
int64 func_step_id = 8;
// Indicates whether the op is a function.
bool is_function = 9;
reserved 3;
}
message QueueItem {
// The remote executor should be able to handle either executing ops directly,
// or releasing any unused tensor handles, since the tensor lifetime is
// maintained by the client.
oneof item {
RemoteTensorHandle handle_to_decref = 1;
Operation operation = 2;
SendTensorOp send_tensor = 3;
// Takes a FunctionDef and makes it enqueable on the remote worker.
RegisterFunctionOp register_function = 4;
CleanupFunctionOp cleanup_function = 5;
// A remote executor is created to execute ops/functions asynchronously
// enqueued in streaming call. Request with this item type waits for pending
// nodes to finish on the remote executor and report status.
SyncRemoteExecutorForStream sync_remote_executor_for_stream = 6;
SendPackedHandleOp send_packed_handle = 7;
}
}
message QueueResponse {
// `shape` and `tensor` cannot be set in the same response.
// Shapes of output tensors for creating remote TensorHandles.
repeated TensorShapeProto shape = 1;
// Optional. If set, represents the output devices of a function.
repeated string device = 3;
// Output tensors of a remote function. Set when Operation.id is invalid.
repeated TensorProto tensor = 2;
}
message CreateContextRequest {
// Identifies the full cluster, and this particular worker's position within.
ServerDef server_def = 1;
// Whether the ops on the worker should be executed synchronously or
// asynchronously. By default, ops are executed synchronously.
bool async = 2;
// Number of seconds to keep the context alive. If more than keep_alive_secs
// has passed since a particular context has been communicated with, it will
// be garbage collected.
int64 keep_alive_secs = 3;
// This is the version for all the ops that will be enqueued by the client.
VersionDef version_def = 4;
// Device attributes in the cluster
repeated DeviceAttributes cluster_device_attributes = 6;
// The ID of the created context. This is usually a randomly generated number,
// that will be used to identify the context in future requests to the
// service. Contexts are not persisted through server restarts.
// This ID will be used for all future communications as well. It is essential
// that both ends use this ID for selecting a rendezvous to get everything to
// match.
fixed64 context_id = 7;
// The view ID of the context.
fixed64 context_view_id = 8;
// For a multi device function, if false, eagerly copy all remote inputs to
// the default function device; if true, lazily copy remote inputs to their
// target devices after function instantiation to avoid redundant copies.
bool lazy_copy_remote_function_inputs = 9;
reserved 5;
}
message CreateContextResponse {
// List of devices that are locally accessible to the worker.
repeated DeviceAttributes device_attributes = 2;
reserved 1;
}
message UpdateContextRequest {
// Identifies the full cluster, and this particular worker's position within.
ServerDef server_def = 1;
// Device attributes in the cluster.
// If this field is empty, it indicates that this is a simple update request
// that only increments the cluster view ID and does not require changes to
// the workers it connects to.
repeated DeviceAttributes cluster_device_attributes = 2;
// The ID of the context to be updated. A context with the specified ID must
// already exist on the recepient server of this request.
fixed64 context_id = 3;
// The view ID of the context, which should be contiguously incremented when
// updating the same context.
fixed64 context_view_id = 4;
}
message UpdateContextResponse {
// List of devices that are locally accessible to the worker.
repeated DeviceAttributes device_attributes = 1;
}
message EnqueueRequest {
fixed64 context_id = 1;
repeated QueueItem queue = 3;
}
message EnqueueResponse {
// A single operation response for every item in the request.
repeated QueueResponse queue_response = 1;
}
message WaitQueueDoneRequest {
fixed64 context_id = 1;
// Ids to wait on. If empty, wait on everything currently pending.
repeated int64 op_id = 2;
}
message WaitQueueDoneResponse {
// TODO(nareshmodi): Consider adding NodeExecStats here to be able to
// propagate some stats.
}
message RunComponentFunctionRequest {
fixed64 context_id = 1;
Operation operation = 2;
// The output indices of its parent function.
repeated int32 output_num = 3;
}
message RunComponentFunctionResponse {
repeated TensorShapeProto shape = 1;
repeated TensorProto tensor = 2;
}
message KeepAliveRequest {
fixed64 context_id = 1;
}
message KeepAliveResponse {
// If the requested context_id is on the remote host, set the context view ID.
fixed64 context_view_id = 1;
}
message CloseContextRequest {
fixed64 context_id = 1;
fixed64 context_view_id = 2;
}
message CloseContextResponse {}
message RegisterFunctionOp {
FunctionDef function_def = 1;
// If true, it means that function_def is produced by graph partition during
// multi-device function instantiation.
bool is_component_function = 2;
// All necessary FunctionDefs and GradientDefs to expand `function_def`.
// When is_component_function is true, `function_def` could be a nested
// function, since some nodes in its parent's function body could be
// replaced with a new function by the graph optimization passes. No need to
// add FunctionDefs here to the function cache in EagerContext since they
// won't be executed as KernelAndDevices.
FunctionDefLibrary library = 3;
}
// Cleanup the step state of a multi-device function (e.g. tensors buffered by
// a `Send` op but not picked up by its corresponding `Recv` op).
message CleanupFunctionOp {
int64 step_id = 1;
}
message SyncRemoteExecutorForStream {}
message SendTensorOp {
// All remote tensors are identified by <Op ID, Output num>. To mimic this
// situation when directly sending tensors, we include an "artificial" op ID
// (which would have corresponded to the _Recv op when not using SendTensor).
int64 op_id = 1;
// The index within the repeated field is the output number that will help
// uniquely identify (along with the above op_id) the particular tensor.
repeated TensorProto tensors = 2;
// The device on which the tensors should be resident.
string device_name = 3;
}
// Send a packed TensorHandle to a remote worker.
message SendPackedHandleOp {
// Op id of the remote packed TensorHandle.
int64 op_id = 1;
message LocalTensorHandle {
TensorProto tensor = 1;
// Device where the tensor is produced.
string device = 2;
}
message Handle {
oneof item {
LocalTensorHandle local_handle = 1;
RemoteTensorHandle remote_handle = 2;
}
}
repeated Handle handles = 2;
string device_name = 3;
}
////////////////////////////////////////////////////////////////////////////////
//
// Eager Service defines a TensorFlow service that executes operations eagerly
// on a set of local devices, on behalf of a remote Eager executor.
//
// The service impl will keep track of the various clients and devices it has
// access to and allows the client to enqueue ops on any devices that it is able
// to access and schedule data transfers from/to any of the peers.
//
// A client can generate multiple contexts to be able to independently execute
// operations, but cannot share data between the two contexts.
//
// NOTE: Even though contexts generated by clients should be independent, the
// lower level tensorflow execution engine is not, so they might share some data
// (e.g. a Device's ResourceMgr).
//
////////////////////////////////////////////////////////////////////////////////
service EagerService {
// This initializes the worker, informing it about the other workers in the
// cluster and exchanging authentication tokens which will be used in all
// other RPCs to detect whether the worker has restarted.
rpc CreateContext(CreateContextRequest) returns (CreateContextResponse);
// This updates the eager context on an existing worker when updating the set
// of servers in a distributed eager cluster.
rpc UpdateContext(UpdateContextRequest) returns (UpdateContextResponse);
// This takes a list of Execute and DeleteTensorHandle operations and enqueues
// (in async mode) or executes (in sync mode) them on the remote server.
// All outputs of ops which were not explicitly deleted with
// DeleteTensorHandle entries will be assumed to be alive and are usable by
// future calls to Enqueue.
rpc Enqueue(EnqueueRequest) returns (EnqueueResponse);
// A streaming version of Enqueue.
// Current server implementation sends one response per received request.
// The benefit for using a streaming version is that subsequent requests
// can be sent without waiting for a response to the previous request. This
// synchronization is required in the regular Enqueue call because gRPC does
// not guarantee to preserve request order.
rpc StreamingEnqueue(stream EnqueueRequest) returns (stream EnqueueResponse);
// Takes a set of op IDs and waits until those ops are done. Returns any error
// in the stream so far.
rpc WaitQueueDone(WaitQueueDoneRequest) returns (WaitQueueDoneResponse);
// This takes an Eager operation and executes it in async mode on the remote
// server. Different from EnqueueRequest, ops/functions sent through this
// type of requests are allowed to execute in parallel and no ordering is
// preserved by RPC stream or executor.
// This request type should only be used for executing component functions.
// Ordering of component functions should be enforced by their corresponding
// main functions. The runtime ensures the following invarients for component
// functions (CFs) and their main functions (MFs):
// (1) MF1 -> MF2 ==> CF1 -> CF2 ("->" indicates order of execution);
// (2) MF1 || MF2 ==> CF1 || CF2 ("||" indicates possible parallel execution);
// (3) For CF1 and CF2 that come from the same MF, CF1 || CF2
// For executing ops/main functions, use Enqueue or StreamingEnqueue instead
// for correct ordering.
rpc RunComponentFunction(RunComponentFunctionRequest)
returns (RunComponentFunctionResponse);
// Contexts are always created with a deadline and no RPCs within a deadline
// will trigger a context garbage collection. KeepAlive calls can be used to
// delay this. It can also be used to validate the existence of a context ID
// on remote eager worker. If the context is on remote worker, return the same
// ID and the current context view ID. This is useful for checking if the
// remote worker (potentially with the same task name and hostname / port) is
// replaced with a new process.
rpc KeepAlive(KeepAliveRequest) returns (KeepAliveResponse);
// Closes the context. No calls to other methods using the existing context ID
// are valid after this.
rpc CloseContext(CloseContextRequest) returns (CloseContextResponse);
}

View File

@ -1,152 +0,0 @@
syntax = "proto3";
package tensorflow.error;
option cc_enable_arenas = true;
option java_outer_classname = "ErrorCodesProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// The canonical error codes for TensorFlow APIs.
//
// Warnings:
//
// - Do not change any numeric assignments.
// - Changes to this list should only be made if there is a compelling
// need that can't be satisfied in another way. Such changes
// must be approved by at least two OWNERS.
// - These error codes must match gRPC and protobuf error codes (except for
// DO_NOT_USE_RESERVED_FOR_FUTURE_EXPANSION_USE_DEFAULT_IN_SWITCH_INSTEAD_).
//
// Sometimes multiple error codes may apply. Services should return
// the most specific error code that applies. For example, prefer
// OUT_OF_RANGE over FAILED_PRECONDITION if both codes apply.
// Similarly prefer NOT_FOUND or ALREADY_EXISTS over FAILED_PRECONDITION.
enum Code {
// Not an error; returned on success
OK = 0;
// The operation was cancelled (typically by the caller).
CANCELLED = 1;
// Unknown error. An example of where this error may be returned is
// if a Status value received from another address space belongs to
// an error-space that is not known in this address space. Also
// errors raised by APIs that do not return enough error information
// may be converted to this error.
UNKNOWN = 2;
// Client specified an invalid argument. Note that this differs
// from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments
// that are problematic regardless of the state of the system
// (e.g., a malformed file name).
INVALID_ARGUMENT = 3;
// Deadline expired before operation could complete. For operations
// that change the state of the system, this error may be returned
// even if the operation has completed successfully. For example, a
// successful response from a server could have been delayed long
// enough for the deadline to expire.
DEADLINE_EXCEEDED = 4;
// Some requested entity (e.g., file or directory) was not found.
// For privacy reasons, this code *may* be returned when the client
// does not have the access right to the entity.
NOT_FOUND = 5;
// Some entity that we attempted to create (e.g., file or directory)
// already exists.
ALREADY_EXISTS = 6;
// The caller does not have permission to execute the specified
// operation. PERMISSION_DENIED must not be used for rejections
// caused by exhausting some resource (use RESOURCE_EXHAUSTED
// instead for those errors). PERMISSION_DENIED must not be
// used if the caller can not be identified (use UNAUTHENTICATED
// instead for those errors).
PERMISSION_DENIED = 7;
// The request does not have valid authentication credentials for the
// operation.
UNAUTHENTICATED = 16;
// Some resource has been exhausted, perhaps a per-user quota, or
// perhaps the entire file system is out of space.
RESOURCE_EXHAUSTED = 8;
// Operation was rejected because the system is not in a state
// required for the operation's execution. For example, directory
// to be deleted may be non-empty, an rmdir operation is applied to
// a non-directory, etc.
//
// A litmus test that may help a service implementor in deciding
// between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE:
// (a) Use UNAVAILABLE if the client can retry just the failing call.
// (b) Use ABORTED if the client should retry at a higher-level
// (e.g., restarting a read-modify-write sequence).
// (c) Use FAILED_PRECONDITION if the client should not retry until
// the system state has been explicitly fixed. E.g., if an "rmdir"
// fails because the directory is non-empty, FAILED_PRECONDITION
// should be returned since the client should not retry unless
// they have first fixed up the directory by deleting files from it.
// (d) Use FAILED_PRECONDITION if the client performs conditional
// REST Get/Update/Delete on a resource and the resource on the
// server does not match the condition. E.g., conflicting
// read-modify-write on the same resource.
FAILED_PRECONDITION = 9;
// The operation was aborted, typically due to a concurrency issue
// like sequencer check failures, transaction aborts, etc.
//
// See litmus test above for deciding between FAILED_PRECONDITION,
// ABORTED, and UNAVAILABLE.
ABORTED = 10;
// Operation tried to iterate past the valid input range. E.g., seeking or
// reading past end of file.
//
// Unlike INVALID_ARGUMENT, this error indicates a problem that may
// be fixed if the system state changes. For example, a 32-bit file
// system will generate INVALID_ARGUMENT if asked to read at an
// offset that is not in the range [0,2^32-1], but it will generate
// OUT_OF_RANGE if asked to read from an offset past the current
// file size.
//
// There is a fair bit of overlap between FAILED_PRECONDITION and
// OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific
// error) when it applies so that callers who are iterating through
// a space can easily look for an OUT_OF_RANGE error to detect when
// they are done.
OUT_OF_RANGE = 11;
// Operation is not implemented or not supported/enabled in this service.
UNIMPLEMENTED = 12;
// Internal errors. Means some invariant expected by the underlying
// system has been broken. If you see one of these errors,
// something is very broken.
INTERNAL = 13;
// The service is currently unavailable. This is a most likely a
// transient condition and may be corrected by retrying with
// a backoff.
//
// See litmus test above for deciding between FAILED_PRECONDITION,
// ABORTED, and UNAVAILABLE.
UNAVAILABLE = 14;
// Unrecoverable data loss or corruption.
DATA_LOSS = 15;
// An extra enum entry to prevent people from writing code that
// fails to compile when a new code is added.
//
// Nobody should ever reference this enumeration entry. In particular,
// if you write C++ code that switches on this enumeration, add a default:
// case instead of a case that mentions this enumeration entry.
//
// Nobody should rely on the value (currently 20) listed here. It
// may change in the future.
DO_NOT_USE_RESERVED_FOR_FUTURE_EXPANSION_USE_DEFAULT_IN_SWITCH_INSTEAD_ = 20;
}

View File

@ -1,52 +0,0 @@
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "GraphDebugInfoProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
message GraphDebugInfo {
// This represents a file/line location in the source code.
message FileLineCol {
// File name index, which can be used to retrieve the file name string from
// `files`. The value should be between 0 and (len(files)-1)
int32 file_index = 1;
// Line number in the file.
int32 line = 2;
// Col number in the file line.
int32 col = 3;
// Name of function contains the file line.
string func = 4;
// Source code contained in this file line.
string code = 5;
}
// This represents a stack trace which is a ordered list of `FileLineCol`.
message StackTrace {
// Each line in the stack trace.
repeated FileLineCol file_line_cols = 1;
}
// This stores all the source code file names and can be indexed by the
// `file_index`.
repeated string files = 1;
// This maps a node name to a stack trace in the source code.
// The map key is a mangling of the containing function and op name with
// syntax:
// op.name '@' func_name
// For ops in the top-level graph, the func_name is the empty string.
// Note that op names are restricted to a small number of characters which
// exclude '@', making it impossible to collide keys of this form. Function
// names accept a much wider set of characters.
// It would be preferable to avoid mangling and use a tuple key of (op.name,
// func_name), but this is not supported with protocol buffers.
map<string, StackTrace> traces = 2;
}

View File

@ -1,353 +0,0 @@
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/device_attributes.proto";
import "tensorflow/core/framework/graph.proto";
import "tensorflow/core/framework/tensor.proto";
import "tensorflow/core/protobuf/config.proto";
import "tensorflow/core/protobuf/error_codes.proto";
import "tensorflow/core/protobuf/named_tensor.proto";
option cc_enable_arenas = true;
option java_outer_classname = "DistributedRuntimeProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.distruntime";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
////////////////////////////////////////////////////////////////////////////////
//
// CreateSession method request/response protos.
//
////////////////////////////////////////////////////////////////////////////////
message CreateSessionRequest {
// The initial graph definition.
GraphDef graph_def = 1;
// Configuration options.
ConfigProto config = 2;
// The target string used from the client's perspective.
string target = 3;
}
message CreateSessionResponse {
// The session handle to be used in subsequent calls for the created session.
//
// The client must arrange to call CloseSession with this returned
// session handle to close the session.
string session_handle = 1;
// The initial version number for the graph, to be used in the next call
// to ExtendSession.
int64 graph_version = 2;
}
////////////////////////////////////////////////////////////////////////////////
//
// ExtendSession method request/response protos.
//
// The "graph_def" specifies a set of nodes to be added to the session's graph.
//
// A typical "graph_def" will contain:
//
// * Zero or more new nodes with names that do not exist in the server-side
// graph. These will be added to the graph.
//
// PRECONDITION: The server-side current version is req.current_version.
// None of the names in req.graph_def appeared in previous successful calls to
// CreateSession or ExtendSession with the same session_handle.
// POSTCONDITION: The server-side current version is resp.new_version.
//
////////////////////////////////////////////////////////////////////////////////
message ExtendSessionRequest {
// REQUIRED: session_handle must be returned by a CreateSession call
// to the same master service.
string session_handle = 1;
// REQUIRED: The nodes to be added to the session's graph. If any node has
// the same name as an existing node, the operation will fail with
// ILLEGAL_ARGUMENT.
GraphDef graph_def = 2;
// REQUIRED: The version number of the graph to be extended. This will be
// tested against the current server-side version number, and the operation
// will fail with FAILED_PRECONDITION if they do not match.
int64 current_graph_version = 3;
}
message ExtendSessionResponse {
// TODO(mrry): Return something about the operation?
// The new version number for the extended graph, to be used in the next call
// to ExtendSession.
int64 new_graph_version = 4;
}
////////////////////////////////////////////////////////////////////////////////
//
// RunStep method request/response protos.
//
// The caller should provide the feeds needed by the graph and specify
// what nodes should be fetched.
//
////////////////////////////////////////////////////////////////////////////////
message RunStepRequest {
// REQUIRED: session_handle must be returned by a CreateSession call
// to the same master service.
string session_handle = 1;
// Tensors to be fed in the step. Each feed is a named tensor.
repeated NamedTensorProto feed = 2;
// Fetches. A list of tensor names. The caller expects a tensor to
// be returned for each fetch[i] (see RunStepResponse.tensor). The
// order of specified fetches does not change the execution order.
repeated string fetch = 3;
// Target Nodes. A list of node names. The named nodes will be run
// to but their outputs will not be fetched.
repeated string target = 4;
// Options for the run call.
RunOptions options = 5;
// Partial run handle (optional). If specified, this will be a partial run
// execution, run up to the specified fetches.
string partial_run_handle = 6;
// If true then some errors, e.g., execution errors that have long
// error messages, may return an OK RunStepResponse with the actual
// error saved in the status_code/status_error_message fields of the
// response body. This is a workaround since the RPC subsystem may
// truncate long metadata messages.
bool store_errors_in_response_body = 7;
// Unique identifier for this request. Every RunStepRequest must
// have a unique request_id, and retried RunStepRequest must have
// the same request_id. If request_id is zero, retry detection is disabled.
int64 request_id = 8;
}
message RunStepResponse {
// NOTE: The order of the returned tensors may or may not match
// the fetch order specified in RunStepRequest.
repeated NamedTensorProto tensor = 1;
// Returned metadata if requested in the options.
RunMetadata metadata = 2;
// If store_errors_in_response_body is true in the request, then
// optionally the server may return an OK status for the RPC and
// fill the true status into the fields below, to allow for messages
// that are too long to fit in metadata.
error.Code status_code = 3;
string status_error_message = 4;
}
////////////////////////////////////////////////////////////////////////////////
//
// PartialRunSetup method request/response protos.
//
// The caller should provide the future partial run feeds, fetches, and targets.
// Then the caller can use RunStepRequest with is_partial set to make partial
// run calls.
//
////////////////////////////////////////////////////////////////////////////////
message PartialRunSetupRequest {
// REQUIRED: session_handle must be returned by a CreateSession call
// to the same master service.
string session_handle = 1;
// Tensors to be fed in future steps.
repeated string feed = 2;
// Fetches. A list of tensor names. The caller expects a tensor to be returned
// for each fetch[i] (see RunStepResponse.tensor), for corresponding partial
// RunStepRequests. The order of specified fetches does not change the
// execution order.
repeated string fetch = 3;
// Target Nodes. A list of node names. The named nodes will be run in future
// steps, but their outputs will not be fetched.
repeated string target = 4;
// Unique identifier for this request. Every PartialRunSetupRequest must
// have a unique request_id, and retried PartialRunSetupRequest must have
// the same request_id. If request_id is zero, retry detection is disabled.
int64 request_id = 5;
}
message PartialRunSetupResponse {
// The unique handle corresponding to the ongoing partial run call setup by
// the invocation to PartialRunSetup. This handle may be passed to
// RunStepRequest to send and receive tensors for this partial run.
string partial_run_handle = 1;
}
////////////////////////////////////////////////////////////////////////////////
//
// CloseSession method request/response protos.
//
////////////////////////////////////////////////////////////////////////////////
message CloseSessionRequest {
// REQUIRED: session_handle must be returned by a CreateSession call
// to the same master service.
string session_handle = 1;
}
message CloseSessionResponse {}
// Reset() allows misbehaving or slow sessions to be aborted and closed, and
// causes their resources eventually to be released. Reset() does not wait
// for the computations in old sessions to cease; it merely starts the
// process of tearing them down. However, if a new session is started after
// a Reset(), the new session is isolated from changes that old sessions
// (started prior to the Reset()) may continue to make to resources, provided
// all those resources are in containers listed in "containers".
//
// Old sessions may continue to have side-effects on resources not in
// containers listed in "containers", and thus may affect future
// sessions' results in ways that are hard to predict. Thus, if well-defined
// behavior is desired, is it recommended that all containers be listed in
// "containers". Similarly, if a device_filter is specified, results may be
// hard to predict.
message ResetRequest {
// A list of container names, which may be empty.
//
// If 'container' is not empty, releases resources in the given
// containers in all devices.
//
// If 'container' is empty, releases resources in the default
// container in all devices.
repeated string container = 1;
// When any filters are present, only devices that match the filters
// will be reset. Each filter can be partially specified,
// e.g. "/job:ps" "/job:worker/replica:3", etc.
repeated string device_filters = 2;
}
message ResetResponse {}
////////////////////////////////////////////////////////////////////////////////
//
// ListDevices method request/response protos.
//
// Returns information about the TensorFlow devices that are available
// to this master.
//
////////////////////////////////////////////////////////////////////////////////
message ListDevicesRequest {
// Optional: session_handle must be returned by a CreateSession call to the
// same master service.
//
// When session_handle is empty, the ClusterSpec provided when the master was
// started is used to compute the available devices. If the session_handle is
// provided but not recognized, an error is returned. Finally, if a valid
// session_handle is provided, the cluster configuration for that session is
// used when computing the response.
string session_handle = 1;
}
message ListDevicesResponse {
repeated DeviceAttributes local_device = 1;
repeated DeviceAttributes remote_device = 2;
}
////////////////////////////////////////////////////////////////////////////////
//
// MakeCallable method request/response protos.
//
////////////////////////////////////////////////////////////////////////////////
message MakeCallableRequest {
// REQUIRED: session_handle must be returned by a CreateSession call
// to the same master service.
string session_handle = 1;
// Options that define the behavior of the created callable.
CallableOptions options = 2;
// Unique identifier for this request. Every MakeCallableRequest must
// have a unique request_id, and retried MakeCallableRequest must have
// the same request_id. If request_id is zero, retry detection is disabled.
int64 request_id = 3;
}
message MakeCallableResponse {
// A handle to the created callable.
int64 handle = 1;
}
////////////////////////////////////////////////////////////////////////////////
//
// RunCallable method request/response protos.
//
////////////////////////////////////////////////////////////////////////////////
message RunCallableRequest {
// REQUIRED: session_handle must be returned by a CreateSession call
// to the same master service.
string session_handle = 1;
// REQUIRED: handle must be returned by a MakeCallable call to the same
// master service.
int64 handle = 2;
// Values of the tensors passed as arguments to the callable, in the order
// defined in the CallableOptions.feed field passed to MakeCallable.
repeated TensorProto feed = 3;
// Unique identifier for this request. Every RunCallableRequest must
// have a unique request_id, and retried RunCallableRequest must have
// the same request_id. If request_id is zero, retry detection is disabled.
int64 request_id = 4;
}
message RunCallableResponse {
// Values of the tensors returned by the callable, in the order defined in the
// CallableOptions.fetch field passed to MakeCallable.
repeated TensorProto fetch = 1;
// Returned metadata if requested in the options.
RunMetadata metadata = 2;
}
////////////////////////////////////////////////////////////////////////////////
//
// ReleaseCallable method request/response protos.
//
////////////////////////////////////////////////////////////////////////////////
message ReleaseCallableRequest {
// REQUIRED: session_handle must be returned by a CreateSession call
// to the same master service.
string session_handle = 1;
// REQUIRED: handle must be returned by a MakeCallable call to the same
// master service.
int64 handle = 2;
}
message ReleaseCallableResponse {}

View File

@ -1,121 +0,0 @@
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
syntax = "proto3";
package tensorflow.grpc;
import "tensorflow/core/protobuf/master.proto";
option java_outer_classname = "MasterServiceProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.distruntime";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
////////////////////////////////////////////////////////////////////////////////
//
// MasterService defines a TensorFlow service with which a client can
// interact to execute a distributed TensorFlow computation.
//
// A master service keeps track of multiple "master sessions". Each
// session encapsulates a computation graph and its associated state,
// and typically corresponds to a single "client session" (e.g. a
// `tensorflow::Session` instance).
//
// A session is responsible for the following:
// * assigning each node to a device (locally or remotely) using a
// placement algorithm. This may make decisions based on collected
// statistics from the workers in the system (e.g., memory usage,
// bandwidth consumption, etc.)
//
// * inserting intermediate nodes and edges to support cross-device
// and cross-process data flows and resource management.
//
// * issuing commands to workers to execute the subgraphs associated
// with those workers.
//
// Typically, a client carries out an iterative computation
// (e.g. training) by invoking RPCs against the master in a
// client-side loop. The client first creates a client session that
// connects to a particular master (using gRPC for example). The
// master creates a corresponding master session that is hosted on
// the master and caches state between the client's invocations.
//
// After the session is established, the master returns an opaque
// handle to the client that can be used to associate the client and
// master sessions.
//
// The client may send an initial graph to the master in the
// CreateSession call, and add nodes to the graph using ExtendSession.
//
// The most frequent operation a master is "RunStep", which implements
// the `Session::Run()` API. It supports feeding in arguments,
// executing a dataflow computation, and fetching arguments.
//
// Finally, when the client no longer needs the session, it should
// close the session by invoking CloseSession, which allows the master
// to reclaim resources associated with the session. The master may
// implement a garbage collection scheme that closes sessions that
// have been inactive for some time.
//
// For example, the following pseudo-code illustrates how a client
// interacts with a master:
//
// stub = NewStub("/job:mnist/replica:0/task:0")
// {handle} = stub->CreateSession({graph_def})
// do {
// stub->RunStep({handle, {feeds}, {fetches}})
// // The client can evaluate a predicate locally, based on the
// // result of `fetches`, to determine whether to terminate. For
// // example, it might fetch the loss and evaluate whether it is less
// // than some threshold.
// } while (!should_stop({fetches}));
// stub->CloseSession({handle})
//
////////////////////////////////////////////////////////////////////////////////
service MasterService {
// Creates a session.
rpc CreateSession(CreateSessionRequest) returns (CreateSessionResponse);
// Extends a session.
rpc ExtendSession(ExtendSessionRequest) returns (ExtendSessionResponse);
// Prepares future partial run calls.
rpc PartialRunSetup(PartialRunSetupRequest) returns (PartialRunSetupResponse);
// Drives the graph computation.
rpc RunStep(RunStepRequest) returns (RunStepResponse);
// Closes a session.
rpc CloseSession(CloseSessionRequest) returns (CloseSessionResponse);
// List the devices usable by the master.
rpc ListDevices(ListDevicesRequest) returns (ListDevicesResponse);
// Close and abandon all existing sessions. Ongoing computations
// will no longer affect fresh ones via the resources in containers listed in
// the ResetRequest. See ResetRequest for more details.
rpc Reset(ResetRequest) returns (ResetResponse);
// Registers a callable for execution with RunCallable.
rpc MakeCallable(MakeCallableRequest) returns (MakeCallableResponse);
// Executes a callable registered with MakeCallable.
rpc RunCallable(RunCallableRequest) returns (RunCallableResponse);
// Frees resources associated with a callable registered with MakeCallable.
rpc ReleaseCallable(ReleaseCallableRequest) returns (ReleaseCallableResponse);
}

View File

@ -1,342 +0,0 @@
syntax = "proto3";
package tensorflow;
import "google/protobuf/any.proto";
import "tensorflow/core/framework/graph.proto";
import "tensorflow/core/framework/op_def.proto";
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/types.proto";
import "tensorflow/core/protobuf/saved_object_graph.proto";
import "tensorflow/core/protobuf/saver.proto";
import "tensorflow/core/protobuf/struct.proto";
option cc_enable_arenas = true;
option java_outer_classname = "MetaGraphProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// NOTE: This protocol buffer is evolving, and will go through revisions in the
// coming months.
//
// Protocol buffer containing the following which are necessary to restart
// training, run inference. It can be used to serialize/de-serialize memory
// objects necessary for running computation in a graph when crossing the
// process boundary. It can be used for long term storage of graphs,
// cross-language execution of graphs, etc.
// MetaInfoDef
// GraphDef
// SaverDef
// CollectionDef
// TensorInfo
// SignatureDef
message MetaGraphDef {
// Meta information regarding the graph to be exported. To be used by users
// of this protocol buffer to encode information regarding their meta graph.
message MetaInfoDef {
// User specified Version string. Can be the name of the model and revision,
// steps this model has been trained to, etc.
string meta_graph_version = 1;
// A copy of the OpDefs used by the producer of this graph_def.
// Descriptions and Ops not used in graph_def are stripped out.
OpList stripped_op_list = 2;
// A serialized protobuf. Can be the time this meta graph is created, or
// modified, or name of the model.
google.protobuf.Any any_info = 3;
// User supplied tag(s) on the meta_graph and included graph_def.
//
// MetaGraphDefs should be tagged with their capabilities or use-cases.
// Examples: "train", "serve", "gpu", "tpu", etc.
// These tags enable loaders to access the MetaGraph(s) appropriate for a
// specific use-case or runtime environment.
repeated string tags = 4;
// The __version__ string of the tensorflow build used to write this graph.
// This will be populated by the framework, which will overwrite any user
// supplied value.
string tensorflow_version = 5;
// The __git_version__ string of the tensorflow build used to write this
// graph. This will be populated by the framework, which will overwrite any
// user supplied value.
string tensorflow_git_version = 6;
// A flag to denote whether default-valued attrs have been stripped from
// the nodes in this graph_def.
bool stripped_default_attrs = 7;
// FunctionDef name to aliases mapping.
map<string, string> function_aliases = 8;
}
MetaInfoDef meta_info_def = 1;
// GraphDef.
GraphDef graph_def = 2;
// SaverDef.
SaverDef saver_def = 3;
// collection_def: Map from collection name to collections.
// See CollectionDef section for details.
map<string, CollectionDef> collection_def = 4;
// signature_def: Map from user supplied key for a signature to a single
// SignatureDef.
map<string, SignatureDef> signature_def = 5;
// Asset file def to be used with the defined graph.
repeated AssetFileDef asset_file_def = 6;
// Extra information about the structure of functions and stateful objects.
SavedObjectGraph object_graph_def = 7;
}
// CollectionDef should cover most collections.
// To add a user-defined collection, do one of the following:
// 1. For simple data types, such as string, int, float:
// tf.add_to_collection("your_collection_name", your_simple_value)
// strings will be stored as bytes_list.
//
// 2. For Protobuf types, there are three ways to add them:
// 1) tf.add_to_collection("your_collection_name",
// your_proto.SerializeToString())
//
// collection_def {
// key: "user_defined_bytes_collection"
// value {
// bytes_list {
// value: "queue_name: \"test_queue\"\n"
// }
// }
// }
//
// or
//
// 2) tf.add_to_collection("your_collection_name", str(your_proto))
//
// collection_def {
// key: "user_defined_string_collection"
// value {
// bytes_list {
// value: "\n\ntest_queue"
// }
// }
// }
//
// or
//
// 3) any_buf = any_pb2.Any()
// tf.add_to_collection("your_collection_name",
// any_buf.Pack(your_proto))
//
// collection_def {
// key: "user_defined_any_collection"
// value {
// any_list {
// value {
// type_url: "type.googleapis.com/tensorflow.QueueRunnerDef"
// value: "\n\ntest_queue"
// }
// }
// }
// }
//
// 3. For Python objects, implement to_proto() and from_proto(), and register
// them in the following manner:
// ops.register_proto_function("your_collection_name",
// proto_type,
// to_proto=YourPythonObject.to_proto,
// from_proto=YourPythonObject.from_proto)
// These functions will be invoked to serialize and de-serialize the
// collection. For example,
// ops.register_proto_function(ops.GraphKeys.GLOBAL_VARIABLES,
// proto_type=variable_pb2.VariableDef,
// to_proto=Variable.to_proto,
// from_proto=Variable.from_proto)
message CollectionDef {
// NodeList is used for collecting nodes in graph. For example
// collection_def {
// key: "summaries"
// value {
// node_list {
// value: "input_producer/ScalarSummary:0"
// value: "shuffle_batch/ScalarSummary:0"
// value: "ImageSummary:0"
// }
// }
message NodeList {
repeated string value = 1;
}
// BytesList is used for collecting strings and serialized protobufs. For
// example:
// collection_def {
// key: "trainable_variables"
// value {
// bytes_list {
// value: "\n\017conv1/weights:0\022\024conv1/weights/Assign
// \032\024conv1/weights/read:0"
// value: "\n\016conv1/biases:0\022\023conv1/biases/Assign\032
// \023conv1/biases/read:0"
// }
// }
// }
message BytesList {
repeated bytes value = 1;
}
// Int64List is used for collecting int, int64 and long values.
message Int64List {
repeated int64 value = 1 [packed = true];
}
// FloatList is used for collecting float values.
message FloatList {
repeated float value = 1 [packed = true];
}
// AnyList is used for collecting Any protos.
message AnyList {
repeated google.protobuf.Any value = 1;
}
oneof kind {
NodeList node_list = 1;
BytesList bytes_list = 2;
Int64List int64_list = 3;
FloatList float_list = 4;
AnyList any_list = 5;
}
}
// Information about a Tensor necessary for feeding or retrieval.
message TensorInfo {
// For sparse tensors, The COO encoding stores a triple of values, indices,
// and shape.
message CooSparse {
// The shape of the values Tensor is [?]. Its dtype must be the dtype of
// the SparseTensor as a whole, given in the enclosing TensorInfo.
string values_tensor_name = 1;
// The indices Tensor must have dtype int64 and shape [?, ?].
string indices_tensor_name = 2;
// The dynamic logical shape represented by the SparseTensor is recorded in
// the Tensor referenced here. It must have dtype int64 and shape [?].
string dense_shape_tensor_name = 3;
}
// Generic encoding for composite tensors.
message CompositeTensor {
// The serialized TypeSpec for the composite tensor.
TypeSpecProto type_spec = 1;
// A TensorInfo for each flattened component tensor.
repeated TensorInfo components = 2;
}
oneof encoding {
// For dense `Tensor`s, the name of the tensor in the graph.
string name = 1;
// There are many possible encodings of sparse matrices
// (https://en.wikipedia.org/wiki/Sparse_matrix). Currently, TensorFlow
// uses only the COO encoding. This is supported and documented in the
// SparseTensor Python class.
CooSparse coo_sparse = 4;
// Generic encoding for CompositeTensors.
CompositeTensor composite_tensor = 5;
}
DataType dtype = 2;
// The static shape should be recorded here, to the extent that it can
// be known in advance. In the case of a SparseTensor, this field describes
// the logical shape of the represented tensor (aka dense_shape).
TensorShapeProto tensor_shape = 3;
}
// SignatureDef defines the signature of a computation supported by a TensorFlow
// graph.
//
// For example, a model with two loss computations, sharing a single input,
// might have the following signature_def map, in a MetaGraphDef message.
//
// Note that across the two SignatureDefs "loss_A" and "loss_B", the input key,
// output key, and method_name are identical, and will be used by system(s) that
// implement or rely upon this particular loss method. The output tensor names
// differ, demonstrating how different outputs can exist for the same method.
//
// signature_def {
// key: "loss_A"
// value {
// inputs {
// key: "input"
// value {
// name: "input:0"
// dtype: DT_STRING
// tensor_shape: ...
// }
// }
// outputs {
// key: "loss_output"
// value {
// name: "loss_output_A:0"
// dtype: DT_FLOAT
// tensor_shape: ...
// }
// }
// method_name: "some/package/compute_loss"
// }
// ...
// }
// signature_def {
// key: "loss_B"
// value {
// inputs {
// key: "input"
// value {
// name: "input:0"
// dtype: DT_STRING
// tensor_shape: ...
// }
// }
// outputs {
// key: "loss_output"
// value {
// name: "loss_output_B:0"
// dtype: DT_FLOAT
// tensor_shape: ...
// }
// }
// method_name: "some/package/compute_loss"
// }
// ...
// }
message SignatureDef {
// Named input parameters.
map<string, TensorInfo> inputs = 1;
// Named output parameters.
map<string, TensorInfo> outputs = 2;
// Extensible method_name information enabling third-party users to mark a
// SignatureDef as supporting a particular method. This enables producers and
// consumers of SignatureDefs, e.g. a model definition library and a serving
// library to have a clear hand-off regarding the semantics of a computation.
//
// Note that multiple SignatureDefs in a single MetaGraphDef may have the same
// method_name. This is commonly used to support multi-headed computation,
// where a single graph computation may return multiple results.
string method_name = 3;
}
// An asset file def for a single file or a set of sharded files with the same
// name.
message AssetFileDef {
// The tensor to bind the asset filename to.
TensorInfo tensor_info = 1;
// The filename within an assets directory. Note: does not include the path
// prefix, i.e. directories. For an asset at /tmp/path/vocab.txt, the filename
// would be "vocab.txt".
string filename = 2;
}

View File

@ -1,25 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/tensor.proto";
option cc_enable_arenas = true;
option java_outer_classname = "NamedTensorProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// A pair of tensor name and tensor values.
message NamedTensorProto {
// Name of the tensor.
string name = 1;
// The client can populate a TensorProto using a tensorflow::Tensor`, or
// directly using the protobuf field accessors.
//
// The client specifies whether the returned tensor values should be
// filled tensor fields (float_val, int_val, etc.) or encoded in a
// compact form in tensor.tensor_content.
TensorProto tensor = 2;
}

View File

@ -1,30 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/protobuf/error_codes.proto";
option cc_enable_arenas = true;
option java_outer_classname = "QueueRunnerProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Protocol buffer representing a QueueRunner.
message QueueRunnerDef {
// Queue name.
string queue_name = 1;
// A list of enqueue operations.
repeated string enqueue_op_name = 2;
// The operation to run to close the queue.
string close_op_name = 3;
// The operation to run to cancel the queue.
string cancel_op_name = 4;
// A list of exception types considered to signal a safely closed queue
// if raised during enqueue operations.
repeated error.Code queue_closed_exception_types = 5;
}

View File

@ -1,34 +0,0 @@
syntax = "proto3";
package tensorflow.eager;
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/types.proto";
option cc_enable_arenas = true;
option java_outer_classname = "RemoteTensorHandleProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
message ResourceDtypeAndShape {
DataType dtype = 1;
TensorShapeProto shape = 2;
}
message RemoteTensorHandle {
// The ID of the operation that produced this tensor.
int64 op_id = 1;
// The index into the outputs of the operation that produced this tensor.
int32 output_num = 2;
// Device where the tensor is located. Cannot be empty.
// For multi-device functions, it's the default device passed to placer.
string device = 3;
// Device of the operation producing this tensor. Can be empty if the
// operation producing this tensor is a multi-device function.
string op_device = 4;
// Tensor type.
DataType dtype = 5;
// Optional data types and shapes of a remote resource variable.
repeated ResourceDtypeAndShape resource_dtypes_and_shapes = 6;
}

View File

@ -1,47 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/protobuf/master.proto";
option cc_enable_arenas = true;
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Records the creation of a new replay session. We record the device listing
// here to capture the state of the cluster.
message NewReplaySession {
ListDevicesResponse devices = 1;
string session_handle = 2;
}
message ReplayOp {
double start_time_us = 31;
double end_time_us = 32;
oneof op {
CreateSessionRequest create_session = 1;
ExtendSessionRequest extend_session = 2;
PartialRunSetupRequest partial_run_setup = 3;
RunStepRequest run_step = 4;
CloseSessionRequest close_session = 5;
ListDevicesRequest list_devices = 6;
ResetRequest reset_request = 7;
MakeCallableRequest make_callable = 8;
RunCallableRequest run_callable = 9;
ReleaseCallableRequest release_callable = 10;
NewReplaySession new_replay_session = 11;
}
oneof response {
CreateSessionResponse create_session_response = 21;
ExtendSessionResponse extend_session_response = 22;
PartialRunSetupResponse partial_run_setup_response = 23;
RunStepResponse run_step_response = 24;
CloseSessionResponse close_session_response = 25;
ListDevicesResponse list_devices_response = 26;
ResetResponse reset_request_response = 27;
MakeCallableResponse make_callable_response = 28;
RunCallableResponse run_callable_response = 29;
ReleaseCallableResponse release_callable_response = 30;
}
}

View File

@ -1,223 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/attr_value.proto";
import "tensorflow/core/protobuf/verifier_config.proto";
option cc_enable_arenas = true;
option java_outer_classname = "RewriterConfigProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
message AutoParallelOptions {
bool enable = 1;
int32 num_replicas = 2;
}
message ScopedAllocatorOptions {
// If present, only perform optimization for these ops.
repeated string enable_op = 1;
}
message RewriterConfig {
// Graph rewriting is experimental and subject to change, not covered by any
// API stability guarantees.
// Configuration options for the meta-optimizer. Unless otherwise noted, these
// configuration options do not apply to explicitly triggered optimization
// passes in the optimizers field.
enum Toggle {
DEFAULT = 0;
ON = 1;
OFF = 2;
// Enable some aggressive optimizations that use assumptions that TF graphs
// may break. For example, assume the shape of a placeholder matches its
// actual feed.
AGGRESSIVE = 3;
}
// Enum for layout conversion between NCHW and NHWC on CPU. Default is OFF.
enum CpuLayout {
NO_CONVERSION_ON_CPU = 0;
NCHW_TO_NHWC = 1;
NHWC_TO_NCHW = 2;
}
// Enum controlling the number of times to run optimizers. The default is to
// run them twice.
enum NumIterationsType {
DEFAULT_NUM_ITERS = 0;
ONE = 1;
TWO = 2;
}
// CPU Conversion settings between NHCW and NCHW.
CpuLayout cpu_layout_conversion = 50;
// Optimize tensor layouts (default is ON)
// e.g. This will try to use NCHW layout on GPU which is faster.
Toggle layout_optimizer = 1;
// Fold constants (default is ON)
// Statically infer the value of tensors when possible, and materialize the
// result using constants.
Toggle constant_folding = 3;
// Shape optimizations (default is ON)
// Simplify computations made on shapes.
Toggle shape_optimization = 13;
// Remapping (default is ON)
// Remap subgraphs onto more efficient implementations.
Toggle remapping = 14;
// Common subgraph elimination (default is ON)
// e.g. Simplify arithmetic ops; merge ops with same value (like constants).
Toggle common_subgraph_elimination = 24;
// Arithmetic optimizations (default is ON)
// e.g. Simplify arithmetic ops; merge ops with same value (like constants).
Toggle arithmetic_optimization = 7;
// Control dependency optimizations (default is ON).
// Remove redundant control dependencies, which may enable other optimization.
Toggle dependency_optimization = 8;
// Loop optimizations (default is ON).
Toggle loop_optimization = 9;
// Function optimizations (default is ON).
Toggle function_optimization = 10;
// Strips debug-related nodes from the graph (off by default).
Toggle debug_stripper = 11;
// If true, don't remove unnecessary ops from the graph
bool disable_model_pruning = 2;
// Try to allocate some independent Op outputs contiguously in order to
// merge or eliminate downstream Ops (off by default).
Toggle scoped_allocator_optimization = 15;
// Force small ops onto the CPU (default is OFF).
Toggle pin_to_host_optimization = 18;
// Enable the swap of kernel implementations based on the device placement
// (default is ON).
Toggle implementation_selector = 22;
// Optimize data types for CUDA (default is OFF).
// This will try to use float16 on GPU which is faster.
// Note that this can change the numerical stability of the graph and may
// require the use of loss scaling to maintain model convergence.
Toggle auto_mixed_precision = 23;
// Optimize data types for MKL (default is OFF).
// This will try to use bfloat16 on CPUs, which is faster.
// Note that this can change the numerical stability of the graph.
Toggle auto_mixed_precision_mkl = 25;
// Emulate a model using data type float16 on CPU (default is OFF).
// This will try to emulate the float16 inputs and outputs of an operator
// on CPU to have better correlation with float16 on GPU; however the
// computation in the operator is based on float32.
// Note that this can change the numerical stability of the graph.
Toggle auto_mixed_precision_cpu = 29;
// Disable the entire meta optimizer (off by default).
bool disable_meta_optimizer = 19;
// Optimizers registered by plugin (default is ON)
Toggle use_plugin_optimizers = 28;
// Controls how many times we run the optimizers in meta optimizer (default
// is once).
NumIterationsType meta_optimizer_iterations = 12;
// The minimum number of nodes in a graph to optimizer. For smaller graphs,
// optimization is skipped.
// 0 means the system picks an appropriate number.
// < 0 means do not skip optimization.
int32 min_graph_nodes = 17;
// Disable optimizations that assume compressed tensors. Note that this flag
// is experimental and may be removed in the future.
bool experimental_disable_compressed_tensor_optimization = 26;
// Disable folding quantization emulation ops such as FakeQuantWithMinMax* and
// QuantizeAndDequantize*. Some compilers (e.g. the TF-to-tflite converter)
// have to extract quantization configs (e.g. min/max range, number of bits,
// and per-channel) from the quantization emulation ops. Note that this flag
// is experimental and may be removed in the future. See b/174138564 for more
// details.
bool experimental_disable_folding_quantization_emulation = 27;
enum MemOptType {
// The default setting (SCHEDULING and SWAPPING HEURISTICS only)
DEFAULT_MEM_OPT = 0;
// Disabled in the meta-optimizer.
NO_MEM_OPT = 1;
// Driven by manual op-level annotations.
MANUAL = 2;
// Driven by heuristics. The behavior of these heuristics is subject to
// change. Currently includes an experimental recomputation and swapping
// heuristics. Manual annotations are respected, but additional nodes are
// selected automatically.
// Swapping heuristic will move a tensor from the GPU to the CPU and move
// it back when needed to reduce peak memory usage.
SWAPPING_HEURISTICS = 4;
// Recomputation heuristics will recompute ops (such as Relu activation)
// during backprop instead of storing them, reducing peak memory usage.
RECOMPUTATION_HEURISTICS = 5;
// Scheduling will split big ops such as AddN and try to enforce a schedule
// of the new computations that decreases peak memory usage.
SCHEDULING_HEURISTICS = 6;
// Use any combination of swapping and recomputation heuristics.
HEURISTICS = 3;
}
// Configures memory optimization passes through the meta-optimizer. Has no
// effect on manually requested memory optimization passes in the optimizers
// field.
MemOptType memory_optimization = 4;
// A node name scope for node names which are valid outputs of recomputations.
// Inputs to nodes that match this scope may be recomputed (subject either to
// manual annotation of those input nodes or to manual annotation and
// heuristics depending on memory_optimization), but the nodes themselves will
// not be recomputed. This matches any sub-scopes as well, meaning the scope
// can appear not just as a top-level scope. For example, if the value is
// "gradients/", the default, it will match node name "gradients/foo",
// "foo/gradients/bar", but not "foo_gradients/"
string memory_optimizer_target_node_name_scope = 6;
// Maximum number of milliseconds to spend optimizing a single graph before
// timing out. If less than or equal to 0 (default value) the optimizer will
// never time out.
int64 meta_optimizer_timeout_ms = 20;
// Configures AutoParallel optimization passes either through the
// meta-optimizer or when manually specified through the optimizers field.
AutoParallelOptions auto_parallel = 5;
// If true, any optimization pass failing will cause the MetaOptimizer to
// stop with an error. By default - or when set to false, failing passes are
// skipped silently.
bool fail_on_optimizer_errors = 21;
ScopedAllocatorOptions scoped_allocator_opts = 16;
// If non-empty, will use this as an alternative way to specify a list of
// optimizations to turn on and the order of the optimizations (replacing the
// meta-optimizer).
//
// Of the RewriterConfig options, only the AutoParallel configuration options
// (the auto_parallel field) apply to manually requested optimization passes
// ("autoparallel"). Memory optimization passes ("memory") invoked here are
// not configurable (in contrast to memory optimization passes through the
// meta-optimizer) and act only on manual op annotations.
//
// Custom optimizers (see custom_optimizers) that are not part of this
// schedule will be run after - in the order that they were specified.
repeated string optimizers = 100;
// Message to describe custom graph optimizer and its parameters
message CustomGraphOptimizer {
string name = 1;
map<string, AttrValue> parameter_map = 2;
}
// list of CustomGraphOptimizers to apply.
repeated CustomGraphOptimizer custom_optimizers = 200;
// VerifierConfig specifying the verifiers to be run after every optimizer.
VerifierConfig inter_optimizer_verifier_config = 300;
// VerifierConfig specifying the verifiers to be run at the end, after all
// optimizers have run.
VerifierConfig post_optimization_verifier_config = 301;
}

View File

@ -1,23 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/protobuf/meta_graph.proto";
option cc_enable_arenas = true;
option java_outer_classname = "SavedModelProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// SavedModel is the high level serialization format for TensorFlow Models.
// See [todo: doc links, similar to session_bundle] for more information.
message SavedModel {
// The schema version of the SavedModel instance. Used for versioning when
// making future changes to the specification/implementation. Initial value
// at release will be 1.
int64 saved_model_schema_version = 1;
// One or more MetaGraphs.
repeated MetaGraphDef meta_graphs = 2;
}

View File

@ -1,251 +0,0 @@
syntax = "proto3";
package tensorflow;
import "google/protobuf/any.proto";
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/types.proto";
import "tensorflow/core/framework/variable.proto";
import "tensorflow/core/framework/versions.proto";
import "tensorflow/core/protobuf/struct.proto";
import "tensorflow/core/protobuf/trackable_object_graph.proto";
option cc_enable_arenas = true;
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// A SavedObjectGraph is part of object-based SavedModels in TF 2.0. It
// describes the directed graph of Python objects (or equivalent in other
// languages) that make up a model, with nodes[0] at the root.
// SavedObjectGraph shares some structure with TrackableObjectGraph, but
// SavedObjectGraph belongs to the MetaGraph and contains pointers to functions
// and type information, while TrackableObjectGraph lives in the checkpoint
// and contains pointers only to variable values.
message SavedObjectGraph {
// Flattened list of objects in the object graph.
//
// The position of the object in this list indicates its id.
// Nodes[0] is considered the root node.
repeated SavedObject nodes = 1;
// Information about captures and output structures in concrete functions.
// Referenced from SavedBareConcreteFunction and SavedFunction.
map<string, SavedConcreteFunction> concrete_functions = 2;
}
message SavedObject {
// Objects which this object depends on: named edges in the dependency
// graph.
//
// Note: All kinds of SavedObject may have children, except
// "constant" and "captured_tensor".
repeated TrackableObjectGraph.TrackableObject.ObjectReference children = 1;
// Ordered list of dependencies that must be loaded before this object.
// SavedModel loads with the bottom-up approach, by first creating all objects
// (in the order defined by the dependencies), then connecting the edges.
repeated TrackableObjectGraph.TrackableObject.ObjectReference dependencies =
15;
// Removed when forking SavedObject from TrackableObjectGraph.
reserved "attributes";
reserved 2;
// Slot variables owned by this object. This describes the three-way
// (optimizer, variable, slot variable) relationship; none of the three
// depend on the others directly.
//
// Note: currently only valid if kind == "user_object".
repeated TrackableObjectGraph.TrackableObject.SlotVariableReference
slot_variables = 3;
oneof kind {
SavedUserObject user_object = 4;
SavedAsset asset = 5;
SavedFunction function = 6;
SavedVariable variable = 7;
SavedBareConcreteFunction bare_concrete_function = 8;
SavedConstant constant = 9;
SavedResource resource = 10;
CapturedTensor captured_tensor = 12;
}
// Stores the functions used to save and restore this object. At most one of
// `saveable_objects` or `registered_saver` is defined for each SavedObject.
// See the comment below for the difference between SaveableObject and
// registered savers.
map<string, SaveableObject> saveable_objects = 11;
// The fields below are filled when the user serializes a registered Trackable
// class or an object with a registered saver function.
//
// Registered classes may save additional metadata and supersede the
// default loading process where nodes are recreated from the proto.
// If the registered class cannot be found, then the object will load as one
// one of the default trackable objects: Autotrackable (a class similar to
// tf.Module), tf.function, or tf.Variable.
//
// Unlike SaveableObjects, which store the functions for saving and restoring
// from tensors, registered savers allow Trackables to write checkpoint shards
// directly (e.g. for performance or coordination reasons).
// *All registered savers must be available when loading the SavedModel.*
// The name of the registered class of the form "{package}.{class_name}".
// This field is used to search for the registered class at loading time.
string registered_name = 13;
// The user-generated proto storing metadata for this object, to be passed to
// the registered classes's _deserialize_from_proto method when this object is
// loaded from the SavedModel.
google.protobuf.Any serialized_user_proto = 14;
// String name of the registered saver. At most one of `saveable_objects` or
// `registered_saver` is defined for each SavedObject.
string registered_saver = 16;
}
// A SavedUserObject is an object (in the object-oriented language of the
// TensorFlow program) of some user- or framework-defined class other than
// those handled specifically by the other kinds of SavedObjects.
//
// This object cannot be evaluated as a tensor, and therefore cannot be bound
// to an input of a function.
message SavedUserObject {
// Corresponds to a registration of the type to use in the loading program.
string identifier = 1;
// Version information from the producer of this SavedUserObject.
VersionDef version = 2;
// Metadata for deserializing this object.
//
// Deprecated! At the time of deprecation, Keras was the only user of this
// field, and its saving and loading code will be updated shortly.
// Please save your application-specific metadata to a separate file.
string metadata = 3 [deprecated = true];
}
// A SavedAsset points to an asset in the MetaGraph.
//
// When bound to a function this object evaluates to a tensor with the absolute
// filename. Users should not depend on a particular part of the filename to
// remain stable (e.g. basename could be changed).
message SavedAsset {
// Index into `MetaGraphDef.asset_file_def[]` that describes the Asset.
//
// Only the field `AssetFileDef.filename` is used. Other fields, such as
// `AssetFileDef.tensor_info`, MUST be ignored.
int32 asset_file_def_index = 1;
}
// A function with multiple signatures, possibly with non-Tensor arguments.
message SavedFunction {
repeated string concrete_functions = 1;
FunctionSpec function_spec = 2;
}
message CapturedTensor {
// Name of captured tensor
string name = 1;
// Name of concrete function which contains the computed graph tensor.
string concrete_function = 2;
}
// Stores low-level information about a concrete function. Referenced in either
// a SavedFunction or a SavedBareConcreteFunction.
message SavedConcreteFunction {
repeated int32 bound_inputs = 2;
// Input in canonicalized form that was received to create this concrete
// function.
StructuredValue canonicalized_input_signature = 3;
// Output that was the return value of this function after replacing all
// Tensors with TensorSpecs. This can be an arbitrary nested function and will
// be used to reconstruct the full structure from pure tensors.
StructuredValue output_signature = 4;
}
message SavedBareConcreteFunction {
// Identifies a SavedConcreteFunction.
string concrete_function_name = 1;
// A sequence of unique strings, one per Tensor argument.
repeated string argument_keywords = 2;
// The prefix of `argument_keywords` which may be identified by position.
int64 allowed_positional_arguments = 3;
// The spec of the function that this ConcreteFunction is traced from. This
// allows the ConcreteFunction to be called with nest structure inputs. This
// field may not be populated. If this field is absent, the concrete function
// can only be called with flat inputs.
// TODO(b/169361281): support calling saved ConcreteFunction with structured
// inputs in C++ SavedModel API.
FunctionSpec function_spec = 4;
}
message SavedConstant {
// An Operation name for a ConstantOp in this SavedObjectGraph's MetaGraph.
string operation = 1;
}
// Represents a Variable that is initialized by loading the contents from the
// checkpoint.
message SavedVariable {
DataType dtype = 1;
TensorShapeProto shape = 2;
bool trainable = 3;
VariableSynchronization synchronization = 4;
VariableAggregation aggregation = 5;
string name = 6;
string device = 7;
// List of component variables for a distributed variable.
//
// When this field is non-empty, the SavedVariable will be assumed
// to be a distributed variable defined by the components listed here.
//
// This is only supported by experimental loaders at the moment.
repeated SavedVariable experimental_distributed_variable_components = 8;
}
// Represents `FunctionSpec` used in `Function`. This represents a
// function that has been wrapped as a TensorFlow `Function`.
message FunctionSpec {
// Full arg spec from inspect.getfullargspec().
StructuredValue fullargspec = 1;
// Whether this represents a class method.
bool is_method = 2;
// The input signature, if specified.
StructuredValue input_signature = 5;
// Whether the function should be compiled by XLA.
//
// The public interface to `tf.function` uses an optional boolean to
// represent three distinct states for this field. Unfortunately, proto3
// removes the ability to explicitly check for the presence or absence of a
// field, so we instead map to an enum.
//
// See `tf.function` for details.
enum JitCompile {
DEFAULT = 0;
ON = 1;
OFF = 2;
}
JitCompile jit_compile = 6;
reserved 3, 4;
}
// A SavedResource represents a TF object that holds state during its lifetime.
// An object of this type can have a reference to a:
// create_resource() and an initialize() function.
message SavedResource {
// A device specification indicating a required placement for the resource
// creation function, e.g. "CPU". An empty string allows the user to select a
// device.
string device = 1;
}
message SaveableObject {
// Node ids of concrete functions for saving and loading from a checkpoint.
// These functions save and restore directly from tensors.
int32 save_function = 2;
int32 restore_function = 3;
}

View File

@ -1,48 +0,0 @@
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "SaverProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.util";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Protocol buffer representing the configuration of a Saver.
message SaverDef {
// The name of the tensor in which to specify the filename when saving or
// restoring a model checkpoint.
string filename_tensor_name = 1;
// The operation to run when saving a model checkpoint.
string save_tensor_name = 2;
// The operation to run when restoring a model checkpoint.
string restore_op_name = 3;
// Maximum number of checkpoints to keep. If 0, no checkpoints are deleted.
int32 max_to_keep = 4;
// Shard the save files, one per device that has Variable nodes.
bool sharded = 5;
// How often to keep an additional checkpoint. If not specified, only the last
// "max_to_keep" checkpoints are kept; if specified, in addition to keeping
// the last "max_to_keep" checkpoints, an additional checkpoint will be kept
// for every n hours of training.
float keep_checkpoint_every_n_hours = 6;
// A version number that identifies a different on-disk checkpoint format.
// Usually, each subclass of BaseSaverBuilder works with a particular
// version/format. However, it is possible that the same builder may be
// upgraded to support a newer checkpoint format in the future.
enum CheckpointFormatVersion {
// Internal legacy format.
LEGACY = 0;
// Deprecated format: tf.Saver() which works with tensorflow::table::Table.
V1 = 1;
// Current format: more efficient.
V2 = 2;
}
CheckpointFormatVersion version = 7;
}

View File

@ -1,82 +0,0 @@
syntax = "proto3";
package tensorflow.data.experimental;
import "tensorflow/core/protobuf/data_service.proto";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Configuration for a tf.data service DispatchServer.
// Next id: 10
message DispatcherConfig {
// The port for the dispatcher to bind to. A value of 0 indicates that the
// dispatcher may bind to any available port.
int64 port = 1;
// The protocol for the dispatcher to use when connecting to workers.
string protocol = 2;
// A work directory to use for storing dispatcher state, and for recovering
// during restarts. The empty string indicates not to use any work directory.
string work_dir = 3;
// Whether to run in fault tolerant mode, where dispatcher state is saved
// across restarts. Requires that `work_dir` is nonempty.
bool fault_tolerant_mode = 4;
// (Optional.) If the job uses auto-sharding, it needs to specify a fixed list
// of worker addresses that will register with the dispatcher. The worker
// addresses should be in the format "host" or "host:port", where "port" is an
// integer, named port, or %port% to match any port.
repeated string worker_addresses = 7;
// (Optional.) tf.data service deployment mode. Supported values are "REMOTE",
// "COLOCATED", and "HYBRID". If unspecified, it is assumed to be "REMOTE".
DeploymentMode deployment_mode = 9;
// How often the dispatcher should scan through to delete old and unused
// jobs. A value of 0 indicates that the decision should be left up to the
// runtime.
int64 job_gc_check_interval_ms = 5;
// How long a job needs to be unused before it becomes a candidate for garbage
// collection. A value of -1 indicates that jobs should never be garbage
// collected. A value of 0 indicates that the decision should be left up to
// the runtime.
int64 job_gc_timeout_ms = 6;
// How long to wait before garbage-collecting a client that hasn't
// heartbeated to the dispatcher. A value of 0 indicates that the timeout
// should be left to the runtime.
int64 client_timeout_ms = 8;
}
// Configuration for a tf.data service WorkerServer.
// Next id: 11
message WorkerConfig {
// The port for the worker to bind to. A value of 0 indicates that the
// worker may bind to any available port.
int64 port = 1;
// The protocol for the worker to use when connecting to the dispatcher.
string protocol = 2;
// The address of the dispatcher to register with.
string dispatcher_address = 3;
// The address of the worker server. The substring "%port%", if specified,
// will be replaced with the worker's bound port. This is useful when the port
// is set to `0`.
string worker_address = 4;
// Tags attached to the worker. This allows reading from selected workers.
// For example, by applying a "COLOCATED" tag, tf.data service is able to read
// from the local tf.data worker if one exists, then from off-TF-host workers,
// to avoid cross-TF-host reads.
repeated string worker_tags = 10;
// How often the worker should heartbeat to the master. A value of 0 indicates
// that the decision should be left up to the runtime.
int64 heartbeat_interval_ms = 5;
// How long to retry requests to the dispatcher before giving up and reporting
// an error. A value of 0 indicates that the decision should be left up to the
// runtime.
int64 dispatcher_timeout_ms = 6;
// The protocol for the worker to use when transferring data to clients.
string data_transfer_protocol = 7;
// The data transfer address of the worker server. The substring "%port%", if
// specified, will be replaced with the worker's bound port. This is useful
// when the port is set to `0`.
string data_transfer_address = 8;
// When shutting down a worker, how long to wait for the gRPC server to
// process the final requests. This is used to achieve clean shutdown in unit
// tests.
int64 shutdown_quiet_period_ms = 9;
}

View File

@ -1,47 +0,0 @@
syntax = "proto3";
package tensorflow.data.experimental;
import "tensorflow/core/framework/tensor.proto";
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/types.proto";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Each SnapshotRecord represents one batch of pre-processed input data. A batch
// consists of a list of tensors that we encode as TensorProtos. This message
// doesn't store the structure of the batch.
message SnapshotRecord {
repeated .tensorflow.TensorProto tensor = 1;
}
// This stores the metadata information present in each snapshot record.
message SnapshotMetadataRecord {
// Stores the fingerprint of the graph that describes the dataset that is
// snapshotted.
string graph_hash = 1;
// Run ID that this snapshot corresponds to.
string run_id = 2;
// Time when we started creating this snapshot.
int64 creation_timestamp = 3;
// Version of the snapshot data file format.
int64 version = 4;
// A list of tensor dtype corresponding to each element of the snapshot.
repeated .tensorflow.DataType dtype = 5;
// The number of elements in the snapshot.
int64 num_elements = 6;
bool finalized = 1000;
}
// Metadata for a single tensor in the Snapshot Record.
message TensorMetadata {
.tensorflow.TensorShapeProto tensor_shape = 2;
// Number of uncompressed bytes used to store the tensor representation.
int64 tensor_size_bytes = 3;
}
// Metadata for all the tensors in a Snapshot Record.
message SnapshotTensorMetadata {
repeated TensorMetadata tensor_metadata = 1;
}

View File

@ -1,10 +0,0 @@
syntax = "proto3";
package tensorflow;
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// If included as a payload, this message flags the Status to be a "derived"
// Status. Used by StatusGroup to ignore certain Statuses when reporting
// errors to end users.
message DerivedStatus {}

View File

@ -1,160 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/tensor.proto";
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/types.proto";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// `StructuredValue` represents a dynamically typed value representing various
// data structures that are inspired by Python data structures typically used in
// TensorFlow functions as inputs and outputs.
//
// For example when saving a Layer there may be a `training` argument. If the
// user passes a boolean True/False, that switches between two concrete
// TensorFlow functions. In order to switch between them in the same way after
// loading the SavedModel, we need to represent "True" and "False".
//
// A more advanced example might be a function which takes a list of
// dictionaries mapping from strings to Tensors. In order to map from
// user-specified arguments `[{"a": tf.constant(1.)}, {"q": tf.constant(3.)}]`
// after load to the right saved TensorFlow function, we need to represent the
// nested structure and the strings, recording that we have a trace for anything
// matching `[{"a": tf.TensorSpec(None, tf.float32)}, {"q": tf.TensorSpec([],
// tf.float64)}]` as an example.
//
// Likewise functions may return nested structures of Tensors, for example
// returning a dictionary mapping from strings to Tensors. In order for the
// loaded function to return the same structure we need to serialize it.
//
// This is an ergonomic aid for working with loaded SavedModels, not a promise
// to serialize all possible function signatures. For example we do not expect
// to pickle generic Python objects, and ideally we'd stay language-agnostic.
message StructuredValue {
// The kind of value.
oneof kind {
// Represents None.
NoneValue none_value = 1;
// Represents a double-precision floating-point value (a Python `float`).
double float64_value = 11;
// Represents a signed integer value, limited to 64 bits.
// Larger values from Python's arbitrary-precision integers are unsupported.
sint64 int64_value = 12;
// Represents a string of Unicode characters stored in a Python `str`.
// In Python 3, this is exactly what type `str` is.
// In Python 2, this is the UTF-8 encoding of the characters.
// For strings with ASCII characters only (as often used in TensorFlow code)
// there is effectively no difference between the language versions.
// The obsolescent `unicode` type of Python 2 is not supported here.
string string_value = 13;
// Represents a boolean value.
bool bool_value = 14;
// Represents a TensorShape.
tensorflow.TensorShapeProto tensor_shape_value = 31;
// Represents an enum value for dtype.
tensorflow.DataType tensor_dtype_value = 32;
// Represents a value for tf.TensorSpec.
TensorSpecProto tensor_spec_value = 33;
// Represents a value for tf.TypeSpec.
TypeSpecProto type_spec_value = 34;
// Represents a value for tf.BoundedTensorSpec.
BoundedTensorSpecProto bounded_tensor_spec_value = 35;
// Represents a list of `Value`.
ListValue list_value = 51;
// Represents a tuple of `Value`.
TupleValue tuple_value = 52;
// Represents a dict `Value`.
DictValue dict_value = 53;
// Represents Python's namedtuple.
NamedTupleValue named_tuple_value = 54;
}
}
// Represents None.
message NoneValue {}
// Represents a Python list.
message ListValue {
repeated StructuredValue values = 1;
}
// Represents a Python tuple.
message TupleValue {
repeated StructuredValue values = 1;
}
// Represents a Python dict keyed by `str`.
// The comment on Unicode from Value.string_value applies analogously.
message DictValue {
map<string, StructuredValue> fields = 1;
}
// Represents a (key, value) pair.
message PairValue {
string key = 1;
StructuredValue value = 2;
}
// Represents Python's namedtuple.
message NamedTupleValue {
string name = 1;
repeated PairValue values = 2;
}
// A protobuf to represent tf.TensorSpec.
message TensorSpecProto {
string name = 1;
tensorflow.TensorShapeProto shape = 2;
tensorflow.DataType dtype = 3;
}
// A protobuf to represent tf.BoundedTensorSpec.
message BoundedTensorSpecProto {
string name = 1;
tensorflow.TensorShapeProto shape = 2;
tensorflow.DataType dtype = 3;
tensorflow.TensorProto minimum = 4;
tensorflow.TensorProto maximum = 5;
}
// Represents a tf.TypeSpec
message TypeSpecProto {
enum TypeSpecClass {
UNKNOWN = 0;
SPARSE_TENSOR_SPEC = 1; // tf.SparseTensorSpec
INDEXED_SLICES_SPEC = 2; // tf.IndexedSlicesSpec
RAGGED_TENSOR_SPEC = 3; // tf.RaggedTensorSpec
TENSOR_ARRAY_SPEC = 4; // tf.TensorArraySpec
DATA_DATASET_SPEC = 5; // tf.data.DatasetSpec
DATA_ITERATOR_SPEC = 6; // IteratorSpec from data/ops/iterator_ops.py
OPTIONAL_SPEC = 7; // tf.OptionalSpec
PER_REPLICA_SPEC = 8; // PerReplicaSpec from distribute/values.py
VARIABLE_SPEC = 9; // tf.VariableSpec
ROW_PARTITION_SPEC = 10; // RowPartitionSpec from ragged/row_partition.py
reserved 11;
REGISTERED_TYPE_SPEC = 12; // The type registered as type_spec_class_name.
EXTENSION_TYPE_SPEC = 13; // Subclasses of tf.ExtensionType
}
TypeSpecClass type_spec_class = 1;
// The value returned by TypeSpec._serialize().
StructuredValue type_state = 2;
// The name of the TypeSpec class.
// * If type_spec_class == REGISTERED_TYPE_SPEC, the TypeSpec class is
// the one registered under this name. For types registered outside
// core TensorFlow by an add-on library, that library must be loaded
// before this value can be deserialized by nested_structure_coder.
// * If type_spec_class specifies a particular TypeSpec class, this field is
// redundant with the type_spec_class enum, and is only used for error
// reporting in older binaries that do not know the tupe_spec_class enum.
string type_spec_class_name = 3;
// The number of flat tensor components required by this TypeSpec.
int32 num_flat_components = 4;
}

View File

@ -1,66 +0,0 @@
syntax = "proto3";
package tensorflow;
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/tensor_slice.proto";
import "tensorflow/core/framework/types.proto";
import "tensorflow/core/framework/versions.proto";
option cc_enable_arenas = true;
option java_outer_classname = "TensorBundleProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.util";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Protos used in the tensor bundle module (tf/core/util/tensor_bundle/).
// Special header that is associated with a bundle.
//
// TODO(zongheng,zhifengc): maybe in the future, we can add information about
// which binary produced this checkpoint, timestamp, etc. Sometime, these can be
// valuable debugging information. And if needed, these can be used as defensive
// information ensuring reader (binary version) of the checkpoint and the writer
// (binary version) must match within certain range, etc.
message BundleHeaderProto {
// Number of data files in the bundle.
int32 num_shards = 1;
// An enum indicating the endianness of the platform that produced this
// bundle. A bundle can only be read by a platform with matching endianness.
// Defaults to LITTLE, as most modern platforms are little-endian.
//
// Affects the binary tensor data bytes only, not the metadata in protobufs.
enum Endianness {
LITTLE = 0;
BIG = 1;
}
Endianness endianness = 2;
// Versioning of the tensor bundle format.
VersionDef version = 3;
}
// Describes the metadata related to a checkpointed tensor.
message BundleEntryProto {
// The tensor dtype and shape.
DataType dtype = 1;
TensorShapeProto shape = 2;
// The binary content of the tensor lies in:
// File "shard_id": bytes [offset, offset + size).
int32 shard_id = 3;
int64 offset = 4;
int64 size = 5;
// The CRC32C checksum of the tensor bytes.
fixed32 crc32c = 6;
// Iff present, this entry represents a partitioned tensor. The previous
// fields are interpreted as follows:
//
// "dtype", "shape": describe the full tensor.
// "shard_id", "offset", "size", "crc32c": all IGNORED.
// These information for each slice can be looked up in their own
// BundleEntryProto, keyed by each "slice_name".
repeated TensorSliceProto slices = 7;
}

View File

@ -1,61 +0,0 @@
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
syntax = "proto3";
package tensorflow;
import "tensorflow/core/protobuf/cluster.proto";
import "tensorflow/core/protobuf/config.proto";
import "tensorflow/core/protobuf/device_filters.proto";
option cc_enable_arenas = true;
option java_outer_classname = "ServerProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.distruntime";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Defines the configuration of a single TensorFlow server.
message ServerDef {
// The cluster of which this server is a member.
ClusterDef cluster = 1;
// The name of the job of which this server is a member.
//
// NOTE(mrry): The `cluster` field must contain a `JobDef` with a `name` field
// that matches this name.
string job_name = 2;
// The task index of this server in its job.
//
// NOTE: The `cluster` field must contain a `JobDef` with a matching `name`
// and a mapping in its `tasks` field for this index.
int32 task_index = 3;
// The default configuration for sessions that run on this server.
ConfigProto default_session_config = 4;
// The protocol to be used by this server.
//
// Acceptable values include: "grpc", "grpc+verbs".
string protocol = 5;
// The server port. If not set, then we identify the port from the job_name.
int32 port = 6;
// Device filters for remote tasks in the cluster.
// NOTE: This is an experimental feature and only effective in TensorFlow 2.x.
ClusterDeviceFilters cluster_device_filters = 7;
}

View File

@ -1,80 +0,0 @@
syntax = "proto3";
package tensorflow;
import "google/protobuf/wrappers.proto";
option cc_enable_arenas = true;
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// A TensorBundle addition which saves extra information about the objects which
// own variables, allowing for more robust checkpoint loading into modified
// programs.
message TrackableObjectGraph {
message TrackableObject {
message ObjectReference {
// An index into `TrackableObjectGraph.nodes`, indicating the object
// being referenced.
int32 node_id = 1;
// A user-provided name for the edge.
string local_name = 2;
}
message SerializedTensor {
// A name for the Tensor. Simple variables have only one
// `SerializedTensor` named "VARIABLE_VALUE" by convention. This value may
// be restored on object creation as an optimization.
string name = 1;
// The full name of the variable/tensor, if applicable. Used to allow
// name-based loading of checkpoints which were saved using an
// object-based API. Should match the checkpoint key which would have been
// assigned by tf.train.Saver.
string full_name = 2;
// The generated name of the Tensor in the checkpoint.
string checkpoint_key = 3;
// Deprecated bool field for optional restore. This field has never been
// set to True.
reserved "optional_restore";
reserved 4;
}
message SlotVariableReference {
// An index into `TrackableObjectGraph.nodes`, indicating the
// variable object this slot was created for.
int32 original_variable_node_id = 1;
// The name of the slot (e.g. "m"/"v").
string slot_name = 2;
// An index into `TrackableObjectGraph.nodes`, indicating the
// `Object` with the value of the slot variable.
int32 slot_variable_node_id = 3;
}
// Objects which this object depends on.
repeated ObjectReference children = 1;
// Serialized data specific to this object.
repeated SerializedTensor attributes = 2;
// Slot variables owned by this object.
repeated SlotVariableReference slot_variables = 3;
// The registered saver used to save this object. If this saver is not
// present when loading the checkpoint, then loading will fail.
RegisteredSaver registered_saver = 4;
// Whether this object has checkpoint values or descendants with checkpoint
// values. This is computed at save time to avoid traversing the entire
// object graph proto when restoring (which also has to traverse the live
// object graph).
google.protobuf.BoolValue has_checkpoint_values = 5;
}
repeated TrackableObject nodes = 1;
}
message RegisteredSaver {
// The name of the registered saver/restore function.
string name = 1;
// Unique auto-generated name of the object.
string object_name = 2;
}

View File

@ -1,10 +0,0 @@
syntax = "proto3";
package tensorflow;
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// Extra data needed on a non-RDMA RecvBufResponse.
message RecvBufRespExtra {
repeated bytes tensor_content = 1;
}

View File

@ -1,27 +0,0 @@
syntax = "proto3";
package tensorflow;
option cc_enable_arenas = true;
option java_outer_classname = "VerifierConfigProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.framework";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
// The config for graph verifiers.
message VerifierConfig {
enum Toggle {
DEFAULT = 0;
ON = 1;
OFF = 2;
}
// Deadline for completion of all verification i.e. all the Toggle ON
// verifiers must complete execution within this time.
int64 verification_timeout_in_ms = 1;
// Perform structural validation on a tensorflow graph. Default is OFF.
Toggle structure_verifier = 2;
// Next tag: 3
}

View File

@ -1,611 +0,0 @@
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
syntax = "proto3";
package tensorflow;
import "google/protobuf/any.proto";
import "tensorflow/core/framework/cost_graph.proto";
import "tensorflow/core/framework/device_attributes.proto";
import "tensorflow/core/framework/graph.proto";
import "tensorflow/core/framework/step_stats.proto";
import "tensorflow/core/framework/tensor.proto";
import "tensorflow/core/framework/tensor_shape.proto";
import "tensorflow/core/framework/types.proto";
import "tensorflow/core/protobuf/config.proto";
import "tensorflow/core/protobuf/coordination_config.proto";
import "tensorflow/core/protobuf/debug.proto";
import "tensorflow/core/protobuf/error_codes.proto";
import "tensorflow/core/protobuf/named_tensor.proto";
import "tensorflow/core/protobuf/tensorflow_server.proto";
option cc_enable_arenas = true;
option java_outer_classname = "WorkerProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.distruntime";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
////////////////////////////////////////////////////////////////////////////////
//
// GetStatus method request/response messages
//
////////////////////////////////////////////////////////////////////////////////
message GetStatusRequest {}
message GetStatusResponse {
repeated DeviceAttributes device_attributes = 1;
}
////////////////////////////////////////////////////////////////////////////////
//
// CreateSession method request/response messages
//
// For each session,
//
////////////////////////////////////////////////////////////////////////////////
message CreateWorkerSessionRequest {
// Sessions are identified by a given handle.
string session_handle = 1;
// Defines the configuration of a TensorFlow worker.
ServerDef server_def = 2;
// If true, any resources such as Variables used in the session will not be
// shared with other sessions.
bool isolate_session_state = 3;
// The device attributes of all the devices in the cluster.
repeated DeviceAttributes cluster_device_attributes = 4;
// The master task name from which the request is sent.
string master_task = 5;
// The incarnation ID of the master task local CPU device.
// If the target worker already has a WorkerSession created previously with
// the same master task name but a different incarnation, it usually indicates
// that the previous master failed before deleting the WorkerSession on the
// worker. To prevent memory leaks, the worker should garbage collect the old
// WorkerSessions.
int64 master_incarnation = 6;
// Configures coordination service within worker sessions.
CoordinationServiceConfig coordination_service_config = 7;
}
message CreateWorkerSessionResponse {}
////////////////////////////////////////////////////////////////////////////////
//
// DeleteSession method request/response messages
//
// Deletes all worker-side state associated with the given session handle.
//
////////////////////////////////////////////////////////////////////////////////
message DeleteWorkerSessionRequest {
// Sessions are identified by a given handle.
string session_handle = 1;
}
message DeleteWorkerSessionResponse {}
////////////////////////////////////////////////////////////////////////////////
//
// RegisterGraph method request/response messages
//
// For each session, after the master placed every node on a device,
// it partitions the whole graph into many subgraphs. All the nodes in
// a subgraph were in the same worker, but potentially on many devices
// owned by that worker (e.g. cpu0, plus gpu0, gpu1, ..., gpu7). The
// master registers subgraphs for a worker before running any steps. A
// successful registration returns a graph handle to be used in latter
// RunGraph requests.
//
////////////////////////////////////////////////////////////////////////////////
message RegisterGraphRequest {
// Subgraphs are scoped within one session.
string session_handle = 1;
// Set to true if `CreateWorkerSession` was called for `session_handle`.
bool create_worker_session_called = 6;
// "graph_def" has the subgraph of nodes for this worker, with each node
// having its device_name filled in.
GraphDef graph_def = 2;
// True iff the graph (before partitioning) contains control flow nodes.
//
// As of 01/11/2015, this is no longer set by clients.
bool has_control_flow = 3 [deprecated = true];
// Configuration options for the session in which this graph was created.
GraphOptions graph_options = 4;
// Field(s) used by TensorFlow Debugger (tfdbg).
DebugOptions debug_options = 5;
// If graph_def contains any collective ops this must be a positive
// integer used to coordinate execution with other graphs. All
// graphs in a distributed execution with the same
// collective_graph_key will coordinate to use the same step_id
// concurrently so that BufRendezvous entries will make the correct
// values accessible.
int64 collective_graph_key = 7;
// ConfigProto from the session in which this graph was created.
// Contains additional parameters beyond graph_options, including
// the name of the requested executor.
ConfigProto config_proto = 8;
}
message RegisterGraphResponse {
// If the registration succeeds, returns an opaque graph_handle to
// the master. The master calls RunGraph with graph_handle to
// compute different steps.
string graph_handle = 1;
}
////////////////////////////////////////////////////////////////////////////////
//
// DeregisterGraph method request/response messages
//
// The master deregisters the given graph_handle when the graph is no
// longer needed (e.g., the overall graph is re-scheduled and nodes
// are re-placed).
//
// The worker deregisters a graph_handle automatically according to on
// a TTL-base policy in case of master restarts.
//
////////////////////////////////////////////////////////////////////////////////
message DeregisterGraphRequest {
// The session_handle used when registering the graph. If session_handle is
// empty, a single global namespace is used.
string session_handle = 2;
// Set to true if `CreateWorkerSession` was called for `session_handle`.
bool create_worker_session_called = 3;
// REQUIRED: graph_handle must be returned by a RegisterGraph call
// to the same WorkerService.
string graph_handle = 1;
}
message DeregisterGraphResponse {
// TODO(mrry): Optionally add summary stats for the graph.
}
////////////////////////////////////////////////////////////////////////////////
//
// CleanupAll method request/response messages
//
////////////////////////////////////////////////////////////////////////////////
message CleanupAllRequest {
// A list of container names.
//
// If 'container' is not empty, releases resources in the given
// containers in all devices.
//
// If 'container' is empty, releases resources in the default
// container in all devices.
repeated string container = 1;
}
message CleanupAllResponse {}
////////////////////////////////////////////////////////////////////////////////
//
// RunGraph request / response messages
//
// The worker executes all subgraphs registered under graph_handle.
// RunGraph returns after the execution finishes or an error is
// encountered.
// A sequence of RunGraphRequests with is_partial may be sent to RunGraph for
// partial graph execution.
//
////////////////////////////////////////////////////////////////////////////////
// Options specific to the execution of a single step.
message ExecutorOpts {
bool record_costs = 1;
bool record_timeline = 3;
bool record_partition_graphs = 4;
bool report_tensor_allocations_upon_oom = 5;
}
message RunGraphRequest {
// session_handle is the master-generated unique id for this session.
// If session_handle is non-empty, it must be the same as used when
// registering the graph. If it is empty, a single global namespace is used to
// search for the graph_handle.
string session_handle = 8;
// Set to true if `CreateWorkerSession` was called for `session_handle`.
bool create_worker_session_called = 10;
// REQUIRED: graph_handle must be returned by a RegisterGraph call
// to the same WorkerService.
string graph_handle = 1;
// A unique ID to distinguish different runs of the same graph.
//
// The master generates a global unique `step_id` to distinguish
// different runs of the graph computation. Subgraphs communicate
// (e.g., send/recv ops) with each other using `step_id` to
// distinguish tensors generated by different runs.
int64 step_id = 2;
// Options for this step.
ExecutorOpts exec_opts = 5;
// Runs the graph.
//
// Sends the tensors in "send" into the graph before the run and
// fetches the keys into `RunGraphResponse.recv` after the run.
repeated NamedTensorProto send = 3;
repeated string recv_key = 4;
// True if the RunGraphRequest is a partial run request.
bool is_partial = 6;
// True if this is the last partial run request in a sequence of requests.
bool is_last_partial_run = 7;
// If true then some errors, e.g., execution errors that have long
// error messages, may return an OK RunGraphResponse with the actual
// error saved in the status_code/status_error_message fields of the
// response body. This is a workaround since the RPC subsystem may
// truncate long metadata messages.
bool store_errors_in_response_body = 9;
// Unique identifier for this request. Every RunGraphRequest must have a
// unique request_id, and retried RunGraphRequests must have the same
// request_id. If request_id is zero, retry detection is disabled.
//
// Retried RunGraphRequests are problematic because they may issue a
// RecvTensor that will have no corresponding sender and will wait forever.
// Workers use request_ids to reject retried RunGraph requests instead of
// waiting forever.
int64 request_id = 11;
// Next: 12
}
message RunGraphResponse {
// A list of tensors corresponding to those requested by
// `RunGraphRequest.recv_key`.
repeated NamedTensorProto recv = 1;
// If the request asked for execution stats, the cost graph, or the partition
// graphs, these are returned here.
// TODO(suharshs): Package these in a RunMetadata instead.
StepStats step_stats = 2;
CostGraphDef cost_graph = 3;
repeated GraphDef partition_graph = 4;
// If store_errors_in_response_body is true in the request, then
// optionally the server may return an OK status for the RPC and
// fill the true status into the fields below, to allow for messages
// that are too long to fit in metadata.
error.Code status_code = 5;
string status_error_message = 6;
}
////////////////////////////////////////////////////////////////////////////////
//
// CleanupGraph method request/response messages
//
// After the master receives RunGraph responses from all workers, the
// master instructs every worker to cleanup any remaining state of a
// step (e.g. tensors buffered by a `Send` op but not picked up by
// other workers). The master does not necessarily need to wait for
// completion of CleanupGraph calls.
//
// Workers should cleanup step states automatically according to a
// TTL-based policy in case of master restarts.
//
////////////////////////////////////////////////////////////////////////////////
message CleanupGraphRequest {
int64 step_id = 1;
}
message CleanupGraphResponse {}
////////////////////////////////////////////////////////////////////////////////
//
// RecvTensor method request/response messages
//
////////////////////////////////////////////////////////////////////////////////
message RecvTensorRequest {
// The step in which the tensor will be produced.
//
// REQUIRED: This must eventually correspond to the `step_id` passed
// into a RunGraph call on the same WorkerService.
int64 step_id = 1;
// A key identifying the channel to receive tensors from. A RecvTensor request
// retrieves one tensor from the channel, but multiple tensors can be sent and
// received over the same channel with multiple RecvTensor requests. See
// rendezvous.h for details.
string rendezvous_key = 2;
// If true, use an out-of-band DMA mechanism to transfer the
// received tensor.
bool dma_ok = 3;
// Optional information on client-side device locality.
DeviceLocality client_locality = 4;
// Optional information on server-side device locality.
DeviceLocality server_locality = 5;
// Optional information needed by the RPC subsystem.
google.protobuf.Any transport_options = 6;
// Unique identifier for this request. Every RecvTensorRequest must have a
// unique request_id, and retried RecvTensorRequests must have the same
// request_id. If request_id is zero, retry detection and response cache
// are disabled.
//
// Retried RecvTensorRequests are problematic because a RecvTensor with no
// corresponding sender will wait forever, and the tensor may have been
// delivered to a previous retry. Workers use request_ids to reject retried
// RecvTensor requests instead of waiting forever.
int64 request_id = 7;
}
message RecvTensorResponse {
// The tensor as a proto.
TensorProto tensor = 1;
// If true, this tensor was the output of a dead node, and the
// content is invalid.
bool is_dead = 2;
// The time at which tensor was available and started to be returned.
int64 send_start_micros = 3;
// Optional additional information about how to receive the tensor,
// e.g. in the event that `RecvTensorRequest.dma_ok` was true.
google.protobuf.Any transport_options = 4;
// Whether the receiver should send a MarkRecvFinishedRequest to the sender
// to ack the message.
bool require_ack = 5;
}
// Message for managing the response cache maintained on the sender side.
// Currently only used by the gRPC worker service.
message MarkRecvFinishedRequest {
int64 request_id = 1;
}
message MarkRecvFinishedResponse {}
////////////////////////////////////////////////////////////////////////////////
//
// Logging method request/response messages
//
// NOTE(mrry): This feature is not supported in the open-source
// version, and these messages are expected to change.
//
////////////////////////////////////////////////////////////////////////////////
// Out-of-band request to begin or end logging, or
// to retrieve logs for particular steps.
message LoggingRequest {
// If true, RPC logging will be enabled.
bool enable_rpc_logging = 1;
// If true, RPC logging will be disabled.
bool disable_rpc_logging = 4;
// If true, discard any saved logging data (for all steps).
bool clear = 2;
// When set, requests all saved log data pertaining to the step.
// Any log data retrieved is eliminated from the store and cannot be
// retrieved again.
repeated int64 fetch_step_id = 3;
}
message LabeledStepStats {
int64 step_id = 1;
StepStats step_stats = 2;
}
message LoggingResponse {
repeated LabeledStepStats step = 1;
}
////////////////////////////////////////////////////////////////////////////////
//
// Tracing method request/response messages
//
// NOTE(mrry): This feature is not supported in the open-source
// version, and these messages are expected to change.
//
////////////////////////////////////////////////////////////////////////////////
message TraceOpts {
// Length of the trace to be taken, in seconds.
double duration = 1;
// If true, capture step profile locally in each worker. Currently
// unimplemented.
bool use_step_profiler = 2;
// If true, capture kernel events from each worker.
bool use_kernel_profiler = 3;
// If true, capture extended profiling events from TensorFlow process.
bool use_extended_profiler = 4;
// If true, capture GPU profiling events locally on each
// machine. Currently unimplemented.
bool use_gpu_profiler = 5;
// If true, collect sampled profile events. Currently unimplemented.
bool use_sample_profiler = 6;
}
// Out-of-band request to configure distributed tracing.
message TracingRequest {
TraceOpts options = 1;
}
message TracingResponse {}
////////////////////////////////////////////////////////////////////////////////
//
// Raw data transfers in support of Collective Ops.
// These methods are experimental and subject to change.
//
// The intention is to allow collectives to take advantage of the most
// efficient methods available on a platform, e.g. RDMA, and not be
// constrained to use the RPC system in use by other methods.
//
////////////////////////////////////////////////////////////////////////////////
message RecvBufRequest {
// Use of the fields below may vary by implementation. For example
// the buf_ptr and num_bytes may be set only for local operations and
// not sent on the wire, or only sent on the wire in one direction.
// Used at server side to find the correct BufRendezvous.
int64 step_id = 1;
// Arbitrary string identifying a BufRendezvous entry.
string buf_rendezvous_key = 2;
// Size of value expected, must agree with BufRendezvous entry.
int64 num_bytes = 3;
// When RDMA is in use, address of destination field on client.
fixed64 buf_ptr = 4;
// Optional information on client-side device locality.
DeviceLocality client_locality = 5;
// Optional information on server-side device locality.
DeviceLocality server_locality = 6;
// Optional, implementation-specific data.
google.protobuf.Any transport_options = 7;
// For annotating timeline and device incarnation check.
string src_device = 8;
// Optional, for annotating the timeline.
string dst_device = 9;
// Depending on the RPC system in use, it may be necessary to set this
// id to detect resends of RPCs where the server is not aware that
// the prior RPC failed.
int64 request_id = 10;
// Incarnation number of the source device, used to detect worker failures.
uint64 src_incarnation = 11;
}
message RecvBufResponse {
// Use of the fields below may vary by implementation. Comments give
// intended use.
fixed64 buf_ptr = 1; // Address of source field on server.
int64 num_bytes = 2; // Byte length of buf_ptr field, if set.
bool is_dead = 3; // True if value is 'dead' like a tensor.
// Optional, implementation-specific data.
google.protobuf.Any transport_options = 4;
// Optional, for timeline.
int64 send_start_micros = 5;
// Whether the receiver should send a MarkRecvFinishedRequest to the sender
// to ack the message.
bool require_ack = 6;
}
////////////////////////////////////////////////////////////////////////////////
//
// Collective Op dynamic group resolution messages.
//
////////////////////////////////////////////////////////////////////////////////
// Supplies one or more device names as members of the group identified by
// group_key. Service will respond when all group_size devices become known.
// All devices in group must have same type.
message CompleteGroupRequest {
int32 group_key = 1;
int32 group_size = 2;
string device_type = 3;
int32 collective_type = 5;
DeviceAttributes device_attributes = 6;
reserved 4;
}
// Gives the complete membership of the group identified by group_key.
message CompleteGroupResponse {
int32 group_key = 1;
int32 group_size = 2;
string device_type = 3;
int32 num_tasks = 4; // number of distinct tasks hosting the devices
bytes communicator_key = 7;
repeated DeviceAttributes device_attributes = 8;
reserved 5, 6;
}
// Supplies data about one collective op belonging to the instance identified
// by instance_key. Service will respond when all group_size ops have
// become known. Most of the data being sent is for correctness checking,
// to ensure that all ops in the instance share common attributes.
message CompleteInstanceRequest {
string name = 1;
int32 type = 2;
DataType data_type = 3;
TensorShapeProto shape = 4;
int32 group_key = 5;
int32 group_size = 6;
int32 instance_key = 7;
string device_type = 8;
repeated int32 subdiv_offset = 9;
string device = 10;
bool is_source = 11;
}
// Confirms that every op in the instance has consistently declared itself.
// Also gives the source_rank in case of broadcast.
message CompleteInstanceResponse {
int32 instance_key = 1;
int32 source_rank = 2;
reserved 3;
}
// Request for next agreed-upon step_id for the specified graph_keys.
// This is used to enable multiple graphs containing nodes from
// a common collective instance to coordinate using the same step_ids.
message GetStepSequenceRequest {
repeated int64 graph_key = 1;
}
message StepSequence {
int64 graph_key = 1;
int64 next_step_id = 2;
}
// Next valid step_ids for one or more graph_keys.
message GetStepSequenceResponse {
repeated StepSequence step_sequence = 1;
}

View File

@ -1,90 +0,0 @@
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
syntax = "proto3";
package tensorflow.grpc;
import "tensorflow/core/protobuf/worker.proto";
option java_outer_classname = "WorkerServiceProtos";
option java_multiple_files = true;
option java_package = "org.tensorflow.distruntime";
option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto";
////////////////////////////////////////////////////////////////////////////////
//
// WorkerService defines a TensorFlow service that executes dataflow
// graphs on a set of local devices, on behalf of a MasterService.
//
// A worker service keeps track of multiple "registered graphs". Each
// registered graph is a subgraph of a client's graph, corresponding to
// only the nodes that should execute on this worker (and any
// additional nodes necessary for inter-process communication using
// the `RecvTensor` method).
//
////////////////////////////////////////////////////////////////////////////////
service WorkerService {
// See worker.proto for details.
rpc GetStatus(GetStatusRequest) returns (GetStatusResponse);
// See worker.proto for details.
rpc CreateWorkerSession(CreateWorkerSessionRequest)
returns (CreateWorkerSessionResponse);
// See worker.proto for details.
rpc DeleteWorkerSession(DeleteWorkerSessionRequest)
returns (DeleteWorkerSessionResponse);
// See worker.proto for details.
rpc RegisterGraph(RegisterGraphRequest) returns (RegisterGraphResponse);
// See worker.proto for details.
rpc DeregisterGraph(DeregisterGraphRequest) returns (DeregisterGraphResponse);
// See worker.proto for details.
rpc RunGraph(RunGraphRequest) returns (RunGraphResponse);
// See worker.proto for details.
rpc CleanupGraph(CleanupGraphRequest) returns (CleanupGraphResponse);
// See worker.proto for details.
rpc CleanupAll(CleanupAllRequest) returns (CleanupAllResponse);
// See worker.proto for details.
rpc RecvTensor(RecvTensorRequest) returns (RecvTensorResponse) {
// RecvTensor Method
}
// See worker.proto for details.
rpc Logging(LoggingRequest) returns (LoggingResponse);
// See worker.proto for details.
rpc Tracing(TracingRequest) returns (TracingResponse);
// See worker.proto for details.
rpc RecvBuf(RecvBufRequest) returns (RecvBufResponse) {}
// See worker.proto for details.
rpc GetStepSequence(GetStepSequenceRequest) returns (GetStepSequenceResponse);
// See worker.proto for details.
rpc CompleteGroup(CompleteGroupRequest) returns (CompleteGroupResponse);
// See worker.proto for details.
rpc CompleteInstance(CompleteInstanceRequest)
returns (CompleteInstanceResponse);
}

View File

@ -1,48 +0,0 @@
syntax = "proto3";
option cc_enable_arenas = true;
import "tensorflow_serving/apis/input.proto";
import "tensorflow_serving/apis/model.proto";
package tensorflow.serving;
// A single class.
message Class {
// Label or name of the class.
string label = 1;
// Score for this class (e.g., the probability the item belongs to this
// class). As per the proto3 default-value semantics, if the score is missing,
// it should be treated as 0.
float score = 2;
}
// List of classes for a single item (tensorflow.Example).
message Classifications {
repeated Class classes = 1;
}
// Contains one result per input example, in the same order as the input in
// ClassificationRequest.
message ClassificationResult {
repeated Classifications classifications = 1;
}
// RPC Interfaces
message ClassificationRequest {
// Model Specification. If version is not specified, will use the latest
// (numerical) version.
ModelSpec model_spec = 1;
// Input data.
tensorflow.serving.Input input = 2;
}
message ClassificationResponse {
// Effective Model Specification used for classification.
ModelSpec model_spec = 2;
// Result of the classification.
ClassificationResult result = 1;
}

View File

@ -1,30 +0,0 @@
syntax = "proto3";
package tensorflow.serving;
option cc_enable_arenas = true;
import "google/protobuf/any.proto";
import "tensorflow/core/protobuf/meta_graph.proto";
import "tensorflow_serving/apis/model.proto";
// Message returned for "signature_def" field.
message SignatureDefMap {
map<string, SignatureDef> signature_def = 1;
};
message GetModelMetadataRequest {
// Model Specification indicating which model we are querying for metadata.
// If version is not specified, will use the latest (numerical) version.
ModelSpec model_spec = 1;
// Metadata fields to get. Currently supported: "signature_def".
repeated string metadata_field = 2;
}
message GetModelMetadataResponse {
// Model Specification indicating which model this metadata belongs to.
ModelSpec model_spec = 1;
// Map of metadata field name to metadata field. The options for metadata
// field name are listed in GetModelMetadataRequest. Currently supported:
// "signature_def".
map<string, google.protobuf.Any> metadata = 2;
}

View File

@ -1,68 +0,0 @@
syntax = "proto3";
package tensorflow.serving;
import "tensorflow_serving/apis/model.proto";
import "tensorflow_serving/apis/status.proto";
option cc_enable_arenas = true;
// GetModelStatusRequest contains a ModelSpec indicating the model for which
// to get status.
message GetModelStatusRequest {
// Model Specification. If version is not specified, information about all
// versions of the model will be returned. If a version is specified, the
// status of only that version will be returned.
ModelSpec model_spec = 1;
}
// Version number, state, and status for a single version of a model.
message ModelVersionStatus {
// Model version.
int64 version = 1;
// States that map to ManagerState enum in
// tensorflow_serving/core/servable_state.h
enum State {
// Default value.
UNKNOWN = 0;
// The manager is tracking this servable, but has not initiated any action
// pertaining to it.
START = 10;
// The manager has decided to load this servable. In particular, checks
// around resource availability and other aspects have passed, and the
// manager is about to invoke the loader's Load() method.
LOADING = 20;
// The manager has successfully loaded this servable and made it available
// for serving (i.e. GetServableHandle(id) will succeed). To avoid races,
// this state is not reported until *after* the servable is made
// available.
AVAILABLE = 30;
// The manager has decided to make this servable unavailable, and unload
// it. To avoid races, this state is reported *before* the servable is
// made unavailable.
UNLOADING = 40;
// This servable has reached the end of its journey in the manager. Either
// it loaded and ultimately unloaded successfully, or it hit an error at
// some point in its lifecycle.
END = 50;
}
// Model state.
State state = 2;
// Model status.
StatusProto status = 3;
}
// Response for ModelStatusRequest on successful run.
message GetModelStatusResponse {
// Version number and status information for applicable model version(s).
repeated ModelVersionStatus model_version_status = 1
[json_name = "model_version_status"];
}

View File

@ -1,59 +0,0 @@
// This file contains messages for various machine learning inferences
// such as regression and classification.
//
// In many applications more than one type of inference is desired for a single
// input. For example, given meteorologic data an application may want to
// perform a classification to determine if we should expect rain, snow or sun
// and also perform a regression to predict the temperature.
// Sharing the single input data between two inference tasks can be accomplished
// using MultiInferenceRequest and MultiInferenceResponse.
syntax = "proto3";
option cc_enable_arenas = true;
import "tensorflow_serving/apis/classification.proto";
import "tensorflow_serving/apis/input.proto";
import "tensorflow_serving/apis/model.proto";
import "tensorflow_serving/apis/regression.proto";
package tensorflow.serving;
// Inference request such as classification, regression, etc...
message InferenceTask {
// Model Specification. If version is not specified, will use the latest
// (numerical) version.
// All ModelSpecs in a MultiInferenceRequest must access the same model name.
ModelSpec model_spec = 1;
// Signature's method_name. Should be one of the method names defined in
// third_party/tensorflow/python/saved_model/signature_constants.py.
// e.g. "tensorflow/serving/classify".
string method_name = 2;
}
// Inference result, matches the type of request or is an error.
message InferenceResult {
ModelSpec model_spec = 1;
oneof result {
ClassificationResult classification_result = 2;
RegressionResult regression_result = 3;
}
}
// Inference request containing one or more requests.
message MultiInferenceRequest {
// Inference tasks.
repeated InferenceTask tasks = 1;
// Input data.
Input input = 2;
}
// Inference request containing one or more responses.
message MultiInferenceResponse {
// List of results; one for each InferenceTask in the request, returned in the
// same order as the request.
repeated InferenceResult results = 1;
}

View File

@ -1,82 +0,0 @@
// Input used in serving APIs. Based on the tensorflow.Example family of
// feature representations.
syntax = "proto3";
option cc_enable_arenas = true;
import "tensorflow/core/example/example.proto";
package tensorflow.serving;
// Specifies one or more fully independent input Examples.
// See examples at:
// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/example/example.proto
message ExampleList {
repeated tensorflow.Example examples = 1;
}
// Specifies one or more independent input Examples, with a common context
// Example.
//
// The common use case for context is to cleanly and optimally specify some
// features that are common across multiple examples.
//
// See example below with a search query as the context and multiple restaurants
// to perform some inference on.
//
// context: {
// features: {
// feature: {
// key : "query"
// value: {
// bytes_list: {
// value: [ "pizza" ]
// }
// }
// }
// }
// }
// examples: {
// features: {
// feature: {
// key : "cuisine"
// value: {
// bytes_list: {
// value: [ "Pizzeria" ]
// }
// }
// }
// }
// }
// examples: {
// features: {
// feature: {
// key : "cuisine"
// value: {
// bytes_list: {
// value: [ "Taqueria" ]
// }
// }
// }
// }
// }
//
// Implementations of ExampleListWithContext merge the context Example into each
// of the Examples. Note that feature keys must not be duplicated between the
// Examples and context Example, or the behavior is undefined.
//
// See also:
// tensorflow/core/example/example.proto
// https://developers.google.com/protocol-buffers/docs/proto3#maps
message ExampleListWithContext {
repeated tensorflow.Example examples = 1;
tensorflow.Example context = 2;
}
message Input {
oneof kind {
ExampleList example_list = 1 [lazy = true];
ExampleListWithContext example_list_with_context = 2 [lazy = true];
}
}

View File

@ -1,17 +0,0 @@
syntax = "proto3";
package tensorflow.serving;
import "tensorflow_serving/apis/model.proto";
import "tensorflow_serving/config/logging_config.proto";
option cc_enable_arenas = true;
// Metadata logged along with the request logs.
message LogMetadata {
ModelSpec model_spec = 1;
SamplingConfig sampling_config = 2;
// List of tags used to load the relevant MetaGraphDef from SavedModel.
repeated string saved_model_tags = 3;
// TODO(b/33279154): Add more metadata as mentioned in the bug.
}

View File

@ -1,33 +0,0 @@
syntax = "proto3";
package tensorflow.serving;
option cc_enable_arenas = true;
import "google/protobuf/wrappers.proto";
// Metadata for an inference request such as the model name and version.
message ModelSpec {
// Required servable name.
string name = 1;
// Optional choice of which version of the model to use.
//
// Recommended to be left unset in the common case. Should be specified only
// when there is a strong version consistency requirement.
//
// When left unspecified, the system will serve the best available version.
// This is typically the latest version, though during version transitions,
// notably when serving on a fleet of instances, may be either the previous or
// new version.
oneof version_choice {
// Use this specific version number.
google.protobuf.Int64Value version = 2;
// Use the version associated with the given label.
string version_label = 4;
}
// A named signature to evaluate. If unspecified, the default signature will
// be used.
string signature_name = 3;
}

View File

@ -1,16 +0,0 @@
syntax = "proto3";
package tensorflow.serving;
import "tensorflow_serving/apis/status.proto";
import "tensorflow_serving/config/model_server_config.proto";
option cc_enable_arenas = true;
message ReloadConfigRequest {
ModelServerConfig config = 1;
}
message ReloadConfigResponse {
StatusProto status = 1;
}

View File

@ -1,24 +0,0 @@
syntax = "proto3";
option cc_enable_arenas = true;
import "tensorflow_serving/apis/get_model_status.proto";
import "tensorflow_serving/apis/model_management.proto";
package tensorflow.serving;
// ModelService provides methods to query and update the state of the server,
// e.g. which models/versions are being served.
service ModelService {
// Gets status of model. If the ModelSpec in the request does not specify
// version, information about all versions of the model will be returned. If
// the ModelSpec in the request does specify a version, the status of only
// that version will be returned.
rpc GetModelStatus(GetModelStatusRequest) returns (GetModelStatusResponse);
// Reloads the set of served models. The new config supersedes the old one,
// so if a model is omitted from the new config it will be unloaded and no
// longer served.
rpc HandleReloadConfigRequest(ReloadConfigRequest)
returns (ReloadConfigResponse);
}

View File

@ -1,40 +0,0 @@
syntax = "proto3";
package tensorflow.serving;
option cc_enable_arenas = true;
import "tensorflow/core/framework/tensor.proto";
import "tensorflow_serving/apis/model.proto";
// PredictRequest specifies which TensorFlow model to run, as well as
// how inputs are mapped to tensors and how outputs are filtered before
// returning to user.
message PredictRequest {
// Model Specification. If version is not specified, will use the latest
// (numerical) version.
ModelSpec model_spec = 1;
// Input tensors.
// Names of input tensor are alias names. The mapping from aliases to real
// input tensor names is stored in the SavedModel export as a prediction
// SignatureDef under the 'inputs' field.
map<string, TensorProto> inputs = 2;
// Output filter.
// Names specified are alias names. The mapping from aliases to real output
// tensor names is stored in the SavedModel export as a prediction
// SignatureDef under the 'outputs' field.
// Only tensors specified here will be run/fetched and returned, with the
// exception that when none is specified, all tensors specified in the
// named signature will be run/fetched and returned.
repeated string output_filter = 3;
}
// Response for PredictRequest on successful run.
message PredictResponse {
// Effective Model Specification used to process PredictRequest.
ModelSpec model_spec = 2;
// Output tensors.
map<string, TensorProto> outputs = 1;
}

View File

@ -1,49 +0,0 @@
syntax = "proto3";
package tensorflow.serving;
import "tensorflow_serving/apis/classification.proto";
import "tensorflow_serving/apis/inference.proto";
import "tensorflow_serving/apis/logging.proto";
import "tensorflow_serving/apis/predict.proto";
import "tensorflow_serving/apis/regression.proto";
import "tensorflow_serving/apis/session_service.proto";
option cc_enable_arenas = true;
message ClassifyLog {
ClassificationRequest request = 1;
ClassificationResponse response = 2;
}
message RegressLog {
RegressionRequest request = 1;
RegressionResponse response = 2;
}
message PredictLog {
PredictRequest request = 1;
PredictResponse response = 2;
}
message MultiInferenceLog {
MultiInferenceRequest request = 1;
MultiInferenceResponse response = 2;
}
message SessionRunLog {
SessionRunRequest request = 1;
SessionRunResponse response = 2;
}
// Logged model inference request.
message PredictionLog {
LogMetadata log_metadata = 1;
oneof log_type {
ClassifyLog classify_log = 2;
RegressLog regress_log = 3;
PredictLog predict_log = 6;
MultiInferenceLog multi_inference_log = 4;
SessionRunLog session_run_log = 5;
}
}

View File

@ -1,31 +0,0 @@
syntax = "proto3";
package tensorflow.serving;
option cc_enable_arenas = true;
import "tensorflow_serving/apis/classification.proto";
import "tensorflow_serving/apis/get_model_metadata.proto";
import "tensorflow_serving/apis/inference.proto";
import "tensorflow_serving/apis/predict.proto";
import "tensorflow_serving/apis/regression.proto";
// open source marker; do not remove
// PredictionService provides access to machine-learned models loaded by
// model_servers.
service PredictionService {
// Classify.
rpc Classify(ClassificationRequest) returns (ClassificationResponse);
// Regress.
rpc Regress(RegressionRequest) returns (RegressionResponse);
// Predict -- provides access to loaded TensorFlow model.
rpc Predict(PredictRequest) returns (PredictResponse);
// MultiInference API for multi-headed models.
rpc MultiInference(MultiInferenceRequest) returns (MultiInferenceResponse);
// GetModelMetadata - provides access to metadata for loaded models.
rpc GetModelMetadata(GetModelMetadataRequest)
returns (GetModelMetadataResponse);
}

View File

@ -1,37 +0,0 @@
syntax = "proto3";
option cc_enable_arenas = true;
import "tensorflow_serving/apis/input.proto";
import "tensorflow_serving/apis/model.proto";
package tensorflow.serving;
// Regression result for a single item (tensorflow.Example).
message Regression {
float value = 1;
}
// Contains one result per input example, in the same order as the input in
// RegressionRequest.
message RegressionResult {
repeated Regression regressions = 1;
}
// RPC interfaces.
message RegressionRequest {
// Model Specification. If version is not specified, will use the latest
// (numerical) version.
ModelSpec model_spec = 1;
// Input data.
tensorflow.serving.Input input = 2;
}
message RegressionResponse {
// Effective Model Specification used for regression.
ModelSpec model_spec = 2;
RegressionResult result = 1;
}

View File

@ -1,56 +0,0 @@
syntax = "proto3";
package tensorflow.serving;
import "tensorflow/core/protobuf/config.proto";
import "tensorflow/core/protobuf/named_tensor.proto";
import "tensorflow_serving/apis/model.proto";
option cc_enable_arenas = true;
message SessionRunRequest {
// Model Specification. If version is not specified, will use the latest
// (numerical) version.
ModelSpec model_spec = 1;
// Tensors to be fed in the step. Each feed is a named tensor.
repeated NamedTensorProto feed = 2;
// Fetches. A list of tensor names. The caller expects a tensor to
// be returned for each fetch[i] (see RunResponse.tensor). The
// order of specified fetches does not change the execution order.
repeated string fetch = 3;
// Target Nodes. A list of node names. The named nodes will be run
// to but their outputs will not be fetched.
repeated string target = 4;
// If true, treat names in feed/fetch/target as alias names than actual tensor
// names (that appear in the TF graph). Alias names are resolved to actual
// names using `SignatureDef` in SavedModel associated with the model.
bool tensor_name_is_alias = 6;
// Options for the run call. **Currently ignored.**
RunOptions options = 5;
}
message SessionRunResponse {
// Effective Model Specification used for session run.
ModelSpec model_spec = 3;
// NOTE: The order of the returned tensors may or may not match
// the fetch order specified in RunRequest.
repeated NamedTensorProto tensor = 1;
// Returned metadata if requested in the options.
RunMetadata metadata = 2;
}
// SessionService defines a service with which a client can interact to execute
// Tensorflow model inference. The SessionService::SessionRun method is similar
// to MasterService::RunStep of Tensorflow, except that all sessions are ready
// to run, and you request a specific model/session with ModelSpec.
service SessionService {
// Runs inference of a given model.
rpc SessionRun(SessionRunRequest) returns (SessionRunResponse);
}

View File

@ -1,17 +0,0 @@
syntax = "proto3";
package tensorflow.serving;
import "tensorflow/core/protobuf/error_codes.proto";
option cc_enable_arenas = true;
// Status that corresponds to Status in
// third_party/tensorflow/core/lib/core/status.h.
message StatusProto {
// Error code.
error.Code error_code = 1 [json_name = "error_code"];
// Error message. Will only be set if an error was encountered.
string error_message = 2 [json_name = "error_message"];
}

View File

@ -1,88 +0,0 @@
syntax = "proto3";
package tensorflow.serving;
// Config proto for FileSystemStoragePathSource.
message FileSystemStoragePathSourceConfig {
// A policy that dictates which version(s) of a servable should be served.
message ServableVersionPolicy {
// Serve the latest versions (i.e. the ones with the highest version
// numbers), among those found on disk.
//
// This is the default policy, with the default number of versions as 1.
message Latest {
// Number of latest versions to serve. (The default is 1.)
uint32 num_versions = 1;
}
// Serve all versions found on disk.
message All {
}
// Serve a specific version (or set of versions).
//
// This policy is useful for rolling back to a specific version, or for
// canarying a specific version while still serving a separate stable
// version.
message Specific {
// The version numbers to serve.
repeated int64 versions = 1;
}
oneof policy_choice {
Latest latest = 100;
All all = 101;
Specific specific = 102;
}
}
// A servable name and base path to look for versions of the servable.
message ServableToMonitor {
// The servable name to supply in aspired-versions callback calls. Child
// paths of 'base_path' are considered to be versions of this servable.
string servable_name = 1;
// The path to monitor, i.e. look for child paths of the form base_path/123.
string base_path = 2;
// The policy to determines the number of versions of the servable to be
// served at the same time.
tensorflow.serving.FileSystemStoragePathSourceConfig.ServableVersionPolicy
servable_version_policy = 4;
reserved 3; // Legacy version_policy definition.
}
// The servables to monitor for new versions, and aspire.
repeated ServableToMonitor servables = 5;
// A single servable name/base_path pair to monitor.
// DEPRECATED: Use 'servables' instead.
// TODO(b/30898016): Stop using these fields, and ultimately remove them here.
string servable_name = 1 [deprecated = true];
string base_path = 2 [deprecated = true];
// How long to wait between file-system polling to look for children of
// 'base_path', in seconds.
//
// If set to zero, filesystem will be polled exactly once. If set to a
// negative value (for testing use only), polling will be entirely disabled.
int64 file_system_poll_wait_seconds = 3;
// If true, then FileSystemStoragePathSource::Create() and ::UpdateConfig()
// fail if, for any configured servables, the file system doesn't currently
// contain at least one version under the base path.
// (Otherwise, it will emit a warning and keep pinging the file system to
// check for a version to appear later.)
// DEPRECATED: Use 'servable_versions_always_present' instead, which includes
// this behavior.
// TODO(b/30898016): Remove 2019-10-31 or later.
bool fail_if_zero_versions_at_startup = 4 [deprecated = true];
// If true, the servable is always expected to exist on the underlying
// filesystem. FileSystemStoragePathSource::Create() and ::UpdateConfig() will
// fail if, for any configured servables, the file system doesn't currently
// contain at least one version under the base path. In addition, if a polling
// loop find the base path empty, it will not unload existing servables.
bool servable_versions_always_present = 6;
}

View File

@ -1,12 +0,0 @@
syntax = "proto3";
package tensorflow.serving;
option cc_enable_arenas = true;
message LogCollectorConfig {
// Identifies the type of the LogCollector we will use to collect these logs.
string type = 1;
// The prefix to use for the filenames of the logs.
string filename_prefix = 2;
}

View File

@ -1,18 +0,0 @@
syntax = "proto3";
package tensorflow.serving;
option cc_enable_arenas = true;
import "tensorflow_serving/config/log_collector_config.proto";
message SamplingConfig {
// Requests will be logged uniformly at random with this probability. Valid
// range: [0, 1.0].
double sampling_rate = 1;
}
// Configuration for logging query/responses.
message LoggingConfig {
LogCollectorConfig log_collector_config = 1;
SamplingConfig sampling_config = 2;
}

View File

@ -1,85 +0,0 @@
syntax = "proto3";
package tensorflow.serving;
import "google/protobuf/any.proto";
import "tensorflow_serving/config/file_system_storage_path_source.proto";
import "tensorflow_serving/config/logging_config.proto";
option cc_enable_arenas = true;
// The type of model.
// TODO(b/31336131): DEPRECATED.
enum ModelType {
MODEL_TYPE_UNSPECIFIED = 0 [deprecated = true];
TENSORFLOW = 1 [deprecated = true];
OTHER = 2 [deprecated = true];
}
// Common configuration for loading a model being served.
message ModelConfig {
// Name of the model.
string name = 1;
// Base path to the model, excluding the version directory.
// E.g> for a model at /foo/bar/my_model/123, where 123 is the version, the
// base path is /foo/bar/my_model.
//
// (This can be changed once a model is in serving, *if* the underlying data
// remains the same. Otherwise there are no guarantees about whether the old
// or new data will be used for model versions currently loaded.)
string base_path = 2;
// Type of model.
// TODO(b/31336131): DEPRECATED. Please use 'model_platform' instead.
ModelType model_type = 3 [deprecated = true];
// Type of model (e.g. "tensorflow").
//
// (This cannot be changed once a model is in serving.)
string model_platform = 4;
reserved 5, 9;
// Version policy for the model indicating which version(s) of the model to
// load and make available for serving simultaneously.
// The default option is to serve only the latest version of the model.
//
// (This can be changed once a model is in serving.)
FileSystemStoragePathSourceConfig.ServableVersionPolicy model_version_policy =
7;
// String labels to associate with versions of the model, allowing inference
// queries to refer to versions by label instead of number. Multiple labels
// can map to the same version, but not vice-versa.
//
// An envisioned use-case for these labels is canarying tentative versions.
// For example, one can assign labels "stable" and "canary" to two specific
// versions. Perhaps initially "stable" is assigned to version 0 and "canary"
// to version 1. Once version 1 passes canary, one can shift the "stable"
// label to refer to version 1 (at that point both labels map to the same
// version -- version 1 -- which is fine). Later once version 2 is ready to
// canary one can move the "canary" label to version 2. And so on.
map<string, int64> version_labels = 8;
// Configures logging requests and responses, to the model.
//
// (This can be changed once a model is in serving.)
LoggingConfig logging_config = 6;
}
// Static list of models to be loaded for serving.
message ModelConfigList {
repeated ModelConfig config = 1;
}
// ModelServer config.
message ModelServerConfig {
// ModelServer takes either a static file-based model config list or an Any
// proto representing custom model config that is fetched dynamically at
// runtime (through network RPC, custom service, etc.).
oneof config {
ModelConfigList model_config_list = 1;
google.protobuf.Any custom_model_config = 2;
}
}

View File

@ -1,9 +0,0 @@
#!/bin/sh
#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 \
RUST_LOG=info LD_LIBRARY_PATH=so/onnx/lib cargo run --bin navi_onnx --features onnx -- \
--port 8030 --num-worker-threads 8 \
--model-check-interval-secs 30 \
--modelsync-cli "echo" \
--onnx-ep-options use_arena=true \
--model-dir models/prod_home --output caligrated_probabilities --input "" --intra-op-parallelism 8 --inter-op-parallelism 8 --max-batch-size 1 --batch-time-out-millis 1 \
--model-dir models/prod_home1 --output caligrated_probabilities --input "" --intra-op-parallelism 8 --inter-op-parallelism 8 --max-batch-size 1 --batch-time-out-millis 1 \

View File

@ -1,6 +0,0 @@
#!/bin/sh
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 \
--model-check-interval-secs 30 \
--model-dir models/click/ \
--input "" \
--output output_0

Some files were not shown because too many files have changed in this diff Show More