MCPcopy Create free account
hub / github.com/AllentDan/LibtorchTutorials / main

Function main

lesson2-TensorOperations/main.cpp:34–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34int main(int argc, char *argv[])
35{
36 auto b = torch::rand({3,4});
37 auto c = torch::rand({3,4});
38 std::cout<<b<<c<<b*c<<b/c<<b.mm(c.t());
39 auto cat = torch::cat({b,c},1);
40 auto stack = torch::stack({b,c},1);
41 std::cout<<b<<c<<cat<<stack;
42
43 //test torch
44 auto device = torch::Device(torch::kCUDA);
45 auto model = ConvReluBn(3,4,3);
46 model->to(device);
47 auto input = torch::zeros({1,3,12,12},torch::kFloat).to(device);
48 auto output = model->forward(input);
49 std::cout<<output<<std::endl;
50
51 //test opencv
52 cv::Mat image = cv::imread("C:\\Users\\Administrator\\Pictures\\1.jpg");
53 cv::Mat M(200, 200, CV_8UC3, cv::Scalar(0, 0, 255));
54 if(!M.data)
55 return 0;
56 cv::imshow("fff",image);
57 cv::imshow("ddd",M);
58 cv::waitKey(0);
59 cv::destroyAllWindows();
60 QApplication a(argc, argv);
61 MainWindow w;
62 w.show();
63 return a.exec();
64}

Callers

nothing calls this directly

Calls 1

forwardMethod · 0.45

Tested by

no test coverage detected