Skip to content
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

Enhanced python_backend autocomplete #317

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 69 additions & 5 deletions src/resources/triton_python_backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,12 @@ def add_input(self, input):
Raises
------
ValueError
If input contains property other than 'name', 'data_type'
and 'dims' or any of the properties are not set, or if an
input with the same name already exists in the configuration
but has different data_type or dims property
If input contains property other than 'name', 'data_type',
'dims', 'optional' or any of the non-optional properties
are not set, or if an input with the same name already exists
in the configuration but has different data_type or dims property
"""
valid_properties = ["name", "data_type", "dims"]
valid_properties = ["name", "data_type", "dims", "optional"]
for current_property in input:
if current_property not in valid_properties:
raise ValueError(
Expand Down Expand Up @@ -447,9 +447,26 @@ def add_input(self, input):
+ " but the model configuration specifies dims "
+ str(current_input["dims"])
)
elif (
"optional" in current_input
and "optional" in input
and current_input["optional"] != input["optional"]
):
raise ValueError(
"model '"
+ self._model_config["name"]
+ "', tensor '"
+ input["name"]
+ "': the model expects optional "
+ str(input["optional"])
+ " but the model configuration specifies optional "
+ str(current_input["optional"])
)
else:
current_input["data_type"] = input["data_type"]
current_input["dims"] = input["dims"]
if "optional" in input:
current_input["optional"] = input["optional"]
return

self._model_config["input"].append(input)
Expand Down Expand Up @@ -538,6 +555,53 @@ def add_output(self, output):

self._model_config["output"].append(output)

def set_model_transaction_policy(self, transaction_policy_dict):
"""
Set model transaction policy for the model.
Parameters
----------
transaction_policy_dict : dict
The dict, containing all properties to be set as a part
of `model_transaction_policy` field.
Raises
------
ValueError
If transaction_policy_dict contains property other
than 'decoupled', or if `model_transaction_policy` already exists
in the configuration, but has different `decoupled` property.
"""
valid_properties = ["decoupled"]
for current_property in transaction_policy_dict.keys():
if current_property not in valid_properties:
raise ValueError(
"model transaction property in auto-complete-config "
+ "function for model '"
+ self._model_config["name"]
+ "' contains property other than 'decoupled'."
)

if "model_transaction_policy" not in self._model_config:
self._model_config["model_transaction_policy"] = {}

if "decoupled" in transaction_policy_dict.keys():
if (
"decoupled" in self._model_config["model_transaction_policy"]
and self._model_config["model_transaction_policy"]["decoupled"]
!= transaction_policy_dict["decoupled"]
):
raise ValueError(
"trying to change decoupled property in auto-complete-config "
+ "for model '"
+ self._model_config["name"]
+ "', which is already set to '"
+ str(self._model_config["model_transaction_policy"]["decoupled"])
+ "'."
)

self._model_config["model_transaction_policy"][
"decoupled"
] = transaction_policy_dict["decoupled"]


TRITONSERVER_REQUEST_FLAG_SEQUENCE_START = 1
TRITONSERVER_REQUEST_FLAG_SEQUENCE_END = 2
Expand Down
Loading