Nvidia Triton tensorflow string parameter

588 views Asked by At

I have a tensorflow model with a string parameter as input. Whats the type to use for strings in the Triton Java api?

Eg. Model definition

    {
        "name":"test_model", "platform":"tensorflow_savedmodel", "backend":"tensorflow",
            "version_policy":{
        "latest":{
            "num_versions":1
        }
    },
        "max_batch_size":8,
            "input":[{
        "name":"input_text", "data_type":"TYPE_STRING", "format":"FORMAT_NONE", "dims":[1],"reshape":{
            "shape":[]},"is_shape_tensor":false, "allow_ragged_batch":false
    }]

Client code

String text = "the text";

    InferTensorContents.Builder input0_data = InferTensorContents.newBuilder();
    input0_data ... how to set
1

There are 1 answers

0
oluies On

Triton uses google protobufs, so this is they way by using ByteString

    String text = "textstring";
    InferTensorContents.Builder input0input_text = InferTensorContents.newBuilder();
    final ByteString input = ByteString.copyFrom(text, Charset.forName("UTF8"));
    System.out.println(input.size());
    input0input_text.addByteContents(input);