Skip to content

Commit

Permalink
Add exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ragmani committed Jan 8, 2025
1 parent 3d78ad3 commit 3ba4c97
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions runtime/onert/api/python/package/common/basesession.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def set_inputs(self, size, inputs_array=[]):
size (int): Number of input tensors.
inputs_array (list): List of numpy arrays for the input data.
"""
if self.session is None:
raise ValueError(
"Session is not initialized with a model. Please compile with a model before setting inputs."
)
for i in range(size):
input_tensorinfo = self.session.input_tensorinfo(i)

Expand All @@ -80,6 +84,10 @@ def set_outputs(self, size):
Args:
size (int): Number of output tensors.
"""
if self.session is None:
raise ValueError(
"Session is not initialized with a model. Please compile a model before setting outputs."
)
for i in range(size):
output_tensorinfo = self.session.output_tensorinfo(i)
output_array = np.zeros((num_elems(output_tensorinfo)),
Expand Down

0 comments on commit 3ba4c97

Please sign in to comment.