Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
42c80025
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
42c80025
编写于
8月 24, 2020
作者:
H
hangq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add getFloatData function
上级
6c309d8f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
3 deletion
+27
-3
mindspore/lite/java/build_aar.sh
mindspore/lite/java/build_aar.sh
+3
-3
mindspore/lite/java/java/app/src/main/java/com/mindspore/lite/MSTensor.java
...a/java/app/src/main/java/com/mindspore/lite/MSTensor.java
+24
-0
未找到文件。
mindspore/lite/java/build_aar.sh
浏览文件 @
42c80025
...
...
@@ -15,10 +15,10 @@ fi
# copy arm64 so
cd
${
TOP_PATH
}
/output/
rm
-rf
mindspore-lite-0.
6
.0
tar
-zxvf
mindspore-lite-0.
6
.0-runtime-arm64-cpu.tar.gz
rm
-rf
mindspore-lite-0.
7
.0
tar
-zxvf
mindspore-lite-0.
7
.0-runtime-arm64-cpu.tar.gz
mkdir
-p
${
BASE_PATH
}
/lib/
cp
${
TOP_PATH
}
/output/mindspore-lite-0.
6
.0/lib/libmindspore-lite.so
${
BASE_PATH
}
/lib/
cp
${
TOP_PATH
}
/output/mindspore-lite-0.
7
.0/lib/libmindspore-lite.so
${
BASE_PATH
}
/lib/
cp
${
ANDROID_NDK
}
/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so
${
BASE_PATH
}
/lib/
# build jni so
...
...
mindspore/lite/java/java/app/src/main/java/com/mindspore/lite/MSTensor.java
浏览文件 @
42c80025
...
...
@@ -16,6 +16,8 @@
package
com.mindspore.lite
;
import
android.util.Log
;
public
class
MSTensor
{
private
long
tensorPtr
;
...
...
@@ -52,6 +54,10 @@ public class MSTensor {
return
this
.
getData
(
this
.
tensorPtr
);
}
public
float
[]
getFloatData
()
{
return
decodeBytes
(
this
.
getData
(
this
.
tensorPtr
));
}
public
void
setData
(
byte
[]
data
)
{
this
.
setData
(
this
.
tensorPtr
,
data
,
data
.
length
);
}
...
...
@@ -69,6 +75,24 @@ public class MSTensor {
this
.
tensorPtr
=
0
;
}
private
float
[]
decodeBytes
(
byte
[]
bytes
)
{
if
(
bytes
.
length
%
4
!=
0
)
{
Log
.
e
(
"MS_LITE"
,
"Length of bytes should be multi of 4 "
);
return
null
;
}
int
size
=
bytes
.
length
/
4
;
float
[]
ret
=
new
float
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
=
i
+
4
)
{
int
accNum
=
0
;
accNum
=
accNum
|
(
bytes
[
i
]
&
0xff
)
<<
0
;
accNum
=
accNum
|
(
bytes
[
i
+
1
]
&
0xff
)
<<
8
;
accNum
=
accNum
|
(
bytes
[
i
+
2
]
&
0xff
)
<<
16
;
accNum
=
accNum
|
(
bytes
[
i
+
3
]
&
0xff
)
<<
24
;
ret
[
i
/
4
]
=
Float
.
intBitsToFloat
(
accNum
);
}
return
ret
;
}
private
native
long
createMSTensor
(
int
dataType
,
int
[]
shape
,
int
shapeLen
);
private
native
int
[]
getShape
(
long
tensorPtr
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录