小编Rou*_*cha的帖子

如何遍历 bash 列表并获得 2 个元素的所有可能组合?

我有一个问题。我有一个包含许多文件的文件夹,我需要对我的文件中 2 个文件的所有组合执行一个程序。

到目前为止,我的 linux bash 脚本如下所示:

for ex in $(ls ${ex_folder}/${testset_folder} | sort -V ); do
   #ex is the name of my current file
   #I would like to do something like a nested loop where
   # ex2 goes from ex to the end of the list $(ls ${ex_folder}/${testset_folder} | sort -V )
done
Run Code Online (Sandbox Code Playgroud)

我是 bash 新手,在其他语言中,这看起来像:

for i in [0,N]
  for j in [i,N]
    #the combination would be i,j
Run Code Online (Sandbox Code Playgroud)

我的文件列表如下所示:

ex_10.1 ex_10.2 ex_10.3 ex_10.4 ex_10.5

我想对其中 2 个文件的所有组合执行一个 python …

bash shell

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

从@cuda.jit numba 函数中调用其他函数

我有一个添加了@cuda.jit 装饰器的函数。

@cuda.jit
def foo(x):
   bar(x[0])
   bar(x[1])
   bar(x[2])

def bar(x):
  # Some routine
Run Code Online (Sandbox Code Playgroud)

我不想将 bar 复制到 foo 的主体中,因为这会使代码变得笨拙和丑陋。

Numba 的 cuda.jit 如何处理这个问题?编译期间函数是否内联?酒吧需要jitt吗?

如果是这样,它将调用其他线程,我发现这对于仅超过 3 个元素的计算来说太过分了......

我也认为 cuda 内核也不能调用其他 cuda 内核。

我是 numba/cuda 的新手,所以如果在理解这里有一些根本性的错误,请原谅我。

python jit cuda numba

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

标签 统计

bash ×1

cuda ×1

jit ×1

numba ×1

python ×1

shell ×1