小编sat*_*tya的帖子

什么是Pytorch中的volatile变量

Pytorch中变量的volatile属性是什么?这是一个用于在PyTorch中定义变量的示例代码.

datatensor = Variable(data, volatile=True)
Run Code Online (Sandbox Code Playgroud)

pytorch

15
推荐指数
2
解决办法
1万
查看次数

C++中的std :: thread库是否支持嵌套线程?

我想使用std::thread像这样的库在C++中创建嵌套线程.

#include<iostream>
#include<thread>
#include<vector>
using namespace std;

void innerfunc(int inp)
{
    cout << inp << endl;
}
void outerfunc(int inp)
{
    thread * threads = new thread[inp];
    for (int i = 0; i < inp; i++)
        threads[i] = thread(innerfunc, i);
    for (int i = 0; i < inp; i++)
        threads[i].join();
    delete[] threads;
}
int main()
{
     int inp = 0;
     thread t1 = thread(outerfunc,2);
     thread t2 = thread(outerfunc,3);
     t1.join();
     t2.join();
}
Run Code Online (Sandbox Code Playgroud)

我可以安全地这样做吗?我担心是否join()正常工作.

c++ multithreading c++11 stdthread

1
推荐指数
1
解决办法
1056
查看次数

标签 统计

c++ ×1

c++11 ×1

multithreading ×1

pytorch ×1

stdthread ×1