fix lite cv resize bilinear fuzz bug

This commit is contained in:
xiefangqi 2021-11-02 09:16:01 +08:00
parent d4e77ed507
commit 8a28ad1aa5
3 changed files with 13 additions and 3 deletions

View File

@ -379,6 +379,9 @@ bool ResizeBilinear(const LiteMat &src, LiteMat &dst, int dst_w, int dst_h) {
}
if (dst.IsEmpty()) {
(void)dst.Init(dst_w, dst_h, src.channel_, LDataType::UINT8);
if (dst.IsEmpty()) {
return false;
}
} else if (dst.height_ != dst_h || dst.width_ != dst_w || dst.channel_ != src.channel_) {
return false;
} else if (dst.data_type_ != LDataType::UINT8) {
@ -965,10 +968,17 @@ bool Merge(const std::vector<LiteMat> &mv, LiteMat &dst) {
return true;
}
inline bool CheckInt(const std::vector<int> &nums) {
if (std::any_of(nums.begin(), nums.end(), [](const auto &num) { return num < 0; })) {
return false;
}
return true;
}
bool Pad(const LiteMat &src, LiteMat &dst, int top, int bottom, int left, int right, PaddBorderType pad_type,
uint8_t fill_b_or_gray, uint8_t fill_g, uint8_t fill_r) {
RETURN_FALSE_IF_LITEMAT_EMPTY(src);
if (top < 0 || bottom < 0 || left < 0 || right < 0) {
if (!CheckInt({top, bottom, left, right})) {
return false;
}
if (src.width_ > std::numeric_limits<int>::max() - left ||

View File

@ -364,7 +364,7 @@ class Dataset:
def notify_watchdog(self):
"""
Close watchdog thread in dataset. Now GeneratorDataset/map/batch will use a thread named watch_dog tp monitor
Close watchdog thread in dataset. Now GeneratorDataset/map/batch will use a thread named watch_dog to monitor
multiprocess, for get_dataset_size/output_shapes/output_types/get_col_name/num_classes, we need notify_watchdog
to close watch_dog thread manually.
"""

View File

@ -211,7 +211,7 @@ def test_resnet_thor_imagenet_8p():
"""
Feature: Resnet50 thor network
Description: Train and evaluate resnet50 thor network on imagenet dataset
Expectation: accuracy > 0.28, time cost < 22.
Expectation: accuracy > 0.28, time cost < 25.
"""
context.set_context(enable_graph_kernel=False, enable_sparse=False)
context.reset_auto_parallel_context()