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

[onert] Check Gather operand data type #14054

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

hseok-oh
Copy link
Contributor

This commit adds operation validation for Gather to check operand data type.

ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh hseok82.oh@samsung.com

This commit adds operation validation for Gather to check operand data type.

ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
@hseok-oh hseok-oh added the PR/ready for review It is ready to review. Please review it. label Sep 23, 2024
@hseok-oh hseok-oh requested a review from a team September 23, 2024 08:38

const auto input_type = operandType(input_index);
if (input_type == DataType::QUANT_GGML_Q4_0 || input_type == DataType::QUANT_GGML_Q8_0)
OP_REQUIRES(isValidType(output_index, {DataType::FLOAT32}));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe need to check output_type, not output_index.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isValidType() get index to check type.

Copy link
Contributor

@glistening glistening Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, isValidType uses index to check type. I didn't know. I confirmed isValidType checks the unerlying operand's type, not the parameter's type itself.

bool OperationValidator::isValidType(const OperandIndex &idx, const DataType &type)
{
  return operandType(idx) == type;
}

bool OperationValidator::isValidType(const OperandIndex &idx,
                                     std::initializer_list<DataType> valid_types)
{
  for (auto &&type_to_check : valid_types)
  {
    if (isValidType(idx, type_to_check))
    {
      return true;
    }
  }
  return false;
}

Copy link
Contributor

@glistening glistening left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hseok-oh hseok-oh merged commit 646c7f1 into Samsung:master Sep 24, 2024
9 checks passed
@hseok-oh hseok-oh deleted the check_gather_type branch September 24, 2024 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR/ready for review It is ready to review. Please review it.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants