device.py 1.2 KB
Newer Older
D
dzhwinter 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
#  Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
Q
init  
qijun 已提交
14 15 16 17 18
"""
All util layers.
"""

from ..layer_helper import LayerHelper
Y
Yang Yu 已提交
19
from ..framework import unique_name
Y
Yang Yu 已提交
20
from ..registry import autodoc
Q
init  
qijun 已提交
21 22 23 24

__all__ = ['get_places']


Y
Yang Yu 已提交
25 26
@autodoc
def get_places(device_count=None, device_type=None):
Q
init  
qijun 已提交
27
    helper = LayerHelper('get_places', **locals())
Y
Yang Yu 已提交
28
    out_places = helper.create_variable(name=unique_name(helper.name + ".out"))
Y
Yang Yu 已提交
29 30 31 32 33 34
    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 已提交
35
    helper.append_op(
Y
Yang Yu 已提交
36
        type='get_places', outputs={"Out": [out_places]}, attrs=attrs)
Q
init  
qijun 已提交
37 38

    return out_places