Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
81f3f6b5
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 2 年 前同步成功
通知
2325
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
未验证
提交
81f3f6b5
编写于
3月 20, 2023
作者:
A
Ainavo
提交者:
GitHub
3月 20, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CodeStyle][UP008] remove super call with parameters (#51812)
* remove super call with parameters * fix bug
上级
79bc9c0d
变更
68
隐藏空白更改
内联
并排
Showing
68 changed file
with
96 addition
and
95 deletion
+96
-95
paddle/fluid/imperative/README.md
paddle/fluid/imperative/README.md
+3
-3
pyproject.toml
pyproject.toml
+1
-0
python/paddle/device/__init__.py
python/paddle/device/__init__.py
+1
-1
python/paddle/distributed/fleet/recompute/recompute.py
python/paddle/distributed/fleet/recompute/recompute.py
+1
-1
python/paddle/distributed/fleet/utils/__init__.py
python/paddle/distributed/fleet/utils/__init__.py
+1
-1
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3.py
...nittests/collective/fleet/dygraph_group_sharded_stage3.py
+3
-3
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3_eager.py
...ts/collective/fleet/dygraph_group_sharded_stage3_eager.py
+1
-1
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_save_for_auto_infer.py
...unittests/collective/fleet/dygraph_save_for_auto_infer.py
+3
-3
python/paddle/fluid/tests/unittests/collective/fleet/fused_attention_pass_with_mp.py
...nittests/collective/fleet/fused_attention_pass_with_mp.py
+1
-1
python/paddle/fluid/tests/unittests/collective/fleet/test_dygraph_recompute_for_eager.py
...ests/collective/fleet/test_dygraph_recompute_for_eager.py
+1
-1
python/paddle/fluid/tests/unittests/distributed_passes/test_dist_fuse_gemm_epilogue_pass.py
...s/distributed_passes/test_dist_fuse_gemm_epilogue_pass.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_backward_without_params.py
...ittests/dygraph_to_static/test_backward_without_params.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cinn.py
...ddle/fluid/tests/unittests/dygraph_to_static/test_cinn.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cinn_prim.py
...fluid/tests/unittests/dygraph_to_static/test_cinn_prim.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cinn_prim_gelu.py
.../tests/unittests/dygraph_to_static/test_cinn_prim_gelu.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cinn_prim_layer_norm.py
.../unittests/dygraph_to_static/test_cinn_prim_layer_norm.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cinn_prim_mean.py
.../tests/unittests/dygraph_to_static/test_cinn_prim_mean.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_convert_call.py
...id/tests/unittests/dygraph_to_static/test_convert_call.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_program_translator.py
...ts/unittests/dygraph_to_static/test_program_translator.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_unuseful_inputs.py
...tests/unittests/dygraph_to_static/test_unuseful_inputs.py
+2
-2
python/paddle/fluid/tests/unittests/ipu/test_modelruntime_ipu.py
...paddle/fluid/tests/unittests/ipu/test_modelruntime_ipu.py
+1
-1
python/paddle/fluid/tests/unittests/ir/inference/test_trt_inference_predictor.py
...ts/unittests/ir/inference/test_trt_inference_predictor.py
+2
-2
python/paddle/fluid/tests/unittests/ir/inference/test_trt_support_nhwc_pass.py
...ests/unittests/ir/inference/test_trt_support_nhwc_pass.py
+1
-1
python/paddle/fluid/tests/unittests/prim/composite_ops/test_composite_batch_norm.py
...unittests/prim/composite_ops/test_composite_batch_norm.py
+1
-1
python/paddle/fluid/tests/unittests/prim/composite_ops/test_composite_layer_norm.py
...unittests/prim/composite_ops/test_composite_layer_norm.py
+1
-1
python/paddle/fluid/tests/unittests/prim/composite_ops/test_composite_softmax.py
...ts/unittests/prim/composite_ops/test_composite_softmax.py
+1
-1
python/paddle/fluid/tests/unittests/prim/model/bert.py
python/paddle/fluid/tests/unittests/prim/model/bert.py
+7
-7
python/paddle/fluid/tests/unittests/prim/prim/flags/test_prim_flags_case.py
...d/tests/unittests/prim/prim/flags/test_prim_flags_case.py
+1
-1
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_add_grad.py
...ests/unittests/prim/prim/vjp/static/test_comp_add_grad.py
+1
-1
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_add_tanh_grad.py
...unittests/prim/prim/vjp/static/test_comp_add_tanh_grad.py
+1
-1
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_cast_grad.py
...sts/unittests/prim/prim/vjp/static/test_comp_cast_grad.py
+1
-1
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_div_grad.py
...ests/unittests/prim/prim/vjp/static/test_comp_div_grad.py
+1
-1
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_gather_grad.py
...s/unittests/prim/prim/vjp/static/test_comp_gather_grad.py
+1
-1
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_reshape_grad.py
.../unittests/prim/prim/vjp/static/test_comp_reshape_grad.py
+1
-1
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_sqrt_grad.py
...sts/unittests/prim/prim/vjp/static/test_comp_sqrt_grad.py
+1
-1
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_sub_grad.py
...ests/unittests/prim/prim/vjp/static/test_comp_sub_grad.py
+1
-1
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_tanh_grad.py
...sts/unittests/prim/prim/vjp/static/test_comp_tanh_grad.py
+1
-1
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_transpose_grad.py
...nittests/prim/prim/vjp/static/test_comp_transpose_grad.py
+1
-1
python/paddle/fluid/tests/unittests/prim_op_test.py
python/paddle/fluid/tests/unittests/prim_op_test.py
+1
-1
python/paddle/fluid/tests/unittests/test_activation_op.py
python/paddle/fluid/tests/unittests/test_activation_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_fused_attention_pass.py
...paddle/fluid/tests/unittests/test_fused_attention_pass.py
+1
-1
python/paddle/fluid/tests/unittests/test_lbfgs_v2.py
python/paddle/fluid/tests/unittests/test_lbfgs_v2.py
+1
-1
python/paddle/fluid/tests/unittests/test_rnn_decode_api.py
python/paddle/fluid/tests/unittests/test_rnn_decode_api.py
+4
-4
python/paddle/fluid/tests/unittests/xpu/parallel_dygraph_dataparallel_with_pylayer.py
...ittests/xpu/parallel_dygraph_dataparallel_with_pylayer.py
+1
-1
python/paddle/fluid/tests/unittests/xpu/parallel_dygraph_gradient_check.py
...id/tests/unittests/xpu/parallel_dygraph_gradient_check.py
+1
-1
python/paddle/fluid/tests/unittests/xpu/parallel_dygraph_gradient_check_in_eager_mode.py
...ests/xpu/parallel_dygraph_gradient_check_in_eager_mode.py
+1
-1
python/paddle/fluid/tests/unittests/xpu/test_recompute_op_xpu.py
...paddle/fluid/tests/unittests/xpu/test_recompute_op_xpu.py
+1
-1
python/paddle/incubate/optimizer/lbfgs.py
python/paddle/incubate/optimizer/lbfgs.py
+1
-1
python/paddle/nn/quant/format.py
python/paddle/nn/quant/format.py
+5
-5
python/paddle/nn/quant/qat/conv.py
python/paddle/nn/quant/qat/conv.py
+1
-1
python/paddle/nn/quant/qat/linear.py
python/paddle/nn/quant/qat/linear.py
+1
-1
python/paddle/nn/quant/stub.py
python/paddle/nn/quant/stub.py
+3
-3
python/paddle/quantization/base_observer.py
python/paddle/quantization/base_observer.py
+1
-1
python/paddle/quantization/base_quanter.py
python/paddle/quantization/base_quanter.py
+1
-1
python/paddle/quantization/config.py
python/paddle/quantization/config.py
+4
-4
python/paddle/quantization/factory.py
python/paddle/quantization/factory.py
+1
-1
python/paddle/quantization/observers/abs_max.py
python/paddle/quantization/observers/abs_max.py
+2
-2
python/paddle/quantization/ptq.py
python/paddle/quantization/ptq.py
+1
-1
python/paddle/quantization/qat.py
python/paddle/quantization/qat.py
+1
-1
python/paddle/quantization/quanters/abs_max.py
python/paddle/quantization/quanters/abs_max.py
+2
-2
python/paddle/quantization/wrapper.py
python/paddle/quantization/wrapper.py
+1
-1
python/paddle/tests/quantization/test_customized_quanter.py
python/paddle/tests/quantization/test_customized_quanter.py
+1
-1
python/paddle/tests/quantization/test_ptq.py
python/paddle/tests/quantization/test_ptq.py
+1
-1
python/paddle/tests/quantization/test_qat.py
python/paddle/tests/quantization/test_qat.py
+1
-1
python/paddle/tests/quantization/test_quant.py
python/paddle/tests/quantization/test_quant.py
+1
-1
python/paddle/tests/quantization/test_stub.py
python/paddle/tests/quantization/test_stub.py
+1
-1
python/paddle/utils/install_check.py
python/paddle/utils/install_check.py
+1
-1
python/paddle/vision/models/_utils.py
python/paddle/vision/models/_utils.py
+1
-1
未找到文件。
paddle/fluid/imperative/README.md
浏览文件 @
81f3f6b5
...
...
@@ -139,7 +139,7 @@ TODO
import
paddle
class
MyLayer
(
fluid
.
imperative
.
Layer
):
def
__init__
(
self
):
super
(
MyLayer
,
self
).
__init__
()
super
().
__init__
()
def
forward
(
self
,
inputs
):
x
=
fluid
.
layers
.
relu
(
inputs
)
...
...
@@ -150,7 +150,7 @@ class MyLayer(fluid.imperative.Layer):
class
MyPyLayer
(
fluid
.
imperative
.
PyLayer
):
def
__init__
(
self
):
super
(
MyPyLayer
,
self
).
__init__
()
super
().
__init__
()
@
staticmethod
def
forward
(
inputs
):
...
...
@@ -172,7 +172,7 @@ with fluid.imperative.guard():
class
MLP
(
fluid
.
Layer
):
def
__init__
(
self
,
input_size
):
super
(
MLP
,
self
).
__init__
()
super
().
__init__
()
self
.
_linear1
=
Linear
(
input_size
,
3
,
fluid
.
ParamAttr
(
...
...
pyproject.toml
浏览文件 @
81f3f6b5
...
...
@@ -37,6 +37,7 @@ select = [
"UP003"
,
"UP004"
,
"UP007"
,
"UP008"
,
"UP010"
,
"UP011"
,
"UP013"
,
...
...
python/paddle/device/__init__.py
浏览文件 @
81f3f6b5
...
...
@@ -840,7 +840,7 @@ class Stream:
def
__eq__
(
self
,
o
):
if
isinstance
(
o
,
Stream
):
return
super
(
Stream
,
self
).
__eq__
(
o
)
return
super
().
__eq__
(
o
)
return
False
def
__hash__
(
self
):
...
...
python/paddle/distributed/fleet/recompute/recompute.py
浏览文件 @
81f3f6b5
...
...
@@ -379,7 +379,7 @@ def recompute(function, *args, **kwargs):
def __init__(self, input_size=10,
recompute_blocks=[1, 3],
recompute_kwargs={}):
super(
Naive_fc_net, self
).__init__()
super().__init__()
self.recompute_blocks = recompute_blocks
self.recompute_kwargs = recompute_kwargs
self.runfunc0 = get_fc_block(0, input_size, is_last=False)
...
...
python/paddle/distributed/fleet/utils/__init__.py
浏览文件 @
81f3f6b5
...
...
@@ -79,7 +79,7 @@ def recompute(function, *args, **kwargs):
def __init__(self, input_size=10,
recompute_blocks=[1, 3],
recompute_kwargs={}):
super(
Naive_fc_net, self
).__init__()
super().__init__()
self.recompute_blocks = recompute_blocks
self.recompute_kwargs = recompute_kwargs
self.runfunc0 = get_fc_block(0, input_size, is_last=False)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3.py
浏览文件 @
81f3f6b5
...
...
@@ -61,7 +61,7 @@ class MLP(paddle.nn.Layer):
class
Encoder
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
encoder
):
super
(
Encoder
,
self
).
__init__
()
super
().
__init__
()
self
.
first_stage
=
paddle
.
nn
.
Linear
(
1024
,
1024
)
self
.
encoder
=
encoder
...
...
@@ -73,7 +73,7 @@ class Encoder(paddle.nn.Layer):
class
Decoder
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
decoder
):
super
(
Decoder
,
self
).
__init__
()
super
().
__init__
()
self
.
decoder
=
decoder
self
.
final_stage
=
paddle
.
nn
.
Linear
(
1024
,
1024
)
self
.
group_norm
=
paddle
.
nn
.
GroupNorm
(
64
,
1024
)
...
...
@@ -87,7 +87,7 @@ class Decoder(paddle.nn.Layer):
class
SpecialModel
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
SpecialModel
,
self
).
__init__
()
super
().
__init__
()
self
.
shared
=
paddle
.
nn
.
Linear
(
1024
,
1024
,
bias_attr
=
False
)
self
.
encoder
=
Encoder
(
self
.
shared
)
self
.
decoder
=
Decoder
(
self
.
shared
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3_eager.py
浏览文件 @
81f3f6b5
...
...
@@ -25,7 +25,7 @@ np.random.seed(2022)
class
Model
(
nn
.
Layer
):
def
__init__
(
self
):
super
(
Model
,
self
).
__init__
()
super
().
__init__
()
self
.
first_stage
=
nn
.
Linear
(
4096
,
4096
,
bias_attr
=
False
)
self
.
center_stage
=
nn
.
Linear
(
4096
,
4096
)
self
.
center_stage
.
weight
.
stop_gradient
=
True
...
...
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_save_for_auto_infer.py
浏览文件 @
81f3f6b5
...
...
@@ -77,7 +77,7 @@ class MLP_pipe(PipelineLayer):
),
LayerDesc
(
Linear
,
in_features
=
linear_size
,
out_features
=
10
),
]
super
(
MLP_pipe
,
self
).
__init__
(
super
().
__init__
(
desc
,
num_stages
=
2
,
loss_fn
=
paddle
.
nn
.
CrossEntropyLoss
(),
...
...
@@ -93,7 +93,7 @@ class MLP_Hybrid(paddle.nn.Layer):
param_attr
=
None
,
bias_attr
=
None
,
):
super
(
MLP_Hybrid
,
self
).
__init__
()
super
().
__init__
()
self
.
embedding
=
VocabParallelEmbedding
(
embedding_size
,
linear_size
)
self
.
_linear1
=
RowParallelLinear
(
linear_size
,
linear_size
,
has_bias
=
True
,
input_is_parallel
=
True
...
...
@@ -128,7 +128,7 @@ class MLP(paddle.nn.Layer):
param_attr
=
None
,
bias_attr
=
None
,
):
super
(
MLP
,
self
).
__init__
()
super
().
__init__
()
self
.
embedding
=
paddle
.
nn
.
Embedding
(
embedding_size
,
linear_size
)
self
.
_linear1
=
Linear
(
linear_size
,
linear_size
)
self
.
_linear2
=
Linear
(
linear_size
,
linear_size
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/fused_attention_pass_with_mp.py
浏览文件 @
81f3f6b5
...
...
@@ -35,7 +35,7 @@ class MultiHeadAttentionWithMP(paddle.nn.Layer):
pre_ln
=
True
,
attn_dropout
=
True
,
):
super
(
MultiHeadAttentionWithMP
,
self
).
__init__
()
super
().
__init__
()
self
.
embed_dim
=
embed_dim
self
.
kdim
=
embed_dim
self
.
vdim
=
embed_dim
...
...
python/paddle/fluid/tests/unittests/collective/fleet/test_dygraph_recompute_for_eager.py
浏览文件 @
81f3f6b5
...
...
@@ -23,7 +23,7 @@ from paddle.distributed.fleet.utils import recompute
class
Model
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
block_idx
,
input_size
,
is_last
=
False
):
super
(
Model
,
self
).
__init__
()
super
().
__init__
()
block_name
=
"block_"
+
str
(
block_idx
)
self
.
block
=
paddle
.
nn
.
Sequential
(
(
...
...
python/paddle/fluid/tests/unittests/distributed_passes/test_dist_fuse_gemm_epilogue_pass.py
浏览文件 @
81f3f6b5
...
...
@@ -37,7 +37,7 @@ def verify_op_count(op_types, op_name, target_count):
class
MultiFCLayer
(
nn
.
Layer
):
def
__init__
(
self
,
hidden
,
Activation
):
super
(
MultiFCLayer
,
self
).
__init__
()
super
().
__init__
()
self
.
linear1
=
paddle
.
nn
.
Linear
(
hidden
,
4
*
hidden
)
self
.
linear2
=
paddle
.
nn
.
Linear
(
4
*
hidden
,
hidden
)
self
.
linear3
=
paddle
.
nn
.
Linear
(
hidden
,
hidden
)
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_backward_without_params.py
浏览文件 @
81f3f6b5
...
...
@@ -21,7 +21,7 @@ import paddle
class
Net
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
Net
,
self
).
__init__
()
super
().
__init__
()
@
paddle
.
jit
.
to_static
def
forward
(
self
,
x
):
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cinn.py
浏览文件 @
81f3f6b5
...
...
@@ -21,7 +21,7 @@ import paddle
class
Net
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
Net
,
self
).
__init__
()
super
().
__init__
()
self
.
relu
=
paddle
.
nn
.
functional
.
relu
self
.
fc
=
paddle
.
nn
.
Linear
(
4
,
4
)
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cinn_prim.py
浏览文件 @
81f3f6b5
...
...
@@ -29,7 +29,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
fc
=
paddle
.
nn
.
Linear
(
4
,
4
)
def
forward
(
self
,
x
):
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cinn_prim_gelu.py
浏览文件 @
81f3f6b5
...
...
@@ -42,7 +42,7 @@ def generate_data(shape, dtype="float32"):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
approximate
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
fc
=
paddle
.
nn
.
Linear
(
4
,
4
)
self
.
approximate
=
approximate
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cinn_prim_layer_norm.py
浏览文件 @
81f3f6b5
...
...
@@ -42,7 +42,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
fc
=
paddle
.
nn
.
Linear
(
64
,
64
)
def
forward
(
self
,
x
,
w
,
b
):
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cinn_prim_mean.py
浏览文件 @
81f3f6b5
...
...
@@ -45,7 +45,7 @@ class PrimeNet(
paddle
.
nn
.
Layer
,
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
fc
=
paddle
.
nn
.
Linear
(
4
,
4
)
def
forward
(
self
,
x
):
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_convert_call.py
浏览文件 @
81f3f6b5
...
...
@@ -218,7 +218,7 @@ class TestStaticMethod(TestRecursiveCall2):
class
NotToStaticHelper
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
NotToStaticHelper
,
self
).
__init__
()
super
().
__init__
()
def
sum
(
self
,
x
):
if
x
.
shape
[
0
]
>
1
:
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_program_translator.py
浏览文件 @
81f3f6b5
...
...
@@ -335,7 +335,7 @@ obj = Obj()
class
Net2
:
def
__init__
(
self
):
super
(
Net2
,
self
).
__init__
()
super
().
__init__
()
self
.
layer1
=
paddle
.
nn
.
Linear
(
10
,
10
)
def
forward
(
self
,
data
):
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_unuseful_inputs.py
浏览文件 @
81f3f6b5
...
...
@@ -33,7 +33,7 @@ def apply_to_static(support_to_static, model, image_shape=None):
class
Layer0
(
nn
.
Layer
):
def
__init__
(
self
,
level
):
super
(
Layer0
,
self
).
__init__
()
super
().
__init__
()
self
.
_linear1
=
nn
.
Linear
(
10
,
5
)
self
.
_linear2
=
nn
.
Linear
(
10
,
5
)
self
.
layer1
=
Layer1
(
level
)
...
...
@@ -51,7 +51,7 @@ class Layer0(nn.Layer):
class
Layer1
(
nn
.
Layer
):
def
__init__
(
self
,
level
):
super
(
Layer1
,
self
).
__init__
()
super
().
__init__
()
self
.
level
=
level
self
.
_linear
=
nn
.
Linear
(
5
,
2
)
...
...
python/paddle/fluid/tests/unittests/ipu/test_modelruntime_ipu.py
浏览文件 @
81f3f6b5
...
...
@@ -23,7 +23,7 @@ import paddle
class
SimpleLayer
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
SimpleLayer
,
self
).
__init__
()
super
().
__init__
()
self
.
conv
=
paddle
.
nn
.
Conv2D
(
in_channels
=
3
,
out_channels
=
1
,
kernel_size
=
2
,
stride
=
1
)
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_inference_predictor.py
浏览文件 @
81f3f6b5
...
...
@@ -55,7 +55,7 @@ def getdtype(dtype="float32"):
class
BackendPaddle
:
def
__init__
(
self
):
super
(
BackendPaddle
,
self
).
__init__
()
super
().
__init__
()
self
.
h2d_time
=
[]
self
.
compute_time
=
[]
self
.
d2h_time
=
[]
...
...
@@ -341,7 +341,7 @@ class ConvBNLayer(paddle.nn.Layer):
class
Test
(
nn
.
Layer
):
def
__init__
(
self
):
super
(
Test
,
self
).
__init__
()
super
().
__init__
()
self
.
conv
=
ConvBNLayer
(
num_channels
=
3
,
num_filters
=
64
,
filter_size
=
3
,
stride
=
2
,
act
=
'relu'
)
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_support_nhwc_pass.py
浏览文件 @
81f3f6b5
...
...
@@ -27,7 +27,7 @@ paddle.enable_static()
class
SimpleNet
(
nn
.
Layer
):
def
__init__
(
self
):
super
(
SimpleNet
,
self
).
__init__
()
super
().
__init__
()
self
.
conv1
=
nn
.
Conv2D
(
in_channels
=
4
,
out_channels
=
4
,
...
...
python/paddle/fluid/tests/unittests/prim/composite_ops/test_composite_batch_norm.py
浏览文件 @
81f3f6b5
...
...
@@ -350,7 +350,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
conv
=
nn
.
Conv2D
(
4
,
2
,
(
3
,
3
),
bias_attr
=
False
)
self
.
bn
=
BatchNorm
(
2
,
act
=
"relu"
)
self
.
run_mean
=
zeros
([
2
])
...
...
python/paddle/fluid/tests/unittests/prim/composite_ops/test_composite_layer_norm.py
浏览文件 @
81f3f6b5
...
...
@@ -212,7 +212,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
n_shape
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
ln
=
LayerNorm
(
n_shape
)
def
forward
(
self
,
x
):
...
...
python/paddle/fluid/tests/unittests/prim/composite_ops/test_composite_softmax.py
浏览文件 @
81f3f6b5
...
...
@@ -137,7 +137,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
sf
=
F
.
softmax
def
forward
(
self
,
x
,
current_axis
):
...
...
python/paddle/fluid/tests/unittests/prim/model/bert.py
浏览文件 @
81f3f6b5
...
...
@@ -87,7 +87,7 @@ class BertConfig:
class
BertLMPredictionHead
(
nn
.
Layer
):
def
__init__
(
self
,
config
:
BertConfig
,
embedding_weights
=
None
):
super
(
BertLMPredictionHead
,
self
).
__init__
()
super
().
__init__
()
self
.
transform
=
nn
.
Linear
(
config
.
hidden_size
,
config
.
hidden_size
)
self
.
activation
=
getattr
(
nn
.
functional
,
config
.
hidden_act
)
...
...
@@ -131,7 +131,7 @@ class BertLMPredictionHead(nn.Layer):
class
BertPretrainingHeads
(
nn
.
Layer
):
def
__init__
(
self
,
config
:
BertConfig
,
embedding_weights
=
None
):
super
(
BertPretrainingHeads
,
self
).
__init__
()
super
().
__init__
()
self
.
predictions
=
BertLMPredictionHead
(
config
,
embedding_weights
)
self
.
seq_relationship
=
nn
.
Linear
(
config
.
hidden_size
,
2
)
...
...
@@ -143,7 +143,7 @@ class BertPretrainingHeads(nn.Layer):
class
BertEmbeddings
(
nn
.
Layer
):
def
__init__
(
self
,
config
:
BertConfig
):
super
(
BertEmbeddings
,
self
).
__init__
()
super
().
__init__
()
self
.
word_embeddings
=
nn
.
Embedding
(
config
.
vocab_size
,
config
.
hidden_size
...
...
@@ -190,7 +190,7 @@ class BertEmbeddings(nn.Layer):
class
BertPooler
(
nn
.
Layer
):
def
__init__
(
self
,
config
:
BertConfig
):
super
(
BertPooler
,
self
).
__init__
()
super
().
__init__
()
self
.
dense
=
nn
.
Linear
(
config
.
hidden_size
,
config
.
hidden_size
)
self
.
activation
=
nn
.
Tanh
()
...
...
@@ -208,7 +208,7 @@ class BertPooler(nn.Layer):
class
BertModel
(
nn
.
Layer
):
def
__init__
(
self
,
config
:
BertConfig
,
to_static
,
enable_cinn
):
super
(
BertModel
,
self
).
__init__
()
super
().
__init__
()
self
.
config
=
config
self
.
pad_token_id
=
config
.
pad_token_id
self
.
initializer_range
=
config
.
initializer_range
...
...
@@ -372,7 +372,7 @@ class BertModel(nn.Layer):
class
Bert
(
nn
.
Layer
):
def
__init__
(
self
,
to_static
,
enable_cinn
):
super
(
Bert
,
self
).
__init__
()
super
().
__init__
()
config
=
BertConfig
()
self
.
bert
=
BertModel
(
config
,
to_static
,
enable_cinn
)
self
.
cls
=
BertPretrainingHeads
(
...
...
@@ -434,7 +434,7 @@ class Bert(nn.Layer):
class
BertPretrainingCriterion
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
vocab_size
=
VOCAB_SIZE
):
super
(
BertPretrainingCriterion
,
self
).
__init__
()
super
().
__init__
()
# CrossEntropyLoss is expensive since the inner reshape (copy)
self
.
loss_fn
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
(
ignore_index
=-
1
)
self
.
vocab_size
=
vocab_size
...
...
python/paddle/fluid/tests/unittests/prim/prim/flags/test_prim_flags_case.py
浏览文件 @
81f3f6b5
...
...
@@ -28,7 +28,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
def
forward
(
self
,
x
):
out
=
F
.
softmax
(
x
)
...
...
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_add_grad.py
浏览文件 @
81f3f6b5
...
...
@@ -29,7 +29,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
fc
=
paddle
.
nn
.
Linear
(
4
,
4
)
def
forward
(
self
,
x
,
y
):
...
...
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_add_tanh_grad.py
浏览文件 @
81f3f6b5
...
...
@@ -29,7 +29,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
fc
=
paddle
.
nn
.
Linear
(
4
,
4
)
def
forward
(
self
,
x
,
y
):
...
...
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_cast_grad.py
浏览文件 @
81f3f6b5
...
...
@@ -30,7 +30,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
fc
=
paddle
.
nn
.
Linear
(
4
,
4
)
def
forward
(
self
,
x
):
...
...
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_div_grad.py
浏览文件 @
81f3f6b5
...
...
@@ -29,7 +29,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
fc
=
paddle
.
nn
.
Linear
(
4
,
4
)
def
forward
(
self
,
x
,
y
):
...
...
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_gather_grad.py
浏览文件 @
81f3f6b5
...
...
@@ -31,7 +31,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
fc
=
paddle
.
nn
.
Linear
(
4
,
4
)
def
forward
(
self
,
x
,
index
,
axis
):
...
...
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_reshape_grad.py
浏览文件 @
81f3f6b5
...
...
@@ -29,7 +29,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
fc
=
paddle
.
nn
.
Linear
(
4
,
4
)
def
forward
(
self
,
x
):
...
...
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_sqrt_grad.py
浏览文件 @
81f3f6b5
...
...
@@ -34,7 +34,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
fc
=
paddle
.
nn
.
Linear
(
4
,
4
)
def
forward
(
self
,
x
):
...
...
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_sub_grad.py
浏览文件 @
81f3f6b5
...
...
@@ -29,7 +29,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
fc
=
paddle
.
nn
.
Linear
(
4
,
4
)
def
forward
(
self
,
x
,
y
):
...
...
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_tanh_grad.py
浏览文件 @
81f3f6b5
...
...
@@ -34,7 +34,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
self
.
fc
=
paddle
.
nn
.
Linear
(
4
,
4
)
def
forward
(
self
,
x
):
...
...
python/paddle/fluid/tests/unittests/prim/prim/vjp/static/test_comp_transpose_grad.py
浏览文件 @
81f3f6b5
...
...
@@ -29,7 +29,7 @@ def apply_to_static(net, use_cinn):
class
PrimeNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
super
(
PrimeNet
,
self
).
__init__
()
super
().
__init__
()
def
forward
(
self
,
x
):
out
=
paddle
.
transpose
(
x
,
[
0
,
2
,
1
])
...
...
python/paddle/fluid/tests/unittests/prim_op_test.py
浏览文件 @
81f3f6b5
...
...
@@ -222,7 +222,7 @@ def apply_to_static(net, use_cinn):
class
PrimNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
python_api
):
super
(
PrimNet
,
self
).
__init__
()
super
().
__init__
()
self
.
python_api
=
python_api
def
forward
(
self
,
args
):
...
...
python/paddle/fluid/tests/unittests/test_activation_op.py
浏览文件 @
81f3f6b5
...
...
@@ -3005,7 +3005,7 @@ class TestPow_ZeroDim(TestPow):
self
.
shape
=
[]
def
setUp
(
self
):
super
(
TestPow_ZeroDim
,
self
).
setUp
()
super
().
setUp
()
self
.
enable_cinn
=
False
...
...
python/paddle/fluid/tests/unittests/test_fused_attention_pass.py
浏览文件 @
81f3f6b5
...
...
@@ -33,7 +33,7 @@ class MultiHeadAttention(paddle.nn.Layer):
pre_ln
=
True
,
attn_dropout
=
True
,
):
super
(
MultiHeadAttention
,
self
).
__init__
()
super
().
__init__
()
self
.
embed_dim
=
embed_dim
self
.
kdim
=
embed_dim
self
.
vdim
=
embed_dim
...
...
python/paddle/fluid/tests/unittests/test_lbfgs_v2.py
浏览文件 @
81f3f6b5
...
...
@@ -31,7 +31,7 @@ np.random.seed(123)
class
Net
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
np_w
,
func
):
super
(
Net
,
self
).
__init__
()
super
().
__init__
()
self
.
func
=
func
w
=
paddle
.
to_tensor
(
np_w
)
self
.
w
=
paddle
.
create_parameter
(
...
...
python/paddle/fluid/tests/unittests/test_rnn_decode_api.py
浏览文件 @
81f3f6b5
...
...
@@ -407,7 +407,7 @@ class EncoderCell(SimpleRNNCell):
dropout_prob
=
0.0
,
init_scale
=
0.1
,
):
super
(
EncoderCell
,
self
).
__init__
(
input_size
,
hidden_size
)
super
().
__init__
(
input_size
,
hidden_size
)
self
.
dropout_prob
=
dropout_prob
# use add_sublayer to add multi-layers
self
.
lstm_cells
=
[]
...
...
@@ -453,7 +453,7 @@ class Encoder(Layer):
dropout_prob
=
0.0
,
init_scale
=
0.1
,
):
super
(
Encoder
,
self
).
__init__
()
super
().
__init__
()
self
.
embedder
=
Embedding
(
vocab_size
,
embed_dim
)
self
.
stack_lstm
=
RNN
(
EncoderCell
(
...
...
@@ -484,7 +484,7 @@ class Decoder(Layer):
dropout_prob
=
0.0
,
init_scale
=
0.1
,
):
super
(
Decoder
,
self
).
__init__
()
super
().
__init__
()
self
.
embedder
=
Embedding
(
vocab_size
,
embed_dim
)
self
.
stack_lstm
=
RNN
(
DecoderCell
(
...
...
@@ -603,7 +603,7 @@ class BaseModel(Layer):
dropout_prob
=
0.0
,
init_scale
=
0.1
,
):
super
(
BaseModel
,
self
).
__init__
()
super
().
__init__
()
self
.
hidden_size
=
hidden_size
self
.
word_embedding
=
Embedding
(
vocab_size
,
embed_dim
)
self
.
encoder
=
Encoder
(
...
...
python/paddle/fluid/tests/unittests/xpu/parallel_dygraph_dataparallel_with_pylayer.py
浏览文件 @
81f3f6b5
...
...
@@ -44,7 +44,7 @@ class cus_tanh(PyLayer):
class
SimpleNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
train_id
,
model_id
):
super
(
SimpleNet
,
self
).
__init__
()
super
().
__init__
()
self
.
w
=
self
.
create_parameter
(
shape
=
[
in_dim
,
batch
],
dtype
=
"float32"
)
self
.
linear
=
paddle
.
nn
.
Linear
(
in_dim
,
out_dim
)
self
.
tanh
=
paddle
.
tanh
...
...
python/paddle/fluid/tests/unittests/xpu/parallel_dygraph_gradient_check.py
浏览文件 @
81f3f6b5
...
...
@@ -30,7 +30,7 @@ out_dim = 20
class
SimpleNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
train_id
):
super
(
SimpleNet
,
self
).
__init__
()
super
().
__init__
()
self
.
w1
=
self
.
create_parameter
(
shape
=
[
in_dim
,
out_dim
],
dtype
=
"float32"
)
...
...
python/paddle/fluid/tests/unittests/xpu/parallel_dygraph_gradient_check_in_eager_mode.py
浏览文件 @
81f3f6b5
...
...
@@ -30,7 +30,7 @@ out_dim = 20
class
SimpleNet
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
train_id
):
super
(
SimpleNet
,
self
).
__init__
()
super
().
__init__
()
self
.
w1
=
self
.
create_parameter
(
shape
=
[
in_dim
,
out_dim
],
dtype
=
"float32"
)
...
...
python/paddle/fluid/tests/unittests/xpu/test_recompute_op_xpu.py
浏览文件 @
81f3f6b5
...
...
@@ -52,7 +52,7 @@ class Naive_fc_net(paddle.nn.Layer):
def
__init__
(
self
,
input_size
=
10
,
recompute_blocks
=
[
1
,
3
],
recompute_kwargs
=
{}
):
super
(
Naive_fc_net
,
self
).
__init__
()
super
().
__init__
()
self
.
recompute_blocks
=
recompute_blocks
self
.
recompute_kwargs
=
recompute_kwargs
self
.
runfunc0
=
get_fc_block
(
0
,
input_size
,
is_last
=
False
)
...
...
python/paddle/incubate/optimizer/lbfgs.py
浏览文件 @
81f3f6b5
...
...
@@ -89,7 +89,7 @@ class LBFGS(Optimizer):
class Net(paddle.nn.Layer):
def __init__(self):
super(
Net, self
).__init__()
super().__init__()
w = paddle.to_tensor(np_w)
self.w = paddle.create_parameter(shape=w.shape, dtype=w.dtype, default_initializer=paddle.nn.initializer.Assign(w))
...
...
python/paddle/nn/quant/format.py
浏览文件 @
81f3f6b5
...
...
@@ -23,7 +23,7 @@ from paddle.nn import Layer
class
LinearQuanterDequanter
(
Layer
):
def
__init__
(
self
,
quanter
,
dequanter
):
super
(
LinearQuanterDequanter
,
self
).
__init__
()
super
().
__init__
()
self
.
_quanter
=
quanter
self
.
_dequanter
=
dequanter
...
...
@@ -46,7 +46,7 @@ class LinearQuanterDequanter(Layer):
class
LinearQuanter
(
Layer
):
def
__init__
(
self
,
scales
,
zero_point
=
None
,
quant_axis
=
None
,
bit_length
=
8
):
super
(
LinearQuanter
,
self
).
__init__
()
super
().
__init__
()
self
.
_scales
=
paddle
.
to_tensor
(
scales
,
dtype
=
"float32"
)
self
.
_zero_point
=
(
paddle
.
zeros
([
1
],
dtype
=
"float32"
)
...
...
@@ -97,7 +97,7 @@ class LinearQuanter(Layer):
class
LinearDequanter
(
Layer
):
def
__init__
(
self
,
scales
,
zero_point
=
None
,
quant_axis
=
None
,
bit_length
=
8
):
super
(
LinearDequanter
,
self
).
__init__
()
super
().
__init__
()
self
.
_scales
=
paddle
.
to_tensor
(
scales
,
dtype
=
"float32"
)
self
.
_zero_point
=
(
paddle
.
zeros
([
1
],
dtype
=
"float32"
)
...
...
@@ -156,7 +156,7 @@ class ConvertibleQuantedLayer(Layer, metaclass=abc.ABCMeta):
# Given codes in ./customized_quanter.py
class CustomizedQuantedLayer(ConvertibleQuantedLayer):
def __init__(self):
super(
CustomizedQuantedLayer, self
).__init__()
super().__init__()
self.weight_a = paddle.create_parameter(shape=[1], dtype='float32')
self.weight_b = paddle.create_parameter(shape=[1], dtype='float32')
self.quanter_for_weight_a = None
...
...
@@ -176,7 +176,7 @@ class ConvertibleQuantedLayer(Layer, metaclass=abc.ABCMeta):
"""
def
__init__
(
self
):
super
(
ConvertibleQuantedLayer
,
self
).
__init__
()
super
().
__init__
()
self
.
converted
=
False
@
abc
.
abstractmethod
...
...
python/paddle/nn/quant/qat/conv.py
浏览文件 @
81f3f6b5
...
...
@@ -27,7 +27,7 @@ class QuantedConv2D(ConvertibleQuantedLayer):
"""
def
__init__
(
self
,
layer
:
Layer
,
q_config
):
super
(
QuantedConv2D
,
self
).
__init__
()
super
().
__init__
()
# For Conv2D
self
.
_groups
=
layer
.
_groups
...
...
python/paddle/nn/quant/qat/linear.py
浏览文件 @
81f3f6b5
...
...
@@ -26,7 +26,7 @@ class QuantedLinear(ConvertibleQuantedLayer):
"""
def
__init__
(
self
,
layer
:
Layer
,
q_config
):
super
(
QuantedLinear
,
self
).
__init__
()
super
().
__init__
()
# For Linear
self
.
weight
=
layer
.
weight
self
.
bias
=
layer
.
bias
...
...
python/paddle/nn/quant/stub.py
浏览文件 @
81f3f6b5
...
...
@@ -36,7 +36,7 @@ class Stub(Layer):
quanter = FakeQuanterWithAbsMaxObserver(moving_rate=0.9)
class Model(paddle.nn.Layer):
def __init__(self, num_classes=10):
super(
Model, self
).__init__()
super().__init__()
self.conv = Conv2D(3, 6, 3, stride=1, padding=1)
self.quant = Stub(quanter)
def forward(self, inputs):
...
...
@@ -51,7 +51,7 @@ class Stub(Layer):
"""
def
__init__
(
self
,
observer
=
None
):
super
(
Stub
,
self
).
__init__
()
super
().
__init__
()
self
.
_observer
=
observer
def
forward
(
self
,
input
):
...
...
@@ -71,7 +71,7 @@ class QuanterStub(Layer):
"""
def
__init__
(
self
,
layer
:
Stub
,
q_config
):
super
(
QuanterStub
,
self
).
__init__
()
super
().
__init__
()
self
.
_observer
=
None
if
layer
.
_observer
is
not
None
:
self
.
_observer
=
layer
.
_observer
.
_instance
(
layer
)
...
...
python/paddle/quantization/base_observer.py
浏览文件 @
81f3f6b5
...
...
@@ -25,7 +25,7 @@ class BaseObserver(BaseQuanter, metaclass=abc.ABCMeta):
"""
def
__init__
(
self
):
super
(
BaseObserver
,
self
).
__init__
()
super
().
__init__
()
@
abc
.
abstractmethod
def
cal_thresholds
(
self
):
...
...
python/paddle/quantization/base_quanter.py
浏览文件 @
81f3f6b5
...
...
@@ -29,7 +29,7 @@ class BaseQuanter(Layer, metaclass=abc.ABCMeta):
"""
def
__init__
(
self
):
super
(
BaseQuanter
,
self
).
__init__
()
super
().
__init__
()
@
abc
.
abstractmethod
def
forward
(
self
,
input
):
...
...
python/paddle/quantization/config.py
浏览文件 @
81f3f6b5
...
...
@@ -118,7 +118,7 @@ class QuantConfig:
class Model(paddle.nn.Layer):
def __init__(self):
super(
Model, self
).__init__()
super().__init__()
self.fc = Linear(576, 120)
model = Model()
quanter = FakeQuanterWithAbsMaxObserver(moving_rate=0.9)
...
...
@@ -162,7 +162,7 @@ class QuantConfig:
class Model(paddle.nn.Layer):
def __init__(self):
super(
Model, self
).__init__()
super().__init__()
self.fc = Linear(576, 120)
model = Model()
quanter = FakeQuanterWithAbsMaxObserver(moving_rate=0.9)
...
...
@@ -207,7 +207,7 @@ class QuantConfig:
class Model(paddle.nn.Layer):
def __init__(self):
super(
Model, self
).__init__()
super().__init__()
self.fc = Linear(576, 120)
model = Model()
quanter = FakeQuanterWithAbsMaxObserver(moving_rate=0.9)
...
...
@@ -388,7 +388,7 @@ class QuantConfig:
class Model(paddle.nn.Layer):
def __init__(self):
super(
Model, self
).__init__()
super().__init__()
self.fc = Sequential(Linear(576, 120),Linear(576, 120))
model = Model()
quanter = FakeQuanterWithAbsMaxObserver(moving_rate=0.9)
...
...
python/paddle/quantization/factory.py
浏览文件 @
81f3f6b5
...
...
@@ -56,7 +56,7 @@ class QuanterFactory(ClassWithArguments):
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
QuanterFactory
,
self
).
__init__
(
*
args
,
**
kwargs
)
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
partial_class
=
None
def
_instance
(
self
,
layer
:
Layer
)
->
BaseQuanter
:
...
...
python/paddle/quantization/observers/abs_max.py
浏览文件 @
81f3f6b5
...
...
@@ -39,7 +39,7 @@ class AbsmaxObserver(ObserverFactory):
"""
def
__init__
(
self
,
quant_bits
=
8
):
super
(
AbsmaxObserver
,
self
).
__init__
(
quant_bits
=
quant_bits
)
super
().
__init__
(
quant_bits
=
quant_bits
)
def
_get_class
(
self
):
return
AbsmaxObserverLayer
...
...
@@ -53,7 +53,7 @@ class AbsmaxObserverLayer(BaseObserver):
INIT_ABS_MAX
=
1e-7
def
__init__
(
self
,
layer
,
quant_bits
=
8
):
super
(
AbsmaxObserverLayer
,
self
).
__init__
()
super
().
__init__
()
self
.
_quant_bits
=
quant_bits
self
.
abs_max_val
=
paddle
.
to_tensor
(
AbsmaxObserverLayer
.
INIT_ABS_MAX
)
...
...
python/paddle/quantization/ptq.py
浏览文件 @
81f3f6b5
...
...
@@ -27,7 +27,7 @@ class PTQ(Quantization):
"""
def
__init__
(
self
,
config
:
QuantConfig
):
super
(
PTQ
,
self
).
__init__
(
config
)
super
().
__init__
(
config
)
def
_is_parallel_training
(
self
):
try
:
...
...
python/paddle/quantization/qat.py
浏览文件 @
81f3f6b5
...
...
@@ -36,7 +36,7 @@ class QAT(Quantization):
"""
def
__init__
(
self
,
config
:
QuantConfig
):
super
(
QAT
,
self
).
__init__
(
config
)
super
().
__init__
(
config
)
def
quantize
(
self
,
model
:
Layer
,
inplace
=
False
):
r
"""
...
...
python/paddle/quantization/quanters/abs_max.py
浏览文件 @
81f3f6b5
...
...
@@ -82,7 +82,7 @@ class FakeQuanterWithAbsMaxObserver(QuanterFactory):
dtype
=
'float32'
,
name
=
None
,
):
super
(
FakeQuanterWithAbsMaxObserver
,
self
).
__init__
(
super
().
__init__
(
name
=
name
,
moving_rate
=
moving_rate
,
bit_length
=
bit_length
,
...
...
@@ -102,7 +102,7 @@ class FakeQuanterWithAbsMaxObserverLayer(BaseQuanter):
bit_length
=
8
,
dtype
=
'float32'
,
):
super
(
FakeQuanterWithAbsMaxObserverLayer
,
self
).
__init__
()
super
().
__init__
()
self
.
_moving_rate
=
moving_rate
self
.
_bit_length
=
bit_length
scale_prefix
=
(
...
...
python/paddle/quantization/wrapper.py
浏览文件 @
81f3f6b5
...
...
@@ -34,7 +34,7 @@ class ObserveWrapper(Layer):
observed
:
Layer
,
observe_input
=
True
,
):
super
(
ObserveWrapper
,
self
).
__init__
()
super
().
__init__
()
self
.
_observer
=
observer
self
.
_observed
=
observed
self
.
_observe_input
=
observe_input
...
...
python/paddle/tests/quantization/test_customized_quanter.py
浏览文件 @
81f3f6b5
...
...
@@ -28,7 +28,7 @@ linear_quant_axis = 1
@
quanter
(
"CustomizedQuanter"
)
class
CustomizedQuanterLayer
(
BaseQuanter
):
def
__init__
(
self
,
layer
,
bit_length
=
8
,
kwargs1
=
None
):
super
(
CustomizedQuanterLayer
,
self
).
__init__
()
super
().
__init__
()
self
.
_layer
=
layer
self
.
_bit_length
=
bit_length
self
.
_kwargs1
=
kwargs1
...
...
python/paddle/tests/quantization/test_ptq.py
浏览文件 @
81f3f6b5
...
...
@@ -29,7 +29,7 @@ from paddle.quantization.observers.abs_max import AbsmaxObserverLayer
class
LeNetDygraph
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
num_classes
=
10
):
super
(
LeNetDygraph
,
self
).
__init__
()
super
().
__init__
()
self
.
num_classes
=
num_classes
self
.
features
=
Sequential
(
Conv2D
(
1
,
6
,
3
,
stride
=
1
,
padding
=
1
),
...
...
python/paddle/tests/quantization/test_qat.py
浏览文件 @
81f3f6b5
...
...
@@ -41,7 +41,7 @@ class RandomDataset(Dataset):
class
Model
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
num_classes
=
10
):
super
(
Model
,
self
).
__init__
()
super
().
__init__
()
self
.
num_classes
=
num_classes
self
.
features
=
Sequential
(
Conv2D
(
3
,
6
,
3
,
stride
=
1
,
padding
=
1
),
...
...
python/paddle/tests/quantization/test_quant.py
浏览文件 @
81f3f6b5
...
...
@@ -24,7 +24,7 @@ from paddle.quantization.quanters import FakeQuanterWithAbsMaxObserver
class
LeNetDygraph
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
num_classes
=
10
):
super
(
LeNetDygraph
,
self
).
__init__
()
super
().
__init__
()
self
.
num_classes
=
num_classes
self
.
features
=
Sequential
(
Conv2D
(
3
,
6
,
3
,
stride
=
1
,
padding
=
1
),
...
...
python/paddle/tests/quantization/test_stub.py
浏览文件 @
81f3f6b5
...
...
@@ -28,7 +28,7 @@ quanter = FakeQuanterWithAbsMaxObserver(moving_rate=0.9)
class
Model
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
num_classes
=
10
):
super
(
Model
,
self
).
__init__
()
super
().
__init__
()
self
.
quant_in
=
Stub
()
self
.
conv
=
Conv2D
(
3
,
6
,
3
,
stride
=
1
,
padding
=
1
)
self
.
quant
=
Stub
(
quanter
)
...
...
python/paddle/utils/install_check.py
浏览文件 @
81f3f6b5
...
...
@@ -186,7 +186,7 @@ def train_for_run_parallel():
"""
def
__init__
(
self
):
super
(
LinearNet
,
self
).
__init__
()
super
().
__init__
()
self
.
_linear1
=
paddle
.
nn
.
Linear
(
10
,
10
)
self
.
_linear2
=
paddle
.
nn
.
Linear
(
10
,
1
)
...
...
python/paddle/vision/models/_utils.py
浏览文件 @
81f3f6b5
...
...
@@ -87,7 +87,7 @@ class IntermediateLayerGetter(nn.LayerDict):
if
not
return_layers
:
break
super
(
IntermediateLayerGetter
,
self
).
__init__
(
layers
)
super
().
__init__
(
layers
)
self
.
return_layers
=
orig_return_layers
def
forward
(
self
,
x
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录