-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Client-side input shape/element validation #7427
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple questions
f432d41
to
3863c39
Compare
17053e9
to
482409e
Compare
} | ||
EOL | ||
|
||
cp -r $DATADIR/qa_model_repository/graphdef_object_int32_int32 models/. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use model "simple_identity" instead to test string inputs.
if client_type == "http": | ||
triton_client = tritonhttpclient.InferenceServerClient("localhost:8000") | ||
else: | ||
triton_client = tritongrpcclient.InferenceServerClient("localhost:8001") | ||
|
||
# Example using BYTES input tensor with utf-8 encoded string that | ||
# has an embedded null character. | ||
null_chars_array = np.array( | ||
["he\x00llo".encode("utf-8") for i in range(16)], dtype=np.object_ | ||
) | ||
null_char_data = null_chars_array.reshape([1, 16]) | ||
identity_inference(triton_client, null_char_data, True) # Using binary data | ||
identity_inference(triton_client, null_char_data, False) # Using JSON data | ||
|
||
# Example using BYTES input tensor with 16 elements, where each | ||
# element is a 4-byte binary blob with value 0x00010203. Can use | ||
# dtype=np.bytes_ in this case. | ||
bytes_data = [b"\x00\x01\x02\x03" for i in range(16)] | ||
np_bytes_data = np.array(bytes_data, dtype=np.bytes_) | ||
np_bytes_data = np_bytes_data.reshape([1, 16]) | ||
identity_inference(triton_client, np_bytes_data, True) # Using binary data | ||
identity_inference(triton_client, np_bytes_data, False) # Using JSON data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from client/src/python/examples/simple_http_string_infer_client.py
. It looks like the example demonstrated two ways of preparing string input data. I'll remove one of them.
inputs[0].set_shape([2, 8]) | ||
inputs[1].set_shape([2, 8]) | ||
|
||
with self.assertRaises(InferenceServerException) as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with self.assertRaises(InferenceServerException) as e: | |
# If number of elements (volume) is correct but shape is wrong, the core will return an error. | |
with self.assertRaises(InferenceServerException) as e: |
What does the PR do?
Add client input size check to make sure input shape byte size matches input data byte size.
Checklist
<commit_type>: <Title>
Commit Type:
Check the conventional commit type
box here and add the label to the github PR.
Related PRs:
triton-inference-server/client#742
Where should the reviewer start?
Should look at triton-inference-server/client#742 first.
Test plan:
n/a
17202351
Caveats:
Shared memory byte size checks for string inputs is not implemented.
Background
Stop malformed input request at client side before sending to the server.
Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Relates to #7171