Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
e508373a
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看板
未验证
提交
e508373a
编写于
1月 07, 2022
作者:
J
Jiaqi Liu
提交者:
GitHub
1月 07, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support string input for ofa export (#964) (#967)
* support string input for ofa export
上级
f4c1f48c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
0 deletion
+22
-0
paddleslim/nas/ofa/ofa.py
paddleslim/nas/ofa/ofa.py
+17
-0
paddleslim/quant/quanter.py
paddleslim/quant/quanter.py
+5
-0
未找到文件。
paddleslim/nas/ofa/ofa.py
浏览文件 @
e508373a
...
...
@@ -79,6 +79,21 @@ DistillConfig = namedtuple(
DistillConfig
.
__new__
.
__defaults__
=
(
None
,
)
*
len
(
DistillConfig
.
_fields
)
def
to_tensor
(
string_values
,
name
=
"text"
):
"""
Create the tensor that the value holds the list of string.
NOTICE: The value will be holded in the cpu place.
Parameters:
string_values(list[string]): The value will be setted to the tensor.
name(string): The name of the tensor.
"""
tensor
=
paddle
.
Tensor
(
core
.
VarDesc
.
VarType
.
STRING
,
[],
name
,
core
.
VarDesc
.
VarType
.
STRINGS
,
False
)
tensor
.
value
().
set_string_list
(
string_values
)
return
tensor
class
OFABase
(
Layer
):
def
__init__
(
self
,
model
):
super
(
OFABase
,
self
).
__init__
()
...
...
@@ -531,6 +546,8 @@ class OFA(OFABase):
dtype
=
dtypes
[
0
]
else
:
dtype
=
dtypes
if
dtype
==
core
.
VarDesc
.
VarType
.
STRINGS
:
return
to_tensor
([
""
])
return
paddle
.
cast
(
paddle
.
rand
(
list
(
input_size
)),
dtype
)
if
isinstance
(
input_size
,
dict
):
inputs
=
{}
...
...
paddleslim/quant/quanter.py
浏览文件 @
e508373a
...
...
@@ -306,6 +306,7 @@ def quant_post_static(
quantize_model_path
,
batch_generator
=
None
,
sample_generator
=
None
,
data_loader
=
None
,
model_filename
=
None
,
params_filename
=
None
,
save_model_filename
=
'__model__'
,
...
...
@@ -345,6 +346,9 @@ def quant_post_static(
can be set. Beisdes, batch_generator supports lod tensor.
sample_generator(Python Generator): The sample generator provides
calibrate data for DataLoader, and it only returns a sample every time.
data_loader(Python Generator, Paddle.io.DataLoader, optional): The
Generator or Dataloader provides calibrate data, and it could
return a batch every time.
model_filename(str, optional): The name of model file. If parameters
are saved in separate files, set it as 'None'. Default: 'None'.
params_filename(str, optional): The name of params file.
...
...
@@ -398,6 +402,7 @@ def quant_post_static(
executor
=
executor
,
sample_generator
=
sample_generator
,
batch_generator
=
batch_generator
,
data_loader
=
data_loader
,
model_dir
=
model_dir
,
model_filename
=
model_filename
,
params_filename
=
params_filename
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录