当我使用 perf 进行分析时,_PyEval_EvalFrameDefaultCPU 使用率位于顶部。
但我不知道那是什么。我怎样才能避免这个功能?
我经常使用命令:
ack searchexpre -l --print0 | xargs -0 -n 1 sed -i -e sedexpression
Run Code Online (Sandbox Code Playgroud)
我想创建一个别名,如:
searchandreplace searchexpre sedexpression
Run Code Online (Sandbox Code Playgroud)
我怎么能这样做?
目前我有以下版本,但它是我的主要瓶颈,而且速度很慢.
def intToBinary(Input):
bStrInput = format(Input, "016b")
bStrInput = list(bStrInput)
bInput = list(map(int, bStrInput))
return bInput
Run Code Online (Sandbox Code Playgroud)
任何想法如何加快这段代码?
我在Tensorflow项目中使用它,用于整数的热编码转换.该函数采用2字节整数(在[0,65536)范围内)并输出值为0和1的整数列表:
>>> intToBinary(50411)
[1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1]
Run Code Online (Sandbox Code Playgroud)
结果传递给张量tInput = torch.tensor(bInput, dtype=torch.uint8).
我想使用 TBB parallel_for 我在我的代码中进行了测试
#include <tbb/parallel_for.h>
#include <tbb/blocked_range.h>
#include <tbb/tbb.h>
std::vector<std::tuple<std::string, unsigned int, std::string>> commands;
auto n = commands.size();
tbb::parallel_for(0, n, [&](int i) {
const auto &tuple = commands[i];
} );
Run Code Online (Sandbox Code Playgroud)
我的编译行是:
g++ -std=c++11 -Wall -Wextra -g -Og TextMiningApp.cpp -ltbb -o TextMiningApp
Run Code Online (Sandbox Code Playgroud)
我的编译器错误是:
TextMiningApp.cpp: In function ‘int main(int, char**)’:
TextMiningApp.cpp:184:7: error: no matching function for call to ‘parallel_for(int, long unsigned int&, main(int, char**)::<lambda(int)>)’
} );
^
In file included from TextMiningApp.cpp:15:0:
/usr/include/tbb/parallel_for.h:185:6: note: candidate: template<class Range, class Body> void tbb::parallel_for(const …Run Code Online (Sandbox Code Playgroud) python ×2
python-3.x ×2
bash ×1
binary ×1
c++ ×1
c++11 ×1
optimization ×1
perf ×1
performance ×1
profiling ×1
sh ×1
shell ×1
tbb ×1
templates ×1
zsh ×1