Tencent / TNN

TNN: developed by Tencent Youtu Lab and Guangying Lab, a uniform deep learning inference framework for mobile、desktop and server. TNN is distinguished by several outstanding features, including its cross-platform capability, high performance, model compression and code pruning. Based on ncnn and Rapidnet, TNN further strengthens the support and performance optimization for mobile devices, and also draws on the advantages of good extensibility and high performance from existed open source efforts. TNN has been deployed in multiple Apps from Tencent, such as Mobile QQ, Weishi, Pitu, etc. Contributions are welcome to work in collaborative with us and make TNN a better framework.
Other
4.37k stars 765 forks source link

#define OPERATOR clamp(in,(FLOAT4)(1.00000e-12f),(FLOAT4)(inff)) #1977

Open PanJinquan opened 7 months ago

PanJinquan commented 7 months ago

测试发现,转换Pytorch的normalize函数存在问题: y=torch.nn.functional.normalize(x, p=1, dim=1) 转换ONNX,opset_version=9,可以正常转换,但在推理时出现异常:

`#pragma OPENCL EXTENSION cl_khr_fp16 : enable ^

:73:18: error: use of undeclared identifier 'inff' FLOAT4 out = OPERATOR; ^ :28:59: note: expanded from here #define OPERATOR clamp(in,(FLOAT4)(1.00000e-12f),(FLOAT4)(inff)) ` ![image](https://github.com/Tencent/TNN/assets/31611317/f40374a2-2d44-435c-b829-68b5609a4b9b) 从问题看,是未能识别字符`inff`导致的异常,而正常情况下,无穷大应该表示为:`inf`,而不是`inff` 于是尝试改动tnnproto文件,将normalize层inf改为in,推理则正常了 ![image](https://github.com/Tencent/TNN/assets/31611317/731eef43-4fca-496d-af4b-ece9557c0e63) 我怀疑,TNN源码是不多加了f导致出现`inff`异常