Skip to content

Commit

Permalink
Add a condition to optional checker
Browse files Browse the repository at this point in the history
Signed-off-by: neginraoof <neginmr@utexas.edu>
  • Loading branch information
neginraoof committed Jul 12, 2021
1 parent f77ff0c commit 02b3f4e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions onnx/checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,17 @@ void check_sequence(const SequenceProto& sequence, const CheckerContext& ctx) {
void check_optional(const OptionalProto& optional, const CheckerContext& ctx) {
enforce_has_field(optional, elem_type);
if (optional.elem_type() == OptionalProto::TENSOR) {
check_tensor(optional.tensor_value(), ctx);
if (optional.has_tensor_value())
check_tensor(optional.tensor_value(), ctx);
} else if (optional.elem_type() == OptionalProto::SPARSE_TENSOR) {
check_sparse_tensor(optional.sparse_tensor_value(), ctx);
if (optional.has_sparse_tensor_value())
check_sparse_tensor(optional.sparse_tensor_value(), ctx);
} else if (optional.elem_type() == OptionalProto::SEQUENCE) {
check_sequence(optional.sequence_value(), ctx);
if (optional.has_sequence_value())
check_sequence(optional.sequence_value(), ctx);
} else if (optional.elem_type() == OptionalProto::MAP) {
check_map(optional.map_value(), ctx);
if (optional.has_map_value())
check_map(optional.map_value(), ctx);
} else {
fail_check(
"Optional ( Structure name: ",
Expand Down

0 comments on commit 02b3f4e

Please sign in to comment.