Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
码匠许师傅
Tflite Micro
提交
2925fc5e
T
Tflite Micro
项目概览
码匠许师傅
/
Tflite Micro
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Tflite Micro
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
2925fc5e
编写于
9月 02, 2021
作者:
T
TFLM-bot
提交者:
GitHub
9月 02, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Sync from upstream TF. (#478)
Co-authored-by:
N
Advait Jain
<
advaitjain@users.noreply.github.com
>
上级
c28df9e5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
105 addition
and
27 deletion
+105
-27
tensorflow/lite/core/api/flatbuffer_conversions.cc
tensorflow/lite/core/api/flatbuffer_conversions.cc
+86
-27
tensorflow/lite/core/api/flatbuffer_conversions.h
tensorflow/lite/core/api/flatbuffer_conversions.h
+19
-0
未找到文件。
tensorflow/lite/core/api/flatbuffer_conversions.cc
浏览文件 @
2925fc5e
...
...
@@ -181,6 +181,10 @@ TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type,
return
ParseArgMin
(
op
,
error_reporter
,
allocator
,
builtin_data
);
}
case
BuiltinOperator_ASSIGN_VARIABLE
:
{
return
ParseAssignVariable
(
op
,
error_reporter
,
allocator
,
builtin_data
);
}
case
BuiltinOperator_AVERAGE_POOL_2D
:
{
return
ParsePool
(
op
,
error_reporter
,
allocator
,
builtin_data
);
}
...
...
@@ -193,6 +197,10 @@ TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type,
return
ParseBatchToSpaceNd
(
op
,
error_reporter
,
allocator
,
builtin_data
);
}
case
BuiltinOperator_CALL_ONCE
:
{
return
ParseCallOnce
(
op
,
error_reporter
,
allocator
,
builtin_data
);
}
case
BuiltinOperator_CEIL
:
{
return
ParseCeil
(
op
,
error_reporter
,
allocator
,
builtin_data
);
}
...
...
@@ -369,6 +377,10 @@ TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type,
return
ParseQuantize
(
op
,
error_reporter
,
allocator
,
builtin_data
);
}
case
BuiltinOperator_READ_VARIABLE
:
{
return
ParseReadVariable
(
op
,
error_reporter
,
allocator
,
builtin_data
);
}
case
BuiltinOperator_REDUCE_ANY
:
{
return
ParseReducer
(
op
,
error_reporter
,
allocator
,
builtin_data
);
}
...
...
@@ -486,6 +498,10 @@ TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type,
return
ParseUnpack
(
op
,
error_reporter
,
allocator
,
builtin_data
);
}
case
BuiltinOperator_VAR_HANDLE
:
{
return
ParseVarHandle
(
op
,
error_reporter
,
allocator
,
builtin_data
);
}
case
BuiltinOperator_ZEROS_LIKE
:
{
return
ParseZerosLike
(
op
,
error_reporter
,
allocator
,
builtin_data
);
}
...
...
@@ -737,16 +753,6 @@ TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type,
*
builtin_data
=
params
.
release
();
return
kTfLiteOk
;
}
case
BuiltinOperator_CALL_ONCE
:
{
auto
params
=
safe_allocator
.
Allocate
<
TfLiteCallOnceParams
>
();
TF_LITE_ENSURE
(
error_reporter
,
params
!=
nullptr
);
if
(
const
auto
*
call_once_params
=
op
->
builtin_options_as_CallOnceOptions
())
{
params
->
init_subgraph_index
=
call_once_params
->
init_subgraph_index
();
}
*
builtin_data
=
params
.
release
();
return
kTfLiteOk
;
}
case
BuiltinOperator_CONV_3D
:
case
BuiltinOperator_CONV_3D_TRANSPOSE
:
{
auto
params
=
safe_allocator
.
Allocate
<
TfLiteConv3DParams
>
();
...
...
@@ -780,21 +786,6 @@ TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type,
*
builtin_data
=
params
.
release
();
return
kTfLiteOk
;
}
case
BuiltinOperator_VAR_HANDLE
:
{
auto
params
=
safe_allocator
.
Allocate
<
TfLiteVarHandleParams
>
();
TF_LITE_ENSURE
(
error_reporter
,
params
!=
nullptr
);
params
->
container
=
nullptr
;
params
->
shared_name
=
nullptr
;
if
(
const
auto
*
var_handle_params
=
op
->
builtin_options_as_VarHandleOptions
())
{
if
(
var_handle_params
->
container
())
params
->
container
=
var_handle_params
->
container
()
->
c_str
();
if
(
var_handle_params
->
shared_name
())
params
->
shared_name
=
var_handle_params
->
shared_name
()
->
c_str
();
}
*
builtin_data
=
params
.
release
();
return
kTfLiteOk
;
}
// Below are the ops with no builtin_data structure.
// TODO(aselle): Implement call in BuiltinOptions, but nullptrs are
// ok for now, since there is no call implementation either.
...
...
@@ -831,8 +822,6 @@ TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type,
case
BuiltinOperator_HASHTABLE_FIND
:
case
BuiltinOperator_HASHTABLE_IMPORT
:
case
BuiltinOperator_HASHTABLE_SIZE
:
case
BuiltinOperator_READ_VARIABLE
:
case
BuiltinOperator_ASSIGN_VARIABLE
:
case
BuiltinOperator_BROADCAST_ARGS
:
return
kTfLiteOk
;
case
BuiltinOperator_PLACEHOLDER_FOR_GREATER_OP_CODES
:
...
...
@@ -990,6 +979,14 @@ TfLiteStatus ParseArgMin(const Operator* op, ErrorReporter* error_reporter,
return
kTfLiteOk
;
}
// We have this parse function instead of directly returning kTfLiteOk from the
// switch-case in ParseOpData because this function is used as part of the
// selective registration for the OpResolver implementation in micro.
TfLiteStatus
ParseAssignVariable
(
const
Operator
*
,
ErrorReporter
*
,
BuiltinDataAllocator
*
,
void
**
)
{
return
kTfLiteOk
;
}
// We have this parse function instead of directly returning kTfLiteOk from the
// switch-case in ParseOpData because this function is used as part of the
// selective registration for the OpResolver implementation in micro.
...
...
@@ -1019,6 +1016,33 @@ TfLiteStatus ParseBatchToSpaceNd(const Operator*, ErrorReporter*,
return
kTfLiteOk
;
}
TfLiteStatus
ParseCallOnce
(
const
Operator
*
op
,
ErrorReporter
*
error_reporter
,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
)
{
CheckParsePointerParams
(
op
,
error_reporter
,
allocator
,
builtin_data
);
SafeBuiltinDataAllocator
safe_allocator
(
allocator
);
std
::
unique_ptr
<
TfLiteCallOnceParams
,
SafeBuiltinDataAllocator
::
BuiltinDataDeleter
>
params
=
safe_allocator
.
Allocate
<
TfLiteCallOnceParams
>
();
TF_LITE_ENSURE
(
error_reporter
,
params
!=
nullptr
);
const
CallOnceOptions
*
schema_params
=
op
->
builtin_options_as_CallOnceOptions
();
if
(
schema_params
!=
nullptr
)
{
params
->
init_subgraph_index
=
schema_params
->
init_subgraph_index
();
}
else
{
// TODO(b/157480169): We should either return kTfLiteError or fill in some
// reasonable defaults in the params struct. We are not doing so until we
// better undertand the ramifications of changing the legacy behavior.
}
*
builtin_data
=
params
.
release
();
return
kTfLiteOk
;
}
// We have this parse function instead of directly returning kTfLiteOk from the
// switch-case in ParseOpData because this function is used as part of the
// selective registration for the OpResolver implementation in micro.
...
...
@@ -1663,6 +1687,14 @@ TfLiteStatus ParseQuantize(const Operator*, ErrorReporter*,
return
kTfLiteOk
;
}
// We have this parse function instead of directly returning kTfLiteOk from the
// switch-case in ParseOpData because this function is used as part of the
// selective registration for the OpResolver implementation in micro.
TfLiteStatus
ParseReadVariable
(
const
Operator
*
,
ErrorReporter
*
,
BuiltinDataAllocator
*
,
void
**
)
{
return
kTfLiteOk
;
}
TfLiteStatus
ParseReducer
(
const
Operator
*
op
,
ErrorReporter
*
error_reporter
,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
)
{
...
...
@@ -2179,6 +2211,33 @@ TfLiteStatus ParseUnpack(const Operator* op, ErrorReporter* error_reporter,
return
kTfLiteOk
;
}
TfLiteStatus
ParseVarHandle
(
const
Operator
*
op
,
ErrorReporter
*
error_reporter
,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
)
{
CheckParsePointerParams
(
op
,
error_reporter
,
allocator
,
builtin_data
);
SafeBuiltinDataAllocator
safe_allocator
(
allocator
);
std
::
unique_ptr
<
TfLiteVarHandleParams
,
SafeBuiltinDataAllocator
::
BuiltinDataDeleter
>
params
=
safe_allocator
.
Allocate
<
TfLiteVarHandleParams
>
();
TF_LITE_ENSURE
(
error_reporter
,
params
!=
nullptr
);
const
VarHandleOptions
*
schema_params
=
op
->
builtin_options_as_VarHandleOptions
();
if
(
schema_params
!=
nullptr
)
{
params
->
container
=
schema_params
->
container
()
->
c_str
();
params
->
shared_name
=
schema_params
->
shared_name
()
->
c_str
();
}
else
{
// TODO(b/157480169): We should either return kTfLiteError or fill in some
// reasonable defaults in the params struct. We are not doing so until we
// better undertand the ramifications of changing the legacy behavior.
}
*
builtin_data
=
params
.
release
();
return
kTfLiteOk
;
}
// We have this parse function instead of directly returning kTfLiteOk from the
// switch-case in ParseOpData because this function is used as part of the
// selective registration for the OpResolver implementation in micro.
...
...
tensorflow/lite/core/api/flatbuffer_conversions.h
浏览文件 @
2925fc5e
...
...
@@ -84,6 +84,11 @@ TfLiteStatus ParseArgMax(const Operator* op, ErrorReporter* error_reporter,
TfLiteStatus
ParseArgMin
(
const
Operator
*
op
,
ErrorReporter
*
error_reporter
,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
);
TfLiteStatus
ParseAssignVariable
(
const
Operator
*
op
,
ErrorReporter
*
error_reporter
,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
);
TfLiteStatus
ParseBatchMatMul
(
const
Operator
*
op
,
ErrorReporter
*
error_reporter
,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
);
...
...
@@ -93,6 +98,10 @@ TfLiteStatus ParseBatchToSpaceNd(const Operator* op,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
);
TfLiteStatus
ParseCallOnce
(
const
Operator
*
op
,
ErrorReporter
*
error_reporter
,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
);
TfLiteStatus
ParseCeil
(
const
Operator
*
op
,
ErrorReporter
*
error_reporter
,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
);
...
...
@@ -261,6 +270,11 @@ TfLiteStatus ParseQuantize(const Operator* op, ErrorReporter* error_reporter,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
);
TfLiteStatus
ParseReadVariable
(
const
Operator
*
op
,
ErrorReporter
*
error_reporter
,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
);
TfLiteStatus
ParseReducer
(
const
Operator
*
op
,
ErrorReporter
*
error_reporter
,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
);
...
...
@@ -356,6 +370,11 @@ TfLiteStatus ParseUnidirectionalSequenceLSTM(const Operator* op,
ErrorReporter
*
error_reporter
,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
);
TfLiteStatus
ParseVarHandle
(
const
Operator
*
op
,
ErrorReporter
*
error_reporter
,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
);
TfLiteStatus
ParseZerosLike
(
const
Operator
*
op
,
ErrorReporter
*
error_reporter
,
BuiltinDataAllocator
*
allocator
,
void
**
builtin_data
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录