device.py 652 字节
Newer Older
Q
init  
qijun 已提交
1 2 3 4 5
"""
All util layers.
"""

from ..layer_helper import LayerHelper
Y
Yang Yu 已提交
6
from ..framework import unique_name
Y
Yang Yu 已提交
7
from ..registry import autodoc
Q
init  
qijun 已提交
8 9 10 11

__all__ = ['get_places']


Y
Yang Yu 已提交
12 13
@autodoc
def get_places(device_count=None, device_type=None):
Q
init  
qijun 已提交
14
    helper = LayerHelper('get_places', **locals())
Y
Yang Yu 已提交
15
    out_places = helper.create_variable(name=unique_name(helper.name + ".out"))
Y
Yang Yu 已提交
16 17 18 19 20 21
    attrs = dict()
    if device_count is not None:
        attrs['device_count'] = int(device_count)
    if device_type is not None:
        attrs['device_type'] = str(device_type)

Q
init  
qijun 已提交
22
    helper.append_op(
Y
Yang Yu 已提交
23
        type='get_places', outputs={"Out": [out_places]}, attrs=attrs)
Q
init  
qijun 已提交
24 25

    return out_places