forked from mindspore-Ecosystem/mindspore
!14558 fix export mindir failure for fasterrcnn
From: @zhouneng2 Reviewed-by: @linqingke,@liangchenghui Signed-off-by: @linqingke
This commit is contained in:
commit
010cc0cecd
|
@ -284,19 +284,24 @@ int AclProcess::ModelInfer(std::map<double, double> *costTime_map) {
|
|||
heightScale = static_cast<float>(resizeOutData->height) / inputImg->height;
|
||||
}
|
||||
|
||||
float im_info[4];
|
||||
im_info[0] = static_cast<float>(inputImg->height);
|
||||
im_info[1] = static_cast<float>(inputImg->width);
|
||||
im_info[2] = heightScale;
|
||||
im_info[3] = widthScale;
|
||||
aclFloat16 inputWidth = aclFloatToFloat16(static_cast<float>(inputImg->width));
|
||||
aclFloat16 inputHeight = aclFloatToFloat16(static_cast<float>(inputImg->height));
|
||||
aclFloat16 resizeWidthRatioFp16 = aclFloatToFloat16(widthScale);
|
||||
aclFloat16 resizeHeightRatioFp16 = aclFloatToFloat16(heightScale);
|
||||
|
||||
aclFloat16 *im_info = reinterpret_cast<aclFloat16 *>(malloc(sizeof(aclFloat16) * 4));
|
||||
im_info[0] = inputHeight;
|
||||
im_info[1] = inputWidth;
|
||||
im_info[2] = resizeHeightRatioFp16;
|
||||
im_info[3] = resizeWidthRatioFp16;
|
||||
void *imInfo_dst = nullptr;
|
||||
int ret = aclrtMalloc(&imInfo_dst, 16, ACL_MEM_MALLOC_NORMAL_ONLY);
|
||||
int ret = aclrtMalloc(&imInfo_dst, 8, ACL_MEM_MALLOC_NORMAL_ONLY);
|
||||
if (ret != ACL_ERROR_NONE) {
|
||||
std::cout << "aclrtMalloc failed, ret = " << ret << std::endl;
|
||||
aclrtFree(imInfo_dst);
|
||||
return ret;
|
||||
}
|
||||
ret = aclrtMemcpy(reinterpret_cast<uint8_t *>(imInfo_dst), 16, im_info, 16, ACL_MEMCPY_HOST_TO_DEVICE);
|
||||
ret = aclrtMemcpy(reinterpret_cast<uint8_t *>(imInfo_dst), 8, im_info, 8, ACL_MEMCPY_HOST_TO_DEVICE);
|
||||
if (ret != ACL_ERROR_NONE) {
|
||||
std::cout << "aclrtMemcpy failed, ret = " << ret << std::endl;
|
||||
aclrtFree(imInfo_dst);
|
||||
|
|
|
@ -17,6 +17,7 @@ import argparse
|
|||
import numpy as np
|
||||
|
||||
import mindspore as ms
|
||||
import mindspore.common.dtype as mstype
|
||||
from mindspore import Tensor, load_checkpoint, load_param_into_net, export, context
|
||||
|
||||
from src.FasterRcnn.faster_rcnn_r50 import FasterRcnn_Infer
|
||||
|
@ -46,6 +47,10 @@ if __name__ == '__main__':
|
|||
|
||||
load_param_into_net(net, param_dict_new)
|
||||
|
||||
device_type = "Ascend" if context.get_context("device_target") == "Ascend" else "Others"
|
||||
if device_type == "Ascend":
|
||||
net.to_float(mstype.float16)
|
||||
|
||||
img = Tensor(np.zeros([config.test_batch_size, 3, config.img_height, config.img_width]), ms.float32)
|
||||
img_metas = Tensor(np.random.uniform(0.0, 1.0, size=[config.test_batch_size, 4]), ms.float32)
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ def get_eval_result(ann_file):
|
|||
label_result_file = result_path + file_id + "_1.bin"
|
||||
mask_result_file = result_path + file_id + "_2.bin"
|
||||
|
||||
all_bbox = np.fromfile(bbox_result_file, dtype=np.float32).reshape(80000, 5)
|
||||
all_bbox = np.fromfile(bbox_result_file, dtype=np.float16).reshape(80000, 5)
|
||||
all_label = np.fromfile(label_result_file, dtype=np.int32).reshape(80000, 1)
|
||||
all_mask = np.fromfile(mask_result_file, dtype=np.bool_).reshape(80000, 1)
|
||||
|
||||
|
|
Loading…
Reference in New Issue