VE

class orchespy.devicetype.VE(device_id=0)[source]

Device type class for VE

Specify as the target of the orchespy’s decorator or function.

Examples

Specify VE as the target of decorator. The function exec_on_ve() will be execute on VE.

>>> from orchespy.devicetype import VE
>>> from orchespy import device
>>> import numpy
>>>
>>> @device(VE)
... def exec_on_ve(x, y):
...     return x * y
>>>
>>> x = numpy.ones((2,2))
>>> y = numpy.ones((2,2))
>>> z = exec_on_ve(x, y)

If you have multiple identical devices, you can specify any device for the decorator. Also, when operating within the device decorator function, It is necessary to switch the output device in advance.

>>> from orchespy.devicetype import VE
>>> from orchespy import device
>>> import numpy
>>> import nlcpy as vp
>>>
>>> @device(VE(1))
... def exec_on_ve(x, y):
...     return x * y
...
>>> x = numpy.ones((2,2)) * 3
>>> y = numpy.ones((2,2)) * 2
>>> vp.venode.VE(1).use()
<VE node logical_id=1, physical_id=1>
>>> z = exec_on_ve(x, y)
>>> z.venode.id
1
>>> type(z)
<class 'nlcpy.core.core.ndarray'>
>>> z
array([[6., 6.],
       [6., 6.]])