-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sample_optional, and fix pytest for parameters, optional
- Loading branch information
1 parent
f071bc5
commit d82974e
Showing
9 changed files
with
151 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
HERE=$(dirname "$(readlink -f $0)") | ||
PARENT_DIR=$(dirname "$HERE") | ||
|
||
docker run -it --rm --name triton_tritony \ | ||
-p8100:8000 \ | ||
-p8101:8001 \ | ||
-p8102:8002 \ | ||
-v "${PARENT_DIR}"/model_repository:/models:ro \ | ||
-e OMP_NUM_THREADS=2 \ | ||
-e OPENBLAS_NUM_THREADS=2 \ | ||
--shm-size=1g \ | ||
nvcr.io/nvidia/tritonserver:23.08-pyt-python-py3 \ | ||
tritonserver --model-repository=/models \ | ||
--exit-timeout-secs 15 \ | ||
--min-supported-compute-capability 7.0 \ | ||
--log-verbose 0 # 0-nothing, 1-info, 2-debug, 3-trace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import json | ||
|
||
import triton_python_backend_utils as pb_utils | ||
|
||
|
||
class TritonPythonModel: | ||
def initialize(self, args): | ||
self.model_config = model_config = json.loads(args["model_config"]) | ||
output_configs = model_config["output"] | ||
|
||
self.output_name_list = [output_config["name"] for output_config in output_configs] | ||
self.output_dtype_list = [ | ||
pb_utils.triton_string_to_numpy(output_config["data_type"]) for output_config in output_configs | ||
] | ||
|
||
def execute(self, requests): | ||
responses = [None for _ in requests] | ||
for idx, request in enumerate(requests): | ||
current_add_value = int(json.loads(request.parameters()).get("add", 0)) | ||
optional_in_tensor = pb_utils.get_input_tensor_by_name(request, "optional_model_sub") | ||
if optional_in_tensor: | ||
optional_in_tensor = optional_in_tensor.as_numpy() | ||
else: | ||
optional_in_tensor = 0 | ||
|
||
in_tensor = [ | ||
item.as_numpy() + current_add_value - optional_in_tensor | ||
for item in request.inputs() | ||
if item.name() == "model_in" | ||
] | ||
out_tensor = [ | ||
pb_utils.Tensor(output_name, x.astype(output_dtype)) | ||
for x, output_name, output_dtype in zip(in_tensor, self.output_name_list, self.output_dtype_list) | ||
] | ||
inference_response = pb_utils.InferenceResponse(output_tensors=out_tensor) | ||
responses[idx] = inference_response | ||
return responses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: "sample_optional" | ||
backend: "python" | ||
max_batch_size: 0 | ||
|
||
parameters [ | ||
{ | ||
key: "add", | ||
value: { string_value: "0" } | ||
} | ||
] | ||
input [ | ||
{ | ||
name: "model_in" | ||
data_type: TYPE_FP32 | ||
dims: [ -1 ] | ||
}, | ||
{ | ||
name: "optional_model_sub" | ||
data_type: TYPE_FP32 | ||
optional: true | ||
dims: [ -1 ] | ||
} | ||
] | ||
output [ | ||
{ | ||
name: "model_out" | ||
data_type: TYPE_FP32 | ||
dims: [ -1 ] | ||
} | ||
] | ||
instance_group [{ kind: KIND_CPU, count: 1 }] | ||
model_warmup { | ||
name: "RandomSampleInput" | ||
batch_size: 1 | ||
inputs [{ | ||
key: "model_in" | ||
value: { | ||
data_type: TYPE_FP32 | ||
dims: [ 10 ] | ||
random_data: true | ||
} | ||
}, { | ||
key: "model_in" | ||
value: { | ||
data_type: TYPE_FP32 | ||
dims: [ 10 ] | ||
zero_data: true | ||
} | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters