zoukankan      html  css  js  c++  java
  • libtorch配置vs2017

    注意vs2013版本过低,建议用新版本vs

    1、解压libtorch

    进入lib查看拥有的lib文件

     2、添加系统环境(一般是bin,但是libtorch的dll都在lib目录里)

     3、VS新建项目,属性管理器窗口新建自己的属性表

     双击属性表

     

     

     4、解决提醒std冲突问题,项目——属性(注意不是双击属性表,重新从项目——属性进入,属性表设置了不起作用)

    属性->C/C++ ->常规->SDL检查->否

    属性->C/C++ ->语言->符号模式->否

    至此,release模式完毕。

    debug需要把lib目录中的所有dll拷贝到工程目录,或者https://www.cnblogs.com/chinahunter/p/11297778.html

    以后新建项目,加载自己的属性表,设置第4步即可。

    【测试代码】

    #include<iostream>
    #include<torch/script.h>
    int main() {
        torch::Tensor t1 = torch::tensor({ 10,1,2 });
        std::cout << t1[0] << std::endl;
        system("pause");
    }
    //2个Tensor计算矩阵乘法
    #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");
    }
  • 相关阅读:
    复习时间
    核反应堆
    假期编程
    剪花布条
    Atcoder Regular Contest 072 C Alice in linear land(思维题)
    xss攻击入门
    转发 DDoS攻防战 (一) : 概述
    XSS跨站脚本攻击
    sql注入
    关于阿里云图片识别接口的demo
  • 原文地址:https://www.cnblogs.com/xixixing/p/12842066.html
Copyright © 2011-2022 走看看