Skip to content

libtorch C++, fasterrcnn_resnet50_fpn module.forward() Assert #3349

Open
@dc986

Description

@dc986

🐛 Bug

module.forward() launches Debug assert

File: minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp
Line: 966

Expression: __acrt_first_block == header

To Reproduce

Loaded scripted model with

torch::jit::script::Module module;
try {
	module = torch::jit::load(model_path);
}
catch (const c10::Error& e) {
	std::cerr << e.what();
	return -1;
}
module.eval();

Loaded image into tensor with

cv::Mat image; 
cv::Mat3f image_32fc3;

image = cv::imread(image_path, cv::IMREAD_COLOR);
auto h = image.rows;
auto w = image.cols;
auto c = image.channels();

image.convertTo(image_32fc3, CV_32FC3, 1.0f / 255.0f);
at::Tensor inputTensor = torch::from_blob(image_32fc3.data, { 1, h, w, c });
inputTensor = inputTensor.permute({ 0, 3, 1, 2 });
torch::DeviceType device_type = torch::kCPU;
inputTensor = inputTensor.to(device_type);

Both model and tensor seem to be loaded correctly anyway

std::vector<torch::jit::IValue>  input_to_net;
input_to_net.push_back(inputTensor);
at::Tensor output = module.forward(input_to_net).toTensor();

does not work.

call stack is:
image

Environment

OS: Microsoft Windows 7 Professional
Language: C++
CMake version: version 3.17.1
Python version: 3.7 (64-bit runtime)
Is CUDA available: N/A
numpy==1.18.5
torch==1.7.1+cpu
torchaudio==0.7.2
torchvision==nightly
Python version:

Additional context

cc @vfdev-5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions