Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c80af6ff
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
c80af6ff
编写于
1月 22, 2018
作者:
Y
Yu Yang
提交者:
GitHub
1月 22, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7721 from reyoung/feature/rename_fluid
Move registery.py to layers module
上级
54a4696f
5c26f608
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
34 addition
and
35 deletion
+34
-35
python/paddle/v2/fluid/layers/control_flow.py
python/paddle/v2/fluid/layers/control_flow.py
+6
-6
python/paddle/v2/fluid/layers/device.py
python/paddle/v2/fluid/layers/device.py
+3
-3
python/paddle/v2/fluid/layers/layer_function_generator.py
python/paddle/v2/fluid/layers/layer_function_generator.py
+16
-11
python/paddle/v2/fluid/layers/ops.py
python/paddle/v2/fluid/layers/ops.py
+2
-3
python/paddle/v2/fluid/tests/test_registry.py
python/paddle/v2/fluid/tests/test_registry.py
+7
-12
未找到文件。
python/paddle/v2/fluid/layers/control_flow.py
浏览文件 @
c80af6ff
...
@@ -11,13 +11,13 @@
...
@@ -11,13 +11,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
contextlib
from
..layer_helper
import
LayerHelper
,
unique_name
from
layer_function_generator
import
autodoc
from
..framework
import
Program
,
Variable
,
Operator
from
..
import
core
from
tensor
import
assign
,
fill_constant
from
tensor
import
assign
,
fill_constant
import
contextlib
from
..
import
core
from
..registry
import
autodoc
from
..framework
import
Program
,
Variable
,
Operator
from
..layer_helper
import
LayerHelper
,
unique_name
__all__
=
[
__all__
=
[
'split_lod_tensor'
,
'split_lod_tensor'
,
...
@@ -1477,7 +1477,7 @@ class DynamicRNN(object):
...
@@ -1477,7 +1477,7 @@ class DynamicRNN(object):
method
))
method
))
@
autodoc
@
autodoc
()
def
reorder_lod_tensor_by_rank
(
x
,
rank_table
):
def
reorder_lod_tensor_by_rank
(
x
,
rank_table
):
helper
=
LayerHelper
(
'reorder_lod_tensor_by_rank'
,
**
locals
())
helper
=
LayerHelper
(
'reorder_lod_tensor_by_rank'
,
**
locals
())
helper
.
is_instance
(
'x'
,
Variable
)
helper
.
is_instance
(
'x'
,
Variable
)
...
...
python/paddle/v2/fluid/layers/device.py
浏览文件 @
c80af6ff
...
@@ -15,14 +15,14 @@
...
@@ -15,14 +15,14 @@
All util layers.
All util layers.
"""
"""
from
..layer_helper
import
LayerHelper
from
layer_function_generator
import
autodoc
from
..framework
import
unique_name
from
..framework
import
unique_name
from
..
registry
import
autodoc
from
..
layer_helper
import
LayerHelper
__all__
=
[
'get_places'
]
__all__
=
[
'get_places'
]
@
autodoc
@
autodoc
()
def
get_places
(
device_count
=
None
,
device_type
=
None
):
def
get_places
(
device_count
=
None
,
device_type
=
None
):
helper
=
LayerHelper
(
'get_places'
,
**
locals
())
helper
=
LayerHelper
(
'get_places'
,
**
locals
())
out_places
=
helper
.
create_variable
(
name
=
unique_name
(
helper
.
name
+
".out"
))
out_places
=
helper
.
create_variable
(
name
=
unique_name
(
helper
.
name
+
".out"
))
...
...
python/paddle/v2/fluid/
registry
.py
→
python/paddle/v2/fluid/
layers/layer_function_generator
.py
浏览文件 @
c80af6ff
...
@@ -13,17 +13,19 @@
...
@@ -13,17 +13,19 @@
# limitations under the License.
# limitations under the License.
import
re
import
re
import
cStringIO
import
cStringIO
import
warnings
import
functools
import
functools
import
inspect
import
warnings
from
..
import
proto
import
proto.framework_pb2
as
framework_pb2
framework_pb2
=
proto
.
framework_pb2
from
framework
import
OpProtoHolder
,
Variable
,
Program
,
Operator
from
paddle.v2.fluid.layer_helper
import
LayerHelper
,
unique_name
from
..framework
import
OpProtoHolder
,
Variable
from
..layer_helper
import
LayerHelper
__all__
=
[
__all__
=
[
'deprecated'
,
'deprecated'
,
'
register_layer
'
,
'
generate_layer_fn
'
,
'autodoc'
,
'autodoc'
,
]
]
...
@@ -96,7 +98,7 @@ def _generate_doc_string_(op_proto):
...
@@ -96,7 +98,7 @@ def _generate_doc_string_(op_proto):
return
buf
.
getvalue
()
return
buf
.
getvalue
()
def
register_layer
(
op_type
):
def
generate_layer_fn
(
op_type
):
"""Register the Python layer for an Operator.
"""Register the Python layer for an Operator.
Args:
Args:
...
@@ -207,7 +209,10 @@ def deprecated(func_or_class):
...
@@ -207,7 +209,10 @@ def deprecated(func_or_class):
return
func_wrapper
return
func_wrapper
def
autodoc
(
func
):
def
autodoc
(
comment
=
""
):
func
.
__doc__
=
_generate_doc_string_
(
OpProtoHolder
.
instance
().
get_op_proto
(
def
__impl__
(
func
):
func
.
__name__
))
func
.
__doc__
=
_generate_doc_string_
(
OpProtoHolder
.
instance
(
).
get_op_proto
(
func
.
__name__
))
+
comment
return
func
return
func
return
__impl__
python/paddle/v2/fluid/layers/ops.py
浏览文件 @
c80af6ff
...
@@ -11,8 +11,7 @@
...
@@ -11,8 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
from
layer_function_generator
import
generate_layer_fn
from
..registry
import
register_layer
__activations__
=
[
__activations__
=
[
'sigmoid'
,
'sigmoid'
,
...
@@ -53,4 +52,4 @@ __all__ = [
...
@@ -53,4 +52,4 @@ __all__ = [
]
+
__activations__
]
+
__activations__
for
_OP
in
set
(
__all__
):
for
_OP
in
set
(
__all__
):
globals
()[
_OP
]
=
register_layer
(
_OP
)
globals
()[
_OP
]
=
generate_layer_fn
(
_OP
)
python/paddle/v2/fluid/tests/test_registry.py
浏览文件 @
c80af6ff
...
@@ -11,26 +11,21 @@
...
@@ -11,26 +11,21 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
unittest
import
unittest
import
warnings
import
paddle.v2.fluid
as
fluid
import
paddle.v2.fluid
as
fluid
import
paddle.v2.fluid.framework
as
framework
import
numpy
as
np
import
paddle.v2.fluid.layers
as
layers
import
decorators
import
paddle.v2.fluid.registry
as
registry
class
TestRegistry
(
unittest
.
TestCase
):
class
TestRegistry
(
unittest
.
TestCase
):
@
decorators
.
prog_scope
()
def
test_registry_layer
(
self
):
def
test_registry_layer
(
self
):
self
.
layer_type
=
"mean"
program
=
framework
.
Program
()
x
=
fluid
.
layers
.
data
(
name
=
'X'
,
shape
=
[
10
,
10
],
dtype
=
'float32'
)
x
=
fluid
.
layers
.
data
(
name
=
'X'
,
shape
=
[
10
,
10
],
dtype
=
'float32'
)
output
=
layers
.
mean
(
x
)
output
=
fluid
.
layers
.
mean
(
x
=
x
)
place
=
fluid
.
CPUPlace
()
place
=
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
place
)
exe
=
fluid
.
Executor
(
place
)
X
=
np
.
random
.
random
((
10
,
10
)).
astype
(
"float32"
)
X
=
np
.
random
.
random
((
10
,
10
)).
astype
(
"float32"
)
mean_out
=
exe
.
run
(
program
,
feed
=
{
"X"
:
X
},
fetch_list
=
[
output
])
mean_out
=
exe
.
run
(
feed
=
{
"X"
:
X
},
fetch_list
=
[
output
])
self
.
assertAlmostEqual
(
np
.
mean
(
X
),
mean_out
)
self
.
assertAlmostEqual
(
np
.
mean
(
X
),
mean_out
[
0
]
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录