create functions of Pelemay options
zacky1972 opened this issue · comments
Susumu Yamazaki commented
Would you implement to select whether CPU or GPU executes the code?
There are two functions: Pelemay.to_gpu/1
and Pelemay.to_cpu/1
.
They are defined as follows:
defmodule Pelemay
def to_gpu(list), do: list
def to_cpu(list), do: list
end
In defpelemay
, Pelemay.to_gpu/1
and Pelemay.to_cpu/1
will work as follows:
defpelemay do
def func1(list) do
list
|> Enum.map(& &1 + 1) # this code will be run on CPU.
|> Pelemay.to_gpu()
|> Enum.map(& &1 * 2) # this code will be run on GPU.
# the return value will be returned to CPU.
end
def func2(list) do
list
|> Enum.map(& &1 + 1) # this code will be run on CPU.
|> Pelemay.to_gpu()
|> Enum.map(& &1 * 2) # this code will be run on GPU.
|> Pelemay.to_cpu()
|> Enum.map(& &1 + 1) # this code will be run on CPU.
end
end
This issue scope is only to create hooks.
The branch name is pelemay_options