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

CreateTensor with tensor size of bigger than 65536 causes BAD_ACCESS in Run on macOS #17884

Open
jie-chen opened this issue Oct 11, 2023 · 3 comments
Labels
platform:windows issues related to the Windows platform stale issues that have not been addressed in a while; categorized by a bot

Comments

@jie-chen
Copy link

Describe the issue

When the size of Output Tensor is bigger than 65536 (e.g. 131024), the BAD_ACCESS exception will be raised in Run(), this only happens on macOS. Windows does not have such problem.

To reproduce

auto memory_info = Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU);
auto input_tensor = Ort::Value::CreateTensor(memory_info, input.data(), input.size(), input_shape.data(), input_shape.size());
auto output_tensor = Ort::Value::CreateTensor(memory_info, output.data(), output.size(), //bigger than 65536
output_shape.data(), output_shape.size());
Ort::AllocatorWithDefaultOptions ort_alloc;
std::optionalOrt::AllocatedStringPtr input_name;
std::optionalOrt::AllocatedStringPtr output_name;
input_name.emplace(sessions[index]->GetInputNameAllocated(0, ort_alloc));
output_name.emplace(sessions[index]->GetOutputNameAllocated(0, ort_alloc));
const char* input_names[] = {input_name->get()};
char* output_names[] = {output_name->get()};
session->Run(Ort::RunOptions{nullptr}, input_names, &input_tensor, 1, output_names, &output_tensor, 1);

Urgency

No response

Platform

Mac

OS Version

14.0

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.14.0

ONNX Runtime API

C++

Architecture

ARM64

Execution Provider

Default CPU

Execution Provider Library Version

No response

@github-actions github-actions bot added the platform:windows issues related to the Windows platform label Oct 11, 2023
@yuslepukhin
Copy link
Member

Check whether the API expects size in bytes or in elements, and whether your shape matches it.

@jie-chen
Copy link
Author

Check whether the API expects size in bytes or in elements, and whether your shape matches it.

Hi, thanks for replying. Given the parameters passed in, it should be the first one of CreateTensor whose size is in elements (https://onnxruntime.ai/docs/api/c/struct_ort_1_1_value.html#a3898146b5fc35b838bd48db807dd6c8e).

As I mentioned this only happens on macOS with model with bigger output tensor size. Lowering the model output tensor size or running the same model on Windows won't raise the exception. Please see the details of exception in screenshot

image image

Copy link
Contributor

This issue has been automatically marked as stale due to inactivity and will be closed in 7 days if no further activity occurs. If further support is needed, please provide an update and/or more details.

@github-actions github-actions bot added the stale issues that have not been addressed in a while; categorized by a bot label Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:windows issues related to the Windows platform stale issues that have not been addressed in a while; categorized by a bot
Projects
None yet
Development

No branches or pull requests

2 participants