Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
12dfca71
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看板
提交
12dfca71
编写于
8月 25, 2020
作者:
Q
qianlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix softdvpp coredump
上级
ac239b65
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
57 addition
and
16 deletion
+57
-16
mindspore/ccsrc/minddata/dataset/kernels/image/soft_dvpp/utils/soft_dp.cc
...minddata/dataset/kernels/image/soft_dvpp/utils/soft_dp.cc
+28
-1
mindspore/ccsrc/minddata/dataset/kernels/image/soft_dvpp/utils/soft_jpegd.cc
...ddata/dataset/kernels/image/soft_dvpp/utils/soft_jpegd.cc
+10
-3
mindspore/ccsrc/minddata/dataset/kernels/image/soft_dvpp/utils/soft_vpc.cc
...inddata/dataset/kernels/image/soft_dvpp/utils/soft_vpc.cc
+9
-9
mindspore/dataset/transforms/vision/c_transforms.py
mindspore/dataset/transforms/vision/c_transforms.py
+6
-0
tests/ut/python/dataset/test_soft_dvpp.py
tests/ut/python/dataset/test_soft_dvpp.py
+4
-3
未找到文件。
mindspore/ccsrc/minddata/dataset/kernels/image/soft_dvpp/utils/soft_dp.cc
浏览文件 @
12dfca71
...
...
@@ -18,10 +18,22 @@
#include "minddata/dataset/kernels/image/soft_dvpp/utils/soft_dp_check.h"
#include "minddata/dataset/kernels/image/soft_dvpp/utils/soft_jpegd.h"
#include "minddata/dataset/kernels/image/soft_dvpp/utils/soft_vpc.h"
#include <thread>
const
int32_t
decodeSucc
=
0
;
const
int32_t
checkParamErr
=
1
;
const
int32_t
num2
=
2
;
uint32_t
DecodeAndResizeJpeg
(
SoftDpProcsessInfo
*
soft_dp_process_info
)
{
if
(
soft_dp_process_info
==
nullptr
||
soft_dp_process_info
->
input_buffer
==
nullptr
||
soft_dp_process_info
->
input_buffer_size
<=
0
||
soft_dp_process_info
->
output_buffer
==
nullptr
||
soft_dp_process_info
->
output_buffer_size
<=
0
)
{
API_LOGE
(
"The input buffer or out buffer is null or size is 0"
);
return
checkParamErr
;
}
if
(
soft_dp_process_info
->
output_width
%
2
==
1
||
soft_dp_process_info
->
output_height
%
2
==
1
)
{
API_LOGE
(
"odd width and height dose not support"
);
return
checkParamErr
;
}
VpcInfo
vpc_input_info
;
SoftJpegd
soft_handler
;
int32_t
ret
=
soft_handler
.
JpegdSoftwareDecodeProcess
(
&
vpc_input_info
,
soft_dp_process_info
);
...
...
@@ -47,6 +59,12 @@ uint32_t DecodeAndResizeJpeg(SoftDpProcsessInfo *soft_dp_process_info) {
}
uint32_t
DecodeAndCropAndResizeJpeg
(
SoftDpProcsessInfo
*
soft_dp_process_info
,
const
SoftDpCropInfo
&
crop_info
)
{
if
(
soft_dp_process_info
==
nullptr
||
soft_dp_process_info
->
input_buffer
==
nullptr
||
soft_dp_process_info
->
input_buffer_size
<=
0
||
soft_dp_process_info
->
output_buffer
==
nullptr
||
soft_dp_process_info
->
output_buffer_size
<=
0
)
{
API_LOGE
(
"The input buffer or out buffer is null or size is 0"
);
return
checkParamErr
;
}
VpcInfo
vpc_input_info
;
SoftJpegd
soft_handler
;
...
...
@@ -63,6 +81,15 @@ uint32_t DecodeAndCropAndResizeJpeg(SoftDpProcsessInfo *soft_dp_process_info, co
output
.
height
=
soft_dp_process_info
->
output_height
;
SoftDpCropInfo
crop
=
crop_info
;
if
((
vpc_input_info
.
real_width
%
num2
==
1
)
&&
((
uint32_t
)
vpc_input_info
.
real_width
==
crop
.
right
))
{
API_LOGD
(
"crop width is equal the real width."
);
crop
.
right
=
vpc_input_info
.
real_width
-
1
;
}
if
((
vpc_input_info
.
real_height
%
num2
==
1
)
&&
((
uint32_t
)
vpc_input_info
.
real_height
==
crop
.
down
))
{
API_LOGD
(
"crop height is equal the real height."
);
crop
.
down
=
vpc_input_info
.
real_height
-
1
;
}
SoftVpc
soft_vpc
;
ret
=
soft_vpc
.
Process
(
vpc_input_info
,
crop
,
output
);
return
ret
;
...
...
mindspore/ccsrc/minddata/dataset/kernels/image/soft_dvpp/utils/soft_jpegd.cc
浏览文件 @
12dfca71
...
...
@@ -26,6 +26,7 @@
#include <cstdint>
#include <cstdio>
#include <string>
#include <thread>
const
uint32_t
yuv400UvValue
=
0x80
;
const
int32_t
num2
=
2
;
...
...
@@ -129,13 +130,17 @@ uint32_t SoftJpegd::AllocOutputBuffer(struct VpcInfo *vpc_input_info, int32_t *w
int32_t
*
sub_sample
)
{
CheckInputParam
(
*
height
,
*
width
);
uint32_t
output_size
=
tjBufSizeYUV2
(
*
width
,
decodePadding
,
*
height
,
*
sub_sample
);
JPEGD_LOGD
(
"In this case the format= %d, output size=%d, real width=%d, the real height=%d, thread_id=%lu."
,
vpc_input_info
->
format
,
output_size
,
*
width
,
*
height
,
std
::
this_thread
::
get_id
());
if
(
output_size
==
zeroBufSize
)
{
JPEGD_LOGE
(
"get outbuffer size failed!"
);
return
decodeErr
;
}
if
(
vpc_input_info
->
is_fake420
)
{
output_size
=
output_size
*
channel3
/
num2
;
*
width
=
AlignUp
(
*
width
,
num2
);
*
height
=
AlignUp
(
*
height
,
num2
);
output_size
=
(
*
width
)
*
(
*
height
)
*
channel3
/
num2
;
}
soft_decode_out_buf_
=
new
(
std
::
nothrow
)
uint8_t
[
output_size
];
...
...
@@ -172,7 +177,8 @@ uint32_t SoftJpegd::ConfigVpcInputData(struct VpcInfo *vpc_input_info, int32_t *
int32_t
uv_size
=
vpc_input_info
->
width
*
vpc_input_info
->
height
/
num2
;
int32_t
safe_ret
=
memset_s
(
reinterpret_cast
<
void
*>
((
uintptr_t
)
u_start
),
uv_size
,
yuv400UvValue
,
uv_size
);
if
(
safe_ret
!=
0
)
{
JPEGD_LOGE
(
"config yuv400 uv memory failed."
);
JPEGD_LOGE
(
"config yuv400 uv memory failed.addr = 0x%llx, thread id = %lu"
,
soft_decode_out_buf_
,
std
::
this_thread
::
get_id
());
delete
[]
soft_decode_out_buf_
;
soft_decode_out_buf_
=
nullptr
;
vpc_input_info
->
addr
=
nullptr
;
...
...
@@ -229,7 +235,8 @@ uint32_t SoftJpegd::JpegdSoftwareDecodeProcess(struct VpcInfo *vpc_input_info,
tjDecompressToYUV2
(
handle
,
soft_dp_process_info
->
input_buffer
,
soft_dp_process_info
->
input_buffer_size
,
soft_decode_out_buf_
,
width
,
decodePadding
,
height
,
JDCT_ISLOW
);
if
(
decode_res
!=
decodeSucc
)
{
JPEGD_LOGE
(
"Decompress jpeg failed."
);
JPEGD_LOGE
(
"Decompress jpeg failed, addr is 0x%llx, thread id= %lu."
,
soft_decode_out_buf_
,
std
::
this_thread
::
get_id
());
delete
[]
soft_decode_out_buf_
;
soft_decode_out_buf_
=
nullptr
;
DestoryLibjpegSource
(
&
libjpeg_handler
,
handle
);
...
...
mindspore/ccsrc/minddata/dataset/kernels/image/soft_dvpp/utils/soft_vpc.cc
浏览文件 @
12dfca71
...
...
@@ -109,21 +109,21 @@ int32_t SoftVpc::CheckParamter() {
uint32_t
out_width
=
out_width_
;
uint32_t
out_height
=
out_height_
;
bool
flag
=
(
out_width
*
16
>=
crop_width
)
?
true
:
false
;
// Up to 16x magnification
bool
flag
=
(
out_width
*
32
>=
crop_width
)
?
true
:
false
;
// A maximum of 32x zoom-out
VPC_CHECK_COND_FAIL_PRINT_RETURN
(
flag
,
dpFail
,
"Max reduction multiple is 32. Please check left(%u), right(%u), out_width(%u)."
,
left_
,
right_
,
out_width
);
// Up to 16x magnification
flag
=
(
crop_width
*
16
>=
out_width
)
?
true
:
false
;
VPC_CHECK_COND_FAIL_PRINT_RETURN
(
flag
,
dpFail
,
"Max magnification is 16. Please check left(%u), right(%u), out_width(%u)."
,
left_
,
right_
,
out_width
);
flag
=
(
crop_width
*
32
>=
out_width
)
?
true
:
false
;
// A maximum of 32x zoom-out
VPC_CHECK_COND_FAIL_PRINT_RETURN
(
flag
,
dpFail
,
"Max reduction multiple is 32. Please check left(%u), right(%u), out_width(%u)."
,
left_
,
right_
,
out_width
);
flag
=
(
out_height
*
16
>=
crop_height
)
?
true
:
false
;
// Up to 16x magnification
VPC_CHECK_COND_FAIL_PRINT_RETURN
(
flag
,
dpFail
,
"Max magnification is 16. Please check up(%u), down(%u), out_height(%u)."
,
up_
,
down_
,
out_height
);
flag
=
(
crop_height
*
32
>=
out_height
)
?
true
:
false
;
// A maximum of 32x zoom-out
flag
=
(
out_height
*
32
>=
crop_height
)
?
true
:
false
;
// A maximum of 32x zoom-out
VPC_CHECK_COND_FAIL_PRINT_RETURN
(
flag
,
dpFail
,
"Max reduction multiple is 32. Please check up(%u), down(%u), out_height(%u)."
,
up_
,
down_
,
out_height
);
flag
=
(
crop_height
*
16
>=
out_height
)
?
true
:
false
;
// Up to 16x magnification
VPC_CHECK_COND_FAIL_PRINT_RETURN
(
flag
,
dpFail
,
"Max magnification is 16. Please check up(%u), down(%u), out_height(%u)."
,
up_
,
down_
,
out_height
);
return
dpSucc
;
}
...
...
mindspore/dataset/transforms/vision/c_transforms.py
浏览文件 @
12dfca71
...
...
@@ -980,6 +980,9 @@ class SoftDvppDecodeResizeJpeg(cde.SoftDvppDecodeResizeJpegOp):
When training, the DVPP of the ascend chip is not used,
and the DVPP of the ascend chip is used during inference,
and the accuracy of inference is lower than the accuracy of training.
And the input image size should be in range [32*32, 8192*8192].
The zoom-out and zoom-in multiples of the image length and width should in range [1/32, 16].
Only images with an even resolution can be output. The output of odd resolution is not supported.
Args:
size (Union[int, sequence]): The output size of the resized image.
...
...
@@ -1002,6 +1005,9 @@ class SoftDvppDecodeRandomCropResizeJpeg(cde.SoftDvppDecodeRandomCropResizeJpegO
ascend series chip DVPP module.
The usage scenario is consistent with SoftDvppDecodeReiszeJpeg.
And the input image size should be in range [32*32, 8192*8192].
The zoom-out and zoom-in multiples of the image length and width should in range [1/32, 16].
Only images with an even resolution can be output. The output of odd resolution is not supported.
Args:
size (Union[int, sequence]): The size of the output image.
...
...
tests/ut/python/dataset/test_soft_dvpp.py
浏览文件 @
12dfca71
...
...
@@ -84,6 +84,7 @@ def test_soft_dvpp_decode_random_crop_resize_jpeg(plot=False):
visualize_image
(
image1
,
image2
,
mse
)
num_iter
+=
1
def
test_soft_dvpp_decode_resize_jpeg_supplement
(
plot
=
False
):
"""
Test SoftDvppDecodeResizeJpeg op
...
...
@@ -93,12 +94,12 @@ def test_soft_dvpp_decode_resize_jpeg_supplement(plot=False):
# First dataset
data1
=
ds
.
TFRecordDataset
(
DATA_DIR
,
SCHEMA_DIR
,
columns_list
=
[
"image"
],
shuffle
=
False
)
decode_op
=
vision
.
Decode
()
resize_op
=
vision
.
Resize
(
256
)
resize_op
=
vision
.
Resize
(
1134
)
data1
=
data1
.
map
(
input_columns
=
[
"image"
],
operations
=
[
decode_op
,
resize_op
])
# Second dataset
data2
=
ds
.
TFRecordDataset
(
DATA_DIR
,
SCHEMA_DIR
,
columns_list
=
[
"image"
],
shuffle
=
False
)
soft_dvpp_decode_resize_op
=
vision
.
SoftDvppDecodeResizeJpeg
(
256
)
soft_dvpp_decode_resize_op
=
vision
.
SoftDvppDecodeResizeJpeg
(
1134
)
data2
=
data2
.
map
(
input_columns
=
[
"image"
],
operations
=
soft_dvpp_decode_resize_op
)
num_iter
=
0
...
...
@@ -114,8 +115,8 @@ def test_soft_dvpp_decode_resize_jpeg_supplement(plot=False):
visualize_image
(
image1
,
image2
,
mse
)
num_iter
+=
1
if
__name__
==
"__main__"
:
test_soft_dvpp_decode_resize_jpeg
(
plot
=
True
)
test_soft_dvpp_decode_random_crop_resize_jpeg
(
plot
=
True
)
test_soft_dvpp_decode_resize_jpeg_supplement
(
plot
=
True
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录