-
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 a test case with the model of
sample_multiple_hybrid_dims
and m…
…odify `sample` model
- Loading branch information
Showing
4 changed files
with
128 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import json | ||
|
||
import numpy as np | ||
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)) | ||
in_tensor = [ | ||
item.as_numpy() + current_add_value | ||
for item in request.inputs() | ||
if "model_in" in item.name() | ||
] | ||
|
||
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) | ||
out_tensor.append( | ||
pb_utils.Tensor( | ||
"model_out2", | ||
np.array([current_add_value], dtype=self.output_dtype_list[1]), | ||
) | ||
) | ||
|
||
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,63 @@ | ||
name: "sample_multiple_hybrid_dims" | ||
backend: "python" | ||
max_batch_size: 2 | ||
|
||
parameters [ | ||
{ | ||
key: "add", | ||
value: { string_value: "0" } | ||
} | ||
] | ||
input [ | ||
{ | ||
name: "model_in0" | ||
data_type: TYPE_FP32 | ||
dims: [ -1 ] | ||
}, | ||
{ | ||
name: "model_in1" | ||
data_type: TYPE_FP32 | ||
dims: [ -1 ] | ||
} | ||
] | ||
output [ | ||
{ | ||
name: "model_out0" | ||
data_type: TYPE_FP32 | ||
dims: [ -1 ] | ||
}, | ||
{ | ||
name: "model_out1" | ||
data_type: TYPE_FP32 | ||
dims: [ -1 ] | ||
}, | ||
{ | ||
name: "model_out2" | ||
data_type: TYPE_FP32 | ||
dims: [ 1 ] | ||
} | ||
] | ||
instance_group [{ kind: KIND_CPU, count: 1 }] | ||
model_warmup { | ||
name: "RandomSampleInput" | ||
batch_size: 1 | ||
inputs [{ | ||
key: "model_in0" | ||
value: { | ||
data_type: TYPE_FP32 | ||
dims: [ 10 ] | ||
random_data: true | ||
} | ||
}, { | ||
key: "model_in1" | ||
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