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

Check bias shape in operator Conv #22760

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

xadupre
Copy link
Member

@xadupre xadupre commented Nov 7, 2024

Description

The bias shape is not checked as the other shapes when operator Conv is called. That could lead to unwanted memory access.

Motivation and Context

Catch potential memory issue.

Status ValidateInputShape(const Tensor* input, const Tensor* weight, const Tensor* bias = nullptr) const {
if (bias == nullptr)
return ValidateInputShape(input->Shape(), weight->Shape());
return ValidateInputShape(input->Shape(), weight->Shape(), bias->Shape());
Copy link
Contributor

@tianleiwu tianleiwu Nov 7, 2024

Choose a reason for hiding this comment

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

Need pass input_channels_last and weight_challels_last to support NHWC (channel last) Conv? Or maybe add a comment here that CPU only support NCHW right now.

bool weight_channels_last = false) const {
Status status = ValidateInputShape(input_shape, weight_shape, input_channels_last, weight_channels_last);
if (status.IsOK()) {
if (bias_shape.Size() > 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

bias_shape.Size() != 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants