We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
class Model(nn.Module): def __init__(self): super(Model, self).__init__() def forward(self, x): i32 = torch.tensor([2, 1, 3, 4], dtype=torch.int32) i64 = torch.tensor([2, 1, 3, 4], dtype=torch.int64) return i32, i64
pnnx demo.pt inputshape=[32] 经过上述转换,ncnn.param内容为
7767517 2 2 MemoryData pnnx_fold_11 0 1 out0 0=4 MemoryData pnnx_fold_22 0 1 out1 0=4
ncnn.bin文件内容为
最终,在cpp中提取时,i64数据输出错误: int|int32_t ---> [2,0,1,0] int64_t ---> [2,1,2,0]
torch.gather实现上,Python强制要求i64类型,然后经pnnx后,ncnn无法正确输出int结果
The text was updated successfully, but these errors were encountered:
#include "net.h" int main() { auto net = ncnn::Net(); net.load_param("demo.ncnn.param"); net.load_model("demo.ncnn.bin"); ncnn::Extractor ex = net.create_extractor(); ncnn::Mat out0, out1; ex.extract("out0", out0); ex.extract("out1", out1); int* p = out0; printf("out0 = %d,%d,%d,%d\n", p[0], p[1], p[2], p[3]); int* p1 = out1; printf("out1 = %d,%d,%d,%d\n", p1[0], p1[1], p1[2], p1[3]); return 0; }
输出:
out0 = 2,1,3,4 # i32正确输出 out1 = 2,0,1,0 # i64 错误输出
结论,pnnx存档时,i64应该强制转i32存档。如果不作为Memorydata存档,那么输入i64也要做一次i32转换
Sorry, something went wrong.
fix: #5881
No branches or pull requests
复现步骤
pnnx demo.pt inputshape=[32]
经过上述转换,ncnn.param内容为
ncnn.bin文件内容为
最终,在cpp中提取时,i64数据输出错误:
int|int32_t ---> [2,0,1,0]
int64_t ---> [2,1,2,0]
故障来源
torch.gather实现上,Python强制要求i64类型,然后经pnnx后,ncnn无法正确输出int结果
The text was updated successfully, but these errors were encountered: