device.py 1.3 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
from layer_function_generator import autodoc
Y
Yang Yu 已提交
19
from ..framework import unique_name
20
from ..layer_helper import LayerHelper
21
from ..annotations import deprecated
Q
init  
qijun 已提交
22

23
__all__ = []
Q
init  
qijun 已提交
24 25


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

    return out_places