device.py 1.4 KB
Newer Older
1
#   Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
D
dzhwinter 已提交
2
#
D
dzhwinter 已提交
3 4 5
# 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
D
dzhwinter 已提交
6
#
D
dzhwinter 已提交
7
#     http://www.apache.org/licenses/LICENSE-2.0
D
dzhwinter 已提交
8
#
D
dzhwinter 已提交
9 10 11 12 13
# 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
"""
All util layers.
"""

18 19
from __future__ import print_function

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

25
__all__ = []
Q
init  
qijun 已提交
26 27


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

    return out_places