Skip to content

Commit

Permalink
Revert "Add test for zero length bytes tensor in Python backend (#3329)"
Browse files Browse the repository at this point in the history
This reverts commit 4ef90b6.
  • Loading branch information
Tabrizian authored Sep 8, 2021
1 parent 4ef90b6 commit bd7911f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
14 changes: 6 additions & 8 deletions qa/L0_backend_python/python_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,12 @@ def test_string(self):
model_name = "string_fixed"
shape = [1]

for i in range(6):
# Each time inference is performed with a new
# API
for i in range(3):
with httpclient.InferenceServerClient("localhost:8000") as client:
input_data = np.array(['123456'], dtype=np.object_)
sample_input = '123456'
input_data = np.array([sample_input], dtype=np.object_)
inputs = [
httpclient.InferInput("INPUT0", shape,
np_to_triton_dtype(input_data.dtype))
Expand All @@ -252,12 +255,7 @@ def test_string(self):
result = client.infer(model_name, inputs)
output0 = result.as_numpy('OUTPUT0')
self.assertTrue(output0 is not None)

if i % 2 == 0:
self.assertTrue(output0[0] == input_data.astype(np.bytes_))
else:
self.assertTrue(output0.size == 0)

self.assertTrue(output0[0] == input_data.astype(np.bytes_))

def test_non_contiguous(self):
model_name = 'non_contiguous'
Expand Down
2 changes: 1 addition & 1 deletion qa/python_models/string_fixed/config.pbtxt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ output [
{
name: "OUTPUT0"
data_type: TYPE_STRING
dims: [ -1 ]
dims: [ 1 ]
}
]

Expand Down
14 changes: 4 additions & 10 deletions qa/python_models/string_fixed/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,17 @@ class TritonPythonModel:
"""
This model returns a constant string on every inference request.
"""

def initialize(self, args):
self._index = 0
self._dtypes = [np.bytes_, np.object_, np.object]

def execute(self, requests):
responses = []
for _ in requests:
if self._index % 2 == 0:
out_tensor_0 = pb_utils.Tensor(
"OUTPUT0",
np.array(['123456'], dtype=self._dtypes[self._index % 3]))
else:
# Test sending strings with no elements
out_tensor_0 = pb_utils.Tensor(
"OUTPUT0", np.array([],
dtype=self._dtypes[self._index % 3]))

out_tensor_0 = pb_utils.Tensor(
"OUTPUT0", np.array(['123456'],
dtype=self._dtypes[self._index]))
self._index += 1
responses.append(pb_utils.InferenceResponse([out_tensor_0]))
return responses

0 comments on commit bd7911f

Please sign in to comment.