pytorch学习笔记Ubuntu开发者专栏

windows端调用libTorch

2019-08-07  本文已影响2人  侠之大者_7d3f

libTorch下载

pytroch为windows端提供了2个版本的预编译好的libTorch动态链接库


测试环境


配置过程

以Debug版本的libTorch为例

image.png image.png image.png

c10.lib
caffe2.lib
caffe2_detectron_ops.lib
caffe2_module_test_dynamic.lib
clog.lib
cpuinfo.lib
foxi_dummy.lib
foxi_loader.lib
libprotobuf-lited.lib
libprotobufd.lib
libprotocd.lib
onnx.lib
onnxifi_dummy.lib
onnxifi_loader.lib
onnx_proto.lib
torch.lib


测试代码

#include<iostream>
#include<torch/script.h>

int main() {

    torch::Tensor t1 = torch::tensor({ 10,1,2 });
    std::cout << t1[0] << std::endl;

    system("pause");

}
image.png
#include<iostream>
#include<torch/script.h>

int main() {

    
    auto t1 = torch::tensor({ 1,2,3,4,5,6,7,8,9 }).reshape({ 3,3 });
    auto t2 = torch::tensor({ 1,0,2,6,1,1,5,3,2 }).reshape({ 3,3 });

    auto t3 = t1.mul(t2);

    std::cout << t3 << std::endl;
    

    system("pause");

}
image.png
上一篇下一篇

猜你喜欢

热点阅读