Skip to content

Commit

Permalink
Add test for type bool in Python backend (#2509)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tabrizian authored Feb 11, 2021
1 parent 78c2082 commit f3c661d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 16 additions & 1 deletion qa/L0_backend_python/python_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ def test_async_infer(self):
"error: expected metric {} == 1, got {}".format(
infer_exec_str, infer_exec_val))

def test_bool(self):
model_name = 'identity_bool'
with httpclient.InferenceServerClient("localhost:8000") as client:
input_data = np.array([[True, False, True]], dtype=np.bool)
inputs = [
httpclient.InferInput("IN", input_data.shape,
np_to_triton_dtype(input_data.dtype))
]
inputs[0].set_data_from_numpy(input_data)
result = client.infer(model_name, inputs)
output0 = result.as_numpy('OUT')
self.assertTrue(output0 is not None)
self.assertTrue(np.all(output0 == input_data))

def test_infer_pymodel_error(self):
model_name = "wrong_model"
shape = [2, 2]
Expand Down Expand Up @@ -250,7 +264,8 @@ def test_unicode(self):
shape = [1]
with httpclient.InferenceServerClient("localhost:8000") as client:
utf8 = '😀'
input_data = np.array([bytes(utf8, encoding='utf-8')], dtype=np.bytes_)
input_data = np.array([bytes(utf8, encoding='utf-8')],
dtype=np.bytes_)
inputs = [
httpclient.InferInput("INPUT0", shape,
np_to_triton_dtype(input_data.dtype))
Expand Down
7 changes: 6 additions & 1 deletion qa/L0_backend_python/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

CLIENT_PY=./python_test.py
CLIENT_LOG="./client.log"
EXPECTED_NUM_TESTS="7"
EXPECTED_NUM_TESTS="8"

SERVER=/opt/tritonserver/bin/tritonserver
SERVER_ARGS="--model-repository=`pwd`/models --log-verbose=1"
Expand Down Expand Up @@ -56,6 +56,11 @@ cp -r ./models/identity_fp32 ./models/identity_uint32
sed -i "s/^name:.*/name: \"identity_uint32\"/" config.pbtxt && \
sed -i "s/TYPE_FP32/TYPE_UINT32/g" config.pbtxt)

cp -r ./models/identity_fp32 ./models/identity_bool
(cd models/identity_bool && \
sed -i "s/^name:.*/name: \"identity_bool\"/" config.pbtxt && \
sed -i "s/TYPE_FP32/TYPE_BOOL/g" config.pbtxt)

mkdir -p models/wrong_model/1/
cp ../python_models/wrong_model/model.py ./models/wrong_model/1/
cp ../python_models/wrong_model/config.pbtxt ./models/wrong_model/
Expand Down

0 comments on commit f3c661d

Please sign in to comment.