Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
fd13584e
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
1 年多 前同步成功
通知
51
Star
1434
Fork
344
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
16
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSlim
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
16
合并请求
16
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
fd13584e
编写于
1月 17, 2022
作者:
C
Chang Xu
提交者:
GitHub
1月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
asymmetric_kernel (#969)
* asymmetric_kernel * asymmetric_kernel
上级
f895aebe
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
30 addition
and
0 deletion
+30
-0
paddleslim/nas/ofa/layers.py
paddleslim/nas/ofa/layers.py
+16
-0
paddleslim/nas/ofa/layers_old.py
paddleslim/nas/ofa/layers_old.py
+14
-0
未找到文件。
paddleslim/nas/ofa/layers.py
浏览文件 @
fd13584e
...
@@ -214,6 +214,10 @@ class SuperConv2D(nn.Conv2D):
...
@@ -214,6 +214,10 @@ class SuperConv2D(nn.Conv2D):
setattr
(
self
,
name
,
param
)
setattr
(
self
,
name
,
param
)
def
get_active_filter
(
self
,
in_nc
,
out_nc
,
kernel_size
):
def
get_active_filter
(
self
,
in_nc
,
out_nc
,
kernel_size
):
### Unsupport for asymmetric kernels
if
self
.
_kernel_size
[
0
]
!=
self
.
_kernel_size
[
1
]:
return
self
.
weight
[:
out_nc
,
:
in_nc
,
:,
:]
start
,
end
=
compute_start_end
(
self
.
_kernel_size
[
0
],
kernel_size
)
start
,
end
=
compute_start_end
(
self
.
_kernel_size
[
0
],
kernel_size
)
### if NOT transform kernel, intercept a center filter with kernel_size from largest filter
### if NOT transform kernel, intercept a center filter with kernel_size from largest filter
filters
=
self
.
weight
[:
out_nc
,
:
in_nc
,
start
:
end
,
start
:
end
]
filters
=
self
.
weight
[:
out_nc
,
:
in_nc
,
start
:
end
,
start
:
end
]
...
@@ -288,9 +292,14 @@ class SuperConv2D(nn.Conv2D):
...
@@ -288,9 +292,14 @@ class SuperConv2D(nn.Conv2D):
out_nc
=
int
(
channel
)
out_nc
=
int
(
channel
)
else
:
else
:
out_nc
=
self
.
_out_channels
out_nc
=
self
.
_out_channels
ks
=
int
(
self
.
_kernel_size
[
0
])
if
kernel_size
==
None
else
int
(
ks
=
int
(
self
.
_kernel_size
[
0
])
if
kernel_size
==
None
else
int
(
kernel_size
)
kernel_size
)
if
kernel_size
is
not
None
and
self
.
_kernel_size
[
0
]
!=
self
.
_kernel_size
[
1
]:
_logger
.
error
(
"Searching for asymmetric kernels is NOT supported"
)
groups
,
weight_in_nc
,
weight_out_nc
=
self
.
get_groups_in_out_nc
(
in_nc
,
groups
,
weight_in_nc
,
weight_out_nc
=
self
.
get_groups_in_out_nc
(
in_nc
,
out_nc
)
out_nc
)
...
@@ -518,6 +527,9 @@ class SuperConv2DTranspose(nn.Conv2DTranspose):
...
@@ -518,6 +527,9 @@ class SuperConv2DTranspose(nn.Conv2DTranspose):
setattr
(
self
,
name
,
param
)
setattr
(
self
,
name
,
param
)
def
get_active_filter
(
self
,
in_nc
,
out_nc
,
kernel_size
):
def
get_active_filter
(
self
,
in_nc
,
out_nc
,
kernel_size
):
### Unsupport for asymmetric kernels
if
self
.
_kernel_size
[
0
]
!=
self
.
_kernel_size
[
1
]:
return
self
.
weight
[:
out_nc
,
:
in_nc
,
:,
:]
start
,
end
=
compute_start_end
(
self
.
_kernel_size
[
0
],
kernel_size
)
start
,
end
=
compute_start_end
(
self
.
_kernel_size
[
0
],
kernel_size
)
filters
=
self
.
weight
[:
in_nc
,
:
out_nc
,
start
:
end
,
start
:
end
]
filters
=
self
.
weight
[:
in_nc
,
:
out_nc
,
start
:
end
,
start
:
end
]
if
self
.
transform_kernel
!=
False
and
kernel_size
<
self
.
_kernel_size
[
if
self
.
transform_kernel
!=
False
and
kernel_size
<
self
.
_kernel_size
[
...
@@ -600,6 +612,10 @@ class SuperConv2DTranspose(nn.Conv2DTranspose):
...
@@ -600,6 +612,10 @@ class SuperConv2DTranspose(nn.Conv2DTranspose):
ks
=
int
(
self
.
_kernel_size
[
0
])
if
kernel_size
==
None
else
int
(
ks
=
int
(
self
.
_kernel_size
[
0
])
if
kernel_size
==
None
else
int
(
kernel_size
)
kernel_size
)
if
kernel_size
is
not
None
and
self
.
_kernel_size
[
0
]
!=
self
.
_kernel_size
[
1
]:
_logger
.
error
(
"Searching for asymmetric kernels is NOT supported"
)
groups
,
weight_in_nc
,
weight_out_nc
=
self
.
get_groups_in_out_nc
(
in_nc
,
groups
,
weight_in_nc
,
weight_out_nc
=
self
.
get_groups_in_out_nc
(
in_nc
,
out_nc
)
out_nc
)
...
...
paddleslim/nas/ofa/layers_old.py
浏览文件 @
fd13584e
...
@@ -213,6 +213,9 @@ class SuperConv2D(fluid.dygraph.Conv2D):
...
@@ -213,6 +213,9 @@ class SuperConv2D(fluid.dygraph.Conv2D):
setattr
(
self
,
name
,
param
)
setattr
(
self
,
name
,
param
)
def
get_active_filter
(
self
,
in_nc
,
out_nc
,
kernel_size
):
def
get_active_filter
(
self
,
in_nc
,
out_nc
,
kernel_size
):
### Unsupport for asymmetric kernels
if
self
.
_filter_size
[
0
]
!=
self
.
_filter_size
[
1
]:
return
self
.
weight
[:
out_nc
,
:
in_nc
,
:,
:]
start
,
end
=
compute_start_end
(
self
.
_filter_size
[
0
],
kernel_size
)
start
,
end
=
compute_start_end
(
self
.
_filter_size
[
0
],
kernel_size
)
### if NOT transform kernel, intercept a center filter with kernel_size from largest filter
### if NOT transform kernel, intercept a center filter with kernel_size from largest filter
filters
=
self
.
weight
[:
out_nc
,
:
in_nc
,
start
:
end
,
start
:
end
]
filters
=
self
.
weight
[:
out_nc
,
:
in_nc
,
start
:
end
,
start
:
end
]
...
@@ -285,6 +288,10 @@ class SuperConv2D(fluid.dygraph.Conv2D):
...
@@ -285,6 +288,10 @@ class SuperConv2D(fluid.dygraph.Conv2D):
ks
=
int
(
self
.
_filter_size
[
0
])
if
kernel_size
==
None
else
int
(
ks
=
int
(
self
.
_filter_size
[
0
])
if
kernel_size
==
None
else
int
(
kernel_size
)
kernel_size
)
if
kernel_size
is
not
None
and
self
.
_filter_size
[
0
]
!=
self
.
_filter_size
[
1
]:
_logger
.
error
(
"Searching for asymmetric kernels is NOT supported"
)
groups
,
weight_in_nc
,
weight_out_nc
=
self
.
get_groups_in_out_nc
(
in_nc
,
groups
,
weight_in_nc
,
weight_out_nc
=
self
.
get_groups_in_out_nc
(
in_nc
,
out_nc
)
out_nc
)
...
@@ -513,6 +520,9 @@ class SuperConv2DTranspose(fluid.dygraph.Conv2DTranspose):
...
@@ -513,6 +520,9 @@ class SuperConv2DTranspose(fluid.dygraph.Conv2DTranspose):
setattr
(
self
,
name
,
param
)
setattr
(
self
,
name
,
param
)
def
get_active_filter
(
self
,
in_nc
,
out_nc
,
kernel_size
):
def
get_active_filter
(
self
,
in_nc
,
out_nc
,
kernel_size
):
### Unsupport for asymmetric kernels
if
self
.
_filter_size
[
0
]
!=
self
.
_filter_size
[
1
]:
return
self
.
weight
[:
out_nc
,
:
in_nc
,
:,
:]
start
,
end
=
compute_start_end
(
self
.
_filter_size
[
0
],
kernel_size
)
start
,
end
=
compute_start_end
(
self
.
_filter_size
[
0
],
kernel_size
)
filters
=
self
.
weight
[:
in_nc
,
:
out_nc
,
start
:
end
,
start
:
end
]
filters
=
self
.
weight
[:
in_nc
,
:
out_nc
,
start
:
end
,
start
:
end
]
if
self
.
transform_kernel
!=
False
and
kernel_size
<
self
.
_filter_size
[
if
self
.
transform_kernel
!=
False
and
kernel_size
<
self
.
_filter_size
[
...
@@ -584,6 +594,10 @@ class SuperConv2DTranspose(fluid.dygraph.Conv2DTranspose):
...
@@ -584,6 +594,10 @@ class SuperConv2DTranspose(fluid.dygraph.Conv2DTranspose):
ks
=
int
(
self
.
_filter_size
[
0
])
if
kernel_size
==
None
else
int
(
ks
=
int
(
self
.
_filter_size
[
0
])
if
kernel_size
==
None
else
int
(
kernel_size
)
kernel_size
)
if
kernel_size
is
not
None
and
self
.
_filter_size
[
0
]
!=
self
.
_filter_size
[
1
]:
_logger
.
error
(
"Searching for asymmetric kernels is NOT supported"
)
groups
,
weight_in_nc
,
weight_out_nc
=
self
.
get_groups_in_out_nc
(
in_nc
,
groups
,
weight_in_nc
,
weight_out_nc
=
self
.
get_groups_in_out_nc
(
in_nc
,
out_nc
)
out_nc
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录