jason-li-831202 / YOLO-NAS-onnxruntime

This repo provides the C++ implementation of YOLO-NAS based on ONNXRuntime for performing object detection in real-time.Support float32/float16/int8 inference.
GNU General Public License v3.0
40 stars 7 forks source link

No instance of overloaded function "std::vector<_Ty, _Alloc>::push_back [with _Ty=Ort::Float16_t, _Alloc=std::allocator<Ort::Float16_t>]" matches the argument list #10

Open blackHorz opened 7 months ago

blackHorz commented 7 months ago

I am encountering the error in detector.cpp at this line

inputTensorValuesFp16.push_back(float32_to_float16(fp32));

I can see that the declaration of inputTensorValuesFp16 is std::vector<Ort::Float16_t> inputTensorValuesFp16;

Also the function float32_to_float16 returns uint16_t static uint16_t float32_to_float16(float& input_fp32)

Is this some bug? Or am i missing something here?

jason-li-831202 commented 7 months ago

inputTensorValuesFp16.push_back(float32_to_float16(fp32)); Typically, this is only used when the model is in fp16. If you use the following parameters during conversion by convertPytorchToONNX.py: --half : Convert fp32 to fp16 model.

could you please provide the full error message?

blackHorz commented 7 months ago

Hello Jason, Thanks for your feedback. But I encounter this error during build process.

Build started... 1>------ Build started: Project: YoloNAS, Configuration: Debug x64 ------ 1>detector.cpp 1>C:\Users\st34616.FFT-IT\Desktop\YoloNAS\YoloNAS\detector.cpp(63,78): warning C4244: 'argument': conversion from '_Ty' to '_Tp', possible loss of data 1> with 1> [ 1> _Ty=int64_t 1> ] 1> and 1> [ 1> _Tp=int 1> ] 1>C:\Users\st34616.FFT-IT\Desktop\YoloNAS\YoloNAS\detector.cpp(63,55): warning C4244: 'argument': conversion from '_Ty' to '_Tp', possible loss of data 1> with 1> [ 1> _Ty=int64_t 1> ] 1> and 1> [ 1> _Tp=int 1> ] 1>C:\Users\st34616.FFT-IT\Desktop\YoloNAS\YoloNAS\detector.cpp(65,47): warning C4244: '=': conversion from '_Ty' to 'int', possible loss of data 1> with 1> [ 1> _Ty=int64_t 1> ] 1>C:\Users\st34616.FFT-IT\Desktop\YoloNAS\YoloNAS\detector.cpp(66,46): warning C4244: '=': conversion from '_Ty' to 'int', possible loss of data 1> with 1> [ 1> _Ty=int64_t 1> ] 1>C:\Users\st34616.FFT-IT\Desktop\YoloNAS\YoloNAS\detector.cpp(270,69): error C2664: 'void std::vector<Ort::Float16_t,std::allocator<Ort::Float16_t>>::push_back(const _Ty &)': cannot convert argument 1 from 'uint16_t' to 'const _Ty &' 1> with 1> [ 1> _Ty=Ort::Float16_t 1> ] 1>C:\Users\st34616.FFT-IT\Desktop\YoloNAS\YoloNAS\detector.cpp(270,69): message : Reason: cannot convert from 'uint16_t' to 'const _Ty' 1> with 1> [ 1> _Ty=Ort::Float16_t 1> ] 1>C:\Users\st34616.FFT-IT\Desktop\YoloNAS\YoloNAS\detector.cpp(270,69): message : Constructor for struct 'Ort::Float16_t' is declared 'explicit' 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\vector(742,33): message : see declaration of 'std::vector<Ort::Float16_t,std::allocator<Ort::Float16_t>>::push_back' 1>Done building project "YoloNAS.vcxproj" -- FAILED.