syntax = "proto3";

package tensorflow.serving;

// Signatures of model export.
message Signatures {
  // Default signature of the graph.
  // WARNING(break-tutorial-inline-code): The following code snippet is
  // in-lined in tutorials, please update tutorial documents accordingly
  // whenever code changes.
  Signature default_signature = 1;

  // Named signatures of the graph.
  map<string, Signature> named_signatures = 2;
};

// A binding to a tensor including the name and, possibly in the future, type
// or other metadata. For example, this may specify whether a tensor supports
// batch vs single inference.
message TensorBinding {
  // The name of the tensor to bind to.
  string tensor_name = 1;
};

// An asset file or set of sharded files with the same name that will be bound
// to a tensor at init / session_bundle load time.
message AssetFile {
  // The tensor to bind the asset filename to.
  TensorBinding tensor_binding = 1;
  // The filename within the assets directory. Note: does not include the base
  // path or asset directory prefix. Base paths can and will change when models
  // are deployed for serving.
  string filename = 2;
}

// A Signature specifies the inputs and outputs of commonly used graphs.
message Signature {
  oneof type {
    RegressionSignature regression_signature = 1;
    ClassificationSignature classification_signature = 2;
    GenericSignature generic_signature = 3;
  }
};

// RegressionSignature specifies a graph that takes an input and returns an
// output.
message RegressionSignature {
  TensorBinding input = 1;
  TensorBinding output = 2;
};

// ClassificationSignature specifies a graph that takes an input and returns
// classes and their scores.
// WARNING(break-tutorial-inline-code): The following code snippet is
// in-lined in tutorials, please update tutorial documents accordingly
// whenever code changes.
message ClassificationSignature {
  TensorBinding input = 1;
  TensorBinding classes = 2;
  TensorBinding scores = 3;
};

// GenericSignature specifies a map from logical name to Tensor name.
// Typical application of GenericSignature is to use a single GenericSignature
// that includes all of the Tensor nodes and target names that may be useful at
// serving, analysis or debugging time. The recommended name for this signature
// in the ModelManifest is "generic_bindings".
message GenericSignature {
  map<string, TensorBinding> map = 1;
};
