I'm trying to make a call from a Java client to Tensorflow Serving. The running model is the half\_plus\_two example model. I can make a REST call successfully. But cannot make the gRPC equivalent call.

I have tried passing a string as model input and also an array of floats into tensor proto builder. The tensor proto seems to contain correct data when I print it out:
[1.0, 2.0, 5.0]

```
String host = "localhost";
        int port = 8500;
        // the model's name.
        String modelName = "half_plus_two";
        // model's version
        long modelVersion = 123;
        // assume this model takes input of free text, and make some sentiment prediction.
//        String modelInput = "some text input to make prediction with";
        String modelInput = "{\"instances\": [1.0, 2.0, 5.0]";

        // create a channel
        ManagedChannel channel = ManagedChannelBuilder.forAddress(host, port).usePlaintext().build();
        tensorflow.serving.PredictionServiceGrpc.PredictionServiceBlockingStub stub = tensorflow.serving.PredictionServiceGrpc.newBlockingStub(channel);

        // create a modelspec
        tensorflow.serving.Model.ModelSpec.Builder modelSpecBuilder = tensorflow.serving.Model.ModelSpec.newBuilder();
        modelSpecBuilder.setName(modelName);
        modelSpecBuilder.setVersion(Int64Value.of(modelVersion));
        modelSpecBuilder.setSignatureName("serving_default");

        Predict.PredictRequest.Builder builder = Predict.PredictRequest.newBuilder();
        builder.setModelSpec(modelSpecBuilder);

        // create the TensorProto and request

        float[] floatData = new float[3];
        floatData[0] = 1.0f;
        floatData[1] = 2.0f;
        floatData[2] = 5.0f;

        org.tensorflow.framework.TensorProto.Builder tensorProtoBuilder = org.tensorflow.framework.TensorProto.newBuilder();
        tensorProtoBuilder.setDtype(DataType.DT_FLOAT);
        org.tensorflow.framework.TensorShapeProto.Builder tensorShapeBuilder = org.tensorflow.framework.TensorShapeProto.newBuilder();
        tensorShapeBuilder.addDim(org.tensorflow.framework.TensorShapeProto.Dim.newBuilder().setSize(3));
        tensorProtoBuilder.setTensorShape(tensorShapeBuilder.build());

        // Set the float_val field.
        for (int i = 0; i < floatData.length; i++) {
            tensorProtoBuilder.addFloatVal(floatData[i]);
        }

        org.tensorflow.framework.TensorProto tp = tensorProtoBuilder.build();

        System.out.println(tp.getFloatValList());

        builder.putInputs("inputs", tp);

        Predict.PredictRequest request = builder.build();
        Predict.PredictResponse response = stub.predict(request);

```

When I print request the shape is:

```
model_spec {
  name: "half_plus_two"
  version {
    value: 123
  }
  signature_name: "serving_default"
}
inputs {
  key: "inputs"
  value {
    dtype: DT_FLOAT
    tensor_shape {
      dim {
        size: -1
      }
      dim {
        size: 1
      }
    }
    float_val: 1.0
    float_val: 2.0
    float_val: 5.0
  }
}

```

Get this exception:

```
Exception in thread "main" io.grpc.StatusRuntimeException: INVALID_ARGUMENT: input tensor alias not found in signature: inputs. Inputs expected to be in the set {x}.
    at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:233)
    at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:214)
    at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:139)
    at tensorflow.serving.PredictionServiceGrpc$PredictionServiceBlockingStub.predict(PredictionServiceGrpc.java:446)
    at com.avaya.ccml.grpc.GrpcClient.main(GrpcClient.java:72)`

```

Edit:
Still working on this.

It looks like the tensor proto I'm supplying is not correct.

Did an inspect with saved\_model\_cli and it shows the correct shape:

```
The given SavedModel SignatureDef contains the following input(s):
  inputs['x'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 1)
      name: x:0
The given SavedModel SignatureDef contains the following output(s):
  outputs['y'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 1)
      name: y:0
Method name is: tensorflow/serving/predict

```

So next need to figure out how to create tensor proto of this structure

Current