Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
曾经的那一瞬间
Tensorflow
提交
ffd3326d
T
Tensorflow
项目概览
曾经的那一瞬间
/
Tensorflow
10 个月 前同步成功
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Tensorflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ffd3326d
编写于
8月 30, 2023
作者:
A
Alan Kelly
提交者:
TensorFlower Gardener
8月 30, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cast Int4->Float32 bench
PiperOrigin-RevId: 561274977
上级
c4f212a0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
70 addition
and
22 deletion
+70
-22
tensorflow/lite/kernels/BUILD
tensorflow/lite/kernels/BUILD
+16
-0
tensorflow/lite/kernels/cast_test.cc
tensorflow/lite/kernels/cast_test.cc
+1
-22
tensorflow/lite/kernels/cast_test_common.h
tensorflow/lite/kernels/cast_test_common.h
+53
-0
未找到文件。
tensorflow/lite/kernels/BUILD
浏览文件 @
ffd3326d
...
...
@@ -1292,12 +1292,28 @@ cc_test(
],
)
cc_library
(
name
=
"cast_test_common"
,
testonly
=
1
,
hdrs
=
[
"cast_test_common.h"
,
],
deps
=
[
":test_util"
,
"//tensorflow/lite:string"
,
"//tensorflow/lite/schema:schema_fbs"
,
"@com_google_absl//absl/types:span"
,
"@flatbuffers"
,
],
)
cc_test
(
name
=
"cast_test"
,
size
=
"small"
,
srcs
=
[
"cast_test.cc"
],
tags
=
[
"tflite_nnapi"
],
deps
=
[
":cast_test_common"
,
":test_main"
,
":test_util"
,
"//tensorflow/lite/core/c:c_api_types"
,
...
...
tensorflow/lite/kernels/cast_test.cc
浏览文件 @
ffd3326d
...
...
@@ -24,6 +24,7 @@ limitations under the License.
#include "absl/types/span.h"
#include "flatbuffers/flatbuffers.h" // from @flatbuffers
#include "tensorflow/lite/core/c/c_api_types.h"
#include "tensorflow/lite/kernels/cast_test_common.h"
#include "tensorflow/lite/kernels/test_util.h"
#include "tensorflow/lite/schema/schema_generated.h"
...
...
@@ -32,28 +33,6 @@ namespace {
using
::
testing
::
ElementsAreArray
;
class
CastOpModel
:
public
SingleOpModel
{
public:
CastOpModel
(
const
TensorData
&
input
,
const
TensorData
&
output
)
{
input_
=
AddInput
(
input
);
output_
=
AddOutput
(
output
);
SetBuiltinOp
(
BuiltinOperator_CAST
,
BuiltinOptions_CastOptions
,
CreateCastOptions
(
builder_
).
Union
());
BuildInterpreter
({
GetShape
(
input_
)});
}
void
Set4BitInput
(
absl
::
Span
<
const
int8_t
>
f
)
{
PopulateTensor4bit
(
input_
,
0
,
f
.
data
(),
f
.
data
()
+
f
.
size
());
}
int
input
()
const
{
return
input_
;
}
int
output
()
const
{
return
output_
;
}
protected:
int
input_
;
int
output_
;
};
TEST
(
CastOpModel
,
CastInt4ToFloat
)
{
CastOpModel
m
({
TensorType_INT4
,
{
2
,
3
}},
{
TensorType_FLOAT32
,
{
2
,
3
}});
m
.
Set4BitInput
({
1
,
2
,
3
,
4
,
5
,
6
});
...
...
tensorflow/lite/kernels/cast_test_common.h
0 → 100644
浏览文件 @
ffd3326d
/* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_KERNELS_CAST_TEST_COMMON_H_
#define TENSORFLOW_LITE_KERNELS_CAST_TEST_COMMON_H_
#include <stdint.h>
#include <vector>
#include "absl/types/span.h"
#include "tensorflow/lite/kernels/test_util.h"
#include "tensorflow/lite/schema/schema_generated.h"
namespace
tflite
{
using
::
testing
::
ElementsAreArray
;
class
CastOpModel
:
public
SingleOpModel
{
public:
CastOpModel
(
const
TensorData
&
input
,
const
TensorData
&
output
)
{
input_
=
AddInput
(
input
);
output_
=
AddOutput
(
output
);
SetBuiltinOp
(
BuiltinOperator_CAST
,
BuiltinOptions_CastOptions
,
CreateCastOptions
(
builder_
).
Union
());
BuildInterpreter
({
GetShape
(
input_
)});
}
void
Set4BitInput
(
absl
::
Span
<
const
int8_t
>
f
)
{
PopulateTensor4bit
(
input_
,
0
,
f
.
data
(),
f
.
data
()
+
f
.
size
());
}
int
input
()
const
{
return
input_
;
}
int
output
()
const
{
return
output_
;
}
protected:
int
input_
;
int
output_
;
};
}
// namespace tflite
#endif // TENSORFLOW_LITE_KERNELS_CAST_TEST_COMMON_H_
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录