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

Add additional safeguards when loading sparse tensor #19681

Open
TBrenetNV opened this issue Feb 28, 2024 · 0 comments
Open

Add additional safeguards when loading sparse tensor #19681

TBrenetNV opened this issue Feb 28, 2024 · 0 comments
Assignees
Labels
core runtime issues related to core runtime

Comments

@TBrenetNV
Copy link

Describe the issue

When loading a model that uses sparse tensor but with incompatible dense and indices tensor shape, onnxruntime will crash.
Additional checks should be added when loading sparse tensors to ensure data can actually be loaded and avoid reading array pass their end. Having those safeguards will also help providing better error feedback.

for (size_t i = 0; i < n_sparse_elements; ++i) {
There is no check that cur_index is at least of size n_sparse_elements * rank

To reproduce

Create an inference session with the attached ONNX model, a crash will occur.

import onnxruntime
sess = onnxruntime.InferenceSession('wrong_sparse_shape.onnx', providers=['CPUExecutionProvider'])
# Crash

wrong_sparse_shape.zip

Urgency

No response

Platform

Windows

OS Version

10

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.16.1

ONNX Runtime API

Python

Architecture

X64

Execution Provider

Default CPU

Execution Provider Library Version

No response

@wangyems wangyems added the core runtime issues related to core runtime label Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core runtime issues related to core runtime
Projects
None yet
Development

No branches or pull requests

3 participants