Browse Source

!15277 fix fuzz bug & codex

From: @hangangqiang
Reviewed-by: @jpc_chenjianping,@zhanghaibo5
Signed-off-by: @zhanghaibo5
pull/15277/MERGE
mindspore-ci-bot Gitee 4 years ago
parent
commit
6f0dd0329c
34 changed files with 102 additions and 114 deletions
  1. +7
    -2
      mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32_grad/layernorm_grad.c
  2. +2
    -2
      mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32_grad/layernorm_grad.h
  3. +0
    -1
      mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/infer/arithmetic_infer.c
  4. +4
    -4
      mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/infer/strided_slice_grad_infer.c
  5. +0
    -7
      mindspore/lite/examples/export_models/models/effnet.py
  6. +0
    -1
      mindspore/lite/examples/export_models/models/mobilenetv2_train_export.py
  7. +2
    -2
      mindspore/lite/examples/quick_start_cpp/build.sh
  8. +2
    -2
      mindspore/lite/examples/quick_start_java/build.sh
  9. +2
    -2
      mindspore/lite/examples/runtime_cpp/build.sh
  10. +2
    -2
      mindspore/lite/src/common/tensor_util.cc
  11. +23
    -1
      mindspore/lite/src/lite_model.cc
  12. +5
    -1
      mindspore/lite/src/lite_model.h
  13. +0
    -41
      mindspore/lite/src/ops/populate/depthwise_conv2d_populate.cc
  14. +0
    -2
      mindspore/lite/src/ops/populate/mul_populate.cc
  15. +0
    -2
      mindspore/lite/src/runtime/kernel/arm/fp32_grad/convolution.cc
  16. +6
    -1
      mindspore/lite/src/runtime/kernel/arm/fp32_grad/layernorm_grad.cc
  17. +2
    -2
      mindspore/lite/src/runtime/kernel/opencl/kernel/conv2d.cc
  18. +5
    -2
      mindspore/lite/src/runtime/kernel/opencl/utils.cc
  19. +1
    -1
      mindspore/lite/src/runtime/kernel/opencl/utils.h
  20. +11
    -3
      mindspore/lite/src/tensorlist.cc
  21. +1
    -1
      mindspore/lite/tools/anf_exporter/anf_exporter.cc
  22. +3
    -3
      mindspore/lite/tools/converter/converter_context.h
  23. +5
    -4
      mindspore/lite/tools/converter/parser/caffe/caffe_node_parser_registry.h
  24. +1
    -1
      mindspore/lite/tools/converter/parser/onnx/onnx_model_parser.cc
  25. +5
    -4
      mindspore/lite/tools/converter/parser/onnx/onnx_node_parser_registry.h
  26. +6
    -4
      mindspore/lite/tools/converter/parser/tf/tf_node_parser_registry.h
  27. +5
    -4
      mindspore/lite/tools/converter/parser/tflite/tflite_node_parser_registry.h
  28. +2
    -1
      mindspore/lite/tools/optimizer/fusion/conv_transform_fusion.cc
  29. +0
    -1
      model_zoo/official/lite/MindSpore_inhand/imageObject/src/main/cpp/SceneMindSporeNetnative.cpp
  30. +0
    -3
      model_zoo/official/lite/MindSpore_inhand/segmentation/src/main/java/com/mindspore/imagesegmentation/StyleRecyclerViewAdapter.java
  31. +0
    -1
      model_zoo/official/lite/MindSpore_inhand/segmentation/src/main/java/com/mindspore/imagesegmentation/help/TrackingMobile.java
  32. +0
    -1
      model_zoo/official/lite/image_segmentation/app/src/main/java/com/mindspore/imagesegmentation/help/TrackingMobile.java
  33. +0
    -1
      model_zoo/official/lite/scene_detection/app/src/main/cpp/MindSporeNetnative.cpp
  34. +0
    -4
      model_zoo/official/lite/style_transfer/app/src/main/java/com/mindspore/styletransferdemo/StyleTransferModelExecutor.java

+ 7
- 2
mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32_grad/layernorm_grad.c View File

@@ -16,12 +16,16 @@
#include "nnacl/fp32_grad/layernorm_grad.h"
#include <stddef.h>
#include <math.h>
#include "nnacl/errorcode.h"

void LayerNormGrad(const float *x, const float *dy, const float *var, const float *mean, const float *gamma,
int param_num, int param_size, int block_num, int block_size, float *dx, float *dg, float *db) {
int LayerNormGrad(const float *x, const float *dy, const float *var, const float *mean, const float *gamma,
int param_num, int param_size, int block_num, int block_size, float *dx, float *dg, float *db) {
// var is actually layer_norm forward output var
const float eps = 1e-12;
const float *var_sqrt_rev = var;
if (block_size <= 0) {
return NNACL_ERRCODE_DIVISOR_ZERO;
}
for (size_t i = 0; i < param_num; ++i) {
float dgamma = 0.0f;
float dbeta = 0.0f;
@@ -56,4 +60,5 @@ void LayerNormGrad(const float *x, const float *dy, const float *var, const floa
dx[index] = dx1 + dx2 + dx3;
}
}
return NNACL_OK;
}

+ 2
- 2
mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32_grad/layernorm_grad.h View File

@@ -20,8 +20,8 @@
extern "C" {
#endif

void LayerNormGrad(const float *x, const float *dy, const float *var, const float *mean, const float *gamma,
int param_num, int param_size, int block_num, int block_size, float *dx, float *dg, float *db);
int LayerNormGrad(const float *x, const float *dy, const float *var, const float *mean, const float *gamma,
int param_num, int param_size, int block_num, int block_size, float *dx, float *dg, float *db);

#ifdef __cplusplus
}


+ 0
- 1
mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/infer/arithmetic_infer.c View File

@@ -62,7 +62,6 @@ int ArithmeticInferShape(const TensorC *const *inputs, size_t inputs_size, Tenso
}
in_shape1_[i] = input_shape1[i];
}
// format = input0->format();
} else if (input_shape0_size > input_shape1_size) {
ndim_ = input_shape0_size;
int fill_dim_num = input_shape0_size - input_shape1_size;


+ 4
- 4
mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/infer/strided_slice_grad_infer.c View File

@@ -89,7 +89,7 @@ int StridedSliceGradInferShape(const TensorC *const *inputs, size_t inputs_size,
param->strides_[i] = strides_[i];
}
ShapeSet(param->in_shape_, &in_shape_size, input->shape_, input->shape_size_);
// ApplyNewAxisMask();
// ApplyNewAxisMask;
for (size_t i = 0; i < ndim_; i++) {
if (new_axis_mask_[i]) {
ndim_ += 1;
@@ -107,19 +107,19 @@ int StridedSliceGradInferShape(const TensorC *const *inputs, size_t inputs_size,
ellipsis_mask_[i] = false;
}
}
// ApplyBeginMask();
// ApplyBeginMask;
for (size_t i = 0; i < ndim_; i++) {
if (begins_mask_[i]) {
begins_[i] = 0;
}
}
// ApplyEndMask();
// ApplyEndMask;
for (size_t i = 0; i < ndim_; i++) {
if (ends_mask_[i]) {
ends_[i] = in_shape_[i];
}
}
// ApplyEllipsisMask();
// ApplyEllipsisMask;
for (size_t i = 0; i < ndim_; i++) {
if (ellipsis_mask_[i]) {
begins_[i] = 0;


+ 0
- 7
mindspore/lite/examples/export_models/models/effnet.py View File

@@ -49,7 +49,6 @@ class Swish(nn.Cell):
s = self.sigmoid(x)
m = x*s
return m
#return x * (1/(1+self.exp(-x)))
class AdaptiveAvgPool(nn.Cell):
@@ -75,7 +74,6 @@ class SELayer(nn.Cell):
self.act2 = nn.Sigmoid()
def construct(self, x):
#b, c, _, _ = x.shape()
o = self.avg_pool(x) #.view(b,c)
o = self.conv_reduce(o)
o = self.act1(o)
@@ -119,9 +117,6 @@ class DepthwiseSeparableConv(nn.Cell):
x = self.bn2(x)
if self.has_residual:
# if self.drop_connect_rate > 0.:
# x = x
# x = drop_connect(x, self.training, self.drop_connect_rate)
x += residual
return x
@@ -199,8 +194,6 @@ class InvertedResidual(nn.Cell):
x = self.bn3(x)
if self.has_residual:
# if self.drop_connect_rate > 0.:
# x = x
x += residual
return x


+ 0
- 1
mindspore/lite/examples/export_models/models/mobilenetv2_train_export.py View File

@@ -25,7 +25,6 @@ from mindspore.train.serialization import export
context.set_context(mode=context.PYNATIVE_MODE, device_target="GPU", save_graphs=False)
batch = 16

#n = MobileNetV2()
backbone_net = MobileNetV2Backbone()
head_net = MobileNetV2Head(input_channel=backbone_net.out_channels, num_classes=10)
n = mobilenet_v2(backbone_net, head_net)


+ 2
- 2
mindspore/lite/examples/quick_start_cpp/build.sh View File

@@ -14,7 +14,7 @@
# limitations under the License.
# ============================================================================

BASEPATH=$(cd "$(dirname $0)"; pwd)
BASEPATH=$(cd "$(dirname $0)" || exit; pwd)
get_version() {
VERSION_MAJOR=$(grep "const int ms_version_major =" ${BASEPATH}/../../include/version.h | tr -dc "[0-9]")
VERSION_MINOR=$(grep "const int ms_version_minor =" ${BASEPATH}/../../include/version.h | tr -dc "[0-9]")
@@ -39,6 +39,6 @@ fi
tar xzvf ${BASEPATH}/build/${MINDSPORE_FILE} -C ${BASEPATH}/build/
cp -r ${BASEPATH}/build/${MINDSPORE_FILE_NAME}/inference/lib/libmindspore-lite.a ${BASEPATH}/lib
cp -r ${BASEPATH}/build/${MINDSPORE_FILE_NAME}/inference/include ${BASEPATH}/
cd ${BASEPATH}/build
cd ${BASEPATH}/build || exit
cmake ${BASEPATH}
make

+ 2
- 2
mindspore/lite/examples/quick_start_java/build.sh View File

@@ -14,7 +14,7 @@
# limitations under the License.
# ============================================================================

BASEPATH=$(cd "$(dirname $0)"; pwd)
BASEPATH=$(cd "$(dirname $0)" || exit; pwd)
get_version() {
VERSION_MAJOR=$(grep "const int ms_version_major =" ${BASEPATH}/../../include/version.h | tr -dc "[0-9]")
VERSION_MINOR=$(grep "const int ms_version_minor =" ${BASEPATH}/../../include/version.h | tr -dc "[0-9]")
@@ -38,6 +38,6 @@ if [ ! -e ${BASEPATH}/build/${MINDSPORE_FILE} ]; then
fi
tar xzvf ${BASEPATH}/build/${MINDSPORE_FILE} -C ${BASEPATH}/build/
cp -r ${BASEPATH}/build/${MINDSPORE_FILE_NAME}/inference/lib/jar/* ${BASEPATH}/lib
cd ${BASEPATH}/
cd ${BASEPATH}/ || exit

mvn package

+ 2
- 2
mindspore/lite/examples/runtime_cpp/build.sh View File

@@ -24,7 +24,7 @@ usage()
}

BASEPATH=$(
cd "$(dirname $0)"
cd "$(dirname $0)" || exit
pwd
)
get_version() {
@@ -94,7 +94,7 @@ cp -r ${BASEPATH}/build/${MINDSPORE_FILE_NAME}/inference/include ${BASEPATH}/
if [[ "X${DEVICE}" == "Xnpu" ]]; then
cp -r ${BASEPATH}/build/${MINDSPORE_FILE_NAME}/inference/third_party/hiai_ddk/lib/*.so ${BASEPATH}/lib
fi
cd ${BASEPATH}/build
cd ${BASEPATH}/build || exit
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_NATIVE_API_LEVEL="19" \
-DANDROID_NDK="${ANDROID_NDK}" -DANDROID_ABI="arm64-v8a" -DANDROID_STL="c++_shared" ${BASEPATH} -DSUPPORT_NPU=${SUPPORT_NPU}



+ 2
- 2
mindspore/lite/src/common/tensor_util.cc View File

@@ -208,11 +208,11 @@ int GenerateInTensorC(const OpParameter *const parameter, const std::vector<lite
int CheckTensorsInvalid(const std::vector<Tensor *> &tensors) {
for (auto &tensor : tensors) {
if (tensor == nullptr) {
MS_LOG(ERROR) << "check tensor is nullptr";
MS_LOG(ERROR) << "Graph input tensor is nullptr";
return RET_ERROR;
}
if (tensor->data_type() != kObjectTypeTensorType && tensor->data_c() == nullptr) {
MS_LOG(ERROR) << "check tensor data is nullptr " << tensors;
MS_LOG(ERROR) << "Graph input tensor is nullptr " << tensors;
return RET_ERROR;
}
auto shape = tensor->shape();


+ 23
- 1
mindspore/lite/src/lite_model.cc View File

@@ -255,7 +255,29 @@ int LiteModel::SubGraphVerify() const {
return RET_OK;
}

bool LiteModel::ModelVerify() const { return NodeVerify() == RET_OK && SubGraphVerify() == RET_OK; }
bool LiteModel::ModelVerify() const {
if (this->sub_graphs_.empty()) {
MS_LOG(ERROR) << "Model does not have a main graph.";
return false;
}
auto main_graph = this->sub_graphs_.front();
for (auto input_index : main_graph->input_indices_) {
if (input_index >= this->all_tensors_.size()) {
MS_LOG(ERROR) << "Graph indices is beyond tensor_size.";
return false;
}
auto *tensor = this->all_tensors_.at(input_index);
if (tensor == nullptr) {
MS_LOG(ERROR) << "Tensor in all tensors is nullptr.";
return false;
}
if (tensor->format() != schema::Format_NHWC) {
MS_LOG(ERROR) << "Graph input tensor should be NHWC";
return false;
}
}
return NodeVerify() == RET_OK && SubGraphVerify() == RET_OK;
}

const void *LiteModel::GetMetaGraphByVerison() {
MS_ASSERT(this->buf != nullptr);


+ 5
- 1
mindspore/lite/src/lite_model.h View File

@@ -70,7 +70,11 @@ class LiteModel : public Model {
} else if (node->quant_type_ == schema::QuantType_WeightQuant) {
node->quant_type_ = schema::QuantType_QUANT_WEIGHT;
}
node->name_ = c_node->name()->c_str();
if (c_node->name() == nullptr) {
node->name_ = "";
} else {
node->name_ = c_node->name()->c_str();
}
auto count = c_node->inputIndex()->size();
for (uint32_t j = 0; j < count; ++j) {
node->input_indices_.push_back(size_t(c_node->inputIndex()->template GetAs<uint32_t>(j)));


+ 0
- 41
mindspore/lite/src/ops/populate/depthwise_conv2d_populate.cc View File

@@ -26,47 +26,6 @@ OpParameter *PopulateConvDwParameter(const void *primitive) {
return nullptr;
}
memset(conv_param, 0, sizeof(ConvParameter));
// conv_param->op_parameter_.type_ = primitive->Type();

// auto conv_primitive =
// reinterpret_cast<mindspore::lite::DepthwiseConv2D *>(const_cast<mindspore::lite::PrimitiveC *>(primitive));
// conv_param->kernel_h_ = conv_primitive->GetKernelH();
// conv_param->kernel_w_ = conv_primitive->GetKernelW();
// conv_param->stride_h_ = conv_primitive->GetStrideH();
// conv_param->stride_w_ = conv_primitive->GetStrideW();

// auto convdw_lite_primitive = (lite::DepthwiseConv2D *)primitive;
// conv_param->pad_u_ = convdw_lite_primitive->PadUp();
// conv_param->pad_d_ = convdw_lite_primitive->PadDown();
// conv_param->pad_l_ = convdw_lite_primitive->PadLeft();
// conv_param->pad_r_ = convdw_lite_primitive->PadRight();
// conv_param->input_channel_ = convdw_lite_primitive->GetInputChannel();
// conv_param->dilation_h_ = conv_primitive->GetDilateH();
// conv_param->dilation_w_ = conv_primitive->GetDilateW();
// auto pad_mode = conv_primitive->GetPadMode();
// switch (pad_mode) {
// case schema::PadMode_SAME_UPPER:
// conv_param->pad_mode_ = Pad_Same;
// break;
// case schema::PadMode_VALID:
// conv_param->pad_mode_ = Pad_Valid;
// break;
// default:
// conv_param->pad_mode_ = Pad_No;
// break;
// }
// auto act_type = conv_primitive->GetActivationType();
// switch (act_type) {
// case schema::ActivationType_RELU:
// conv_param->act_type_ = ActType_Relu;
// break;
// case schema::ActivationType_RELU6:
// conv_param->act_type_ = ActType_Relu6;
// break;
// default:
// conv_param->act_type_ = ActType_No;
// break;
// }
return reinterpret_cast<OpParameter *>(conv_param);
}
} // namespace lite


+ 0
- 2
mindspore/lite/src/ops/populate/mul_populate.cc View File

@@ -29,8 +29,6 @@ OpParameter *PopulateMulParameter(const void *prim) {
}
auto *primitive = static_cast<const schema::Primitive *>(prim);
param->op_parameter_.type_ = primitive->value_type();
// auto mul_prim = primitive->value_as_Mul();
// param->activation_type_ = mul_prim->activationType();
return reinterpret_cast<OpParameter *>(param);
}
} // namespace


+ 0
- 2
mindspore/lite/src/runtime/kernel/arm/fp32_grad/convolution.cc View File

@@ -115,8 +115,6 @@ int ConvolutionTrainCPUKernel::Execute(int task_id) {
for (int j = 0; j < groups; ++j) {
const float *mat_b = w_addr + j * nweights / groups;
float *mat_c = y_addr + (i * groups) * n * m + j * (out_ch / groups) + ci * out_ch;
// float *im = x_addr + i * in_ch * in_h * in_w + j * (in_ch / groups);
// RollingIm2ColPackUnitFp32(im, conv_param_, mat_a, real_chunk, ci);
GemmMatmul(0, 1, real_chunk, n, k, 1, mat_a + (j * kernel_spatial), k * groups, mat_b, k, 0, mat_c, out_ch,
mat_workspace);
}


+ 6
- 1
mindspore/lite/src/runtime/kernel/arm/fp32_grad/layernorm_grad.cc View File

@@ -21,6 +21,7 @@
#include "src/kernel_registry.h"
#include "nnacl/fp32_grad/layernorm_grad.h"
#include "nnacl/fp32_grad/layernormgrad_parameter.h"
#include "nnacl/errorcode.h"
#include "include/errorcode.h"
#include "src/runtime/runtime_api.h"

@@ -81,7 +82,11 @@ int LayerNormGradCPUKernel::Execute(int task_id) {
float *dx = reinterpret_cast<float *>(output_dx->MutableData());
float *dg = reinterpret_cast<float *>(output_dg->MutableData());
float *db = reinterpret_cast<float *>(output_db->MutableData());
LayerNormGrad(x, dy, var, mean, gamma, param_num_, param_size_, block_num_, block_size_, dx, dg, db);
int ret = LayerNormGrad(x, dy, var, mean, gamma, param_num_, param_size_, block_num_, block_size_, dx, dg, db);
if (ret != NNACL_OK) {
MS_LOG(ERROR) << "LayerNormGrad error task_id[" << task_id << "] error_code[" << ret << "]";
return RET_ERROR;
}
return RET_OK;
}



+ 2
- 2
mindspore/lite/src/runtime/kernel/opencl/kernel/conv2d.cc View File

@@ -278,7 +278,7 @@ void Conv2DOpenCLKernel::InitFilter() {
allocator->UnmapBuffer(packed_filter_);
}

FreeTmpWeight(in_tensors_.at(kWeightIndex)->data_c());
FreeTmpWeight(in_tensors_.at(kWeightIndex));
}

void Conv2DOpenCLKernel::InitBias() {
@@ -315,7 +315,7 @@ void Conv2DOpenCLKernel::InitBias() {
}
}
allocator->UnmapBuffer(packed_bias_);
FreeTmpWeight(in_tensors_.at(kBiasIndex)->data_c());
FreeTmpWeight(in_tensors_.at(kBiasIndex));
}

void Conv2DOpenCLKernel::SetConstArgs() {


+ 5
- 2
mindspore/lite/src/runtime/kernel/opencl/utils.cc View File

@@ -300,7 +300,7 @@ static std::set<void *> tmp_weights;

void StoreTmpWeight(lite::Tensor *tensor) {
MS_LOG(WARNING) << "store weight when kernel don't infer shape!";
if (tensor != nullptr && tensor->data_c() != nullptr && tensor->Size() > 0) {
if ((tensor != nullptr) && (tensor->data_c() != nullptr) && (tensor->Size() > 0)) {
void *new_data = malloc(tensor->Size());
MS_ASSERT(new_data);
if (new_data == nullptr) {
@@ -312,10 +312,13 @@ void StoreTmpWeight(lite::Tensor *tensor) {
}
}

void FreeTmpWeight(void *data) {
void FreeTmpWeight(lite::Tensor *tensor) {
MS_ASSERT(tensor != nullptr);
auto data = tensor->data_c();
if (tmp_weights.count(data)) {
tmp_weights.erase(data);
free(data);
tensor->set_data(nullptr);
}
}



+ 1
- 1
mindspore/lite/src/runtime/kernel/opencl/utils.h View File

@@ -64,7 +64,7 @@ int CheckParamLikeTensor(const std::string &kernel_name, const std::string &tens
TypeId expect_data_type, const std::vector<int> &expect_shape);

void StoreTmpWeight(lite::Tensor *tensor);
void FreeTmpWeight(void *tensor);
void FreeTmpWeight(lite::Tensor *tensor);

template <class T1, class T2>
void PackNCHWToNC4HW4(void *src, void *dst, int batch, int plane_in, int plane_out, int channel,


+ 11
- 3
mindspore/lite/src/tensorlist.cc View File

@@ -142,6 +142,9 @@ int TensorList::MallocData(const mindspore::Allocator *allocator) {
void TensorList::FreeData() {
// free data buf of each tensor in tensors_
for (auto tensor : tensors_) {
if (tensor == nullptr) {
continue;
}
tensor->FreeData();
}
}
@@ -274,7 +277,11 @@ STATUS TensorList::Decode(const int *data) {
element_shape_.push_back(data[2 + j]);
}
int tensors_num = data[2 + data[1]];
tensors_.resize(tensors_num);
if (this->ElementsNum() != tensors_num) {
MS_LOG(WARNING) << "Input tensorlist data is invalid: shape size(" << this->ElementsNum() << ") != tensors_num("
<< tensors_num << ").";
}
tensors_.reserve(tensors_num);
int tensor_index = 2 + data[1] + 1;
for (int i = 0; i < tensors_num; i++) {
int tensor_dims_size = data[tensor_index++];
@@ -282,11 +289,12 @@ STATUS TensorList::Decode(const int *data) {
for (int j = 0; j < tensor_dims_size; j++) {
shape[j] = data[tensor_index++];
}
tensors_[i] = new (std::nothrow) Tensor(tensors_data_type_, shape);
if (tensors_[i] == nullptr) {
auto tensor = new (std::nothrow) Tensor(tensors_data_type_, shape);
if (tensor == nullptr) {
MS_LOG(ERROR) << "new Tensor failed";
return RET_NULL_PTR;
}
tensors_.emplace_back(tensor);
}
return RET_OK;
}


+ 1
- 1
mindspore/lite/tools/anf_exporter/anf_exporter.cc View File

@@ -753,7 +753,7 @@ int AnfExporter::ProcessTensor(const ValueNodePtr &value_node, std::unique_ptr<s

// process weight tensor
if (data->Size() > 0) {
if (memcpy_s((*schema_tensor)->data.data(), data->Size(), data->data_c(), data->Size()) != EOK) {
if (memcpy_s((*schema_tensor)->data.data(), (*schema_tensor)->data.size(), data->data_c(), data->Size()) != EOK) {
MS_LOG(ERROR) << "memcpy_s error.";
return RET_ERROR;
}


+ 3
- 3
mindspore/lite/tools/converter/converter_context.h View File

@@ -28,7 +28,6 @@ namespace mindspore {
namespace lite {
class ReturnCode {
public:
virtual ~ReturnCode() = default;
static ReturnCode *GetSingleReturnCode() {
static ReturnCode return_code;
return &return_code;
@@ -42,12 +41,12 @@ class ReturnCode {

private:
ReturnCode() = default;
virtual ~ReturnCode() = default;
int status_code_ = RET_OK;
};

class NotSupportOp {
public:
virtual ~NotSupportOp() = default;
static NotSupportOp *GetInstance() {
static NotSupportOp not_support_op;
return &not_support_op;
@@ -67,13 +66,13 @@ class NotSupportOp {

private:
NotSupportOp() = default;
virtual ~NotSupportOp() = default;
std::set<std::string> not_support_ops_;
std::string fmk_type_;
};

class TensorDataType {
public:
~TensorDataType() = default;
static TensorDataType *GetInstance() {
static TensorDataType tensor_data_type;
return &tensor_data_type;
@@ -88,6 +87,7 @@ class TensorDataType {

private:
TensorDataType() {}
virtual ~TensorDataType() = default;
std::map<int32_t, int32_t> tensor_data_type_map_;
};
} // namespace lite


+ 5
- 4
mindspore/lite/tools/converter/parser/caffe/caffe_node_parser_registry.h View File

@@ -25,15 +25,16 @@
namespace mindspore::lite {
class CaffeNodeParserRegistry {
public:
CaffeNodeParserRegistry();

virtual ~CaffeNodeParserRegistry();

static CaffeNodeParserRegistry *GetInstance();

CaffeNodeParser *GetNodeParser(const std::string &name);

std::unordered_map<std::string, CaffeNodeParser *> parsers;

private:
CaffeNodeParserRegistry();

virtual ~CaffeNodeParserRegistry();
};

class CaffeNodeRegistrar {


+ 1
- 1
mindspore/lite/tools/converter/parser/onnx/onnx_model_parser.cc View File

@@ -1127,7 +1127,7 @@ STATUS OnnxModelParser::CopyOnnxTensorData(const onnx::TensorProto &onnx_const_t
return RET_MEMORY_FAILED;
}
auto tensor_data = reinterpret_cast<uint8_t *>(tensor_info->data_c());
if (memcpy_s(tensor_data, data_size, onnx_data, data_size) != EOK) {
if (memcpy_s(tensor_data, tensor_info->data().nbytes(), onnx_data, data_size) != EOK) {
MS_LOG(ERROR) << "memcpy_s failed";
return RET_ERROR;
}


+ 5
- 4
mindspore/lite/tools/converter/parser/onnx/onnx_node_parser_registry.h View File

@@ -25,15 +25,16 @@ namespace mindspore {
namespace lite {
class OnnxNodeParserRegistry {
public:
OnnxNodeParserRegistry();

virtual ~OnnxNodeParserRegistry();

static OnnxNodeParserRegistry *GetInstance();

OnnxNodeParser *GetNodeParser(const std::string &name);

std::unordered_map<std::string, OnnxNodeParser *> parsers;

private:
OnnxNodeParserRegistry();

virtual ~OnnxNodeParserRegistry();
};

class OnnxNodeRegistrar {


+ 6
- 4
mindspore/lite/tools/converter/parser/tf/tf_node_parser_registry.h View File

@@ -25,14 +25,16 @@ namespace mindspore {
namespace lite {
class TFNodeParserRegistry {
public:
TFNodeParserRegistry() = default;

virtual ~TFNodeParserRegistry();

static TFNodeParserRegistry *GetInstance();

TFNodeParser *GetNodeParser(const std::string &name);

std::unordered_map<std::string, TFNodeParser *> parsers;

private:
TFNodeParserRegistry() = default;

virtual ~TFNodeParserRegistry();
};

class TFNodeRegistrar {


+ 5
- 4
mindspore/lite/tools/converter/parser/tflite/tflite_node_parser_registry.h View File

@@ -25,15 +25,16 @@ namespace mindspore {
namespace lite {
class TfliteNodeParserRegistry {
public:
TfliteNodeParserRegistry();

virtual ~TfliteNodeParserRegistry();

static TfliteNodeParserRegistry *GetInstance();

TfliteNodeParser *GetNodeParser(const tflite::BuiltinOperator &type);

std::unordered_map<tflite::BuiltinOperator, TfliteNodeParser *> parsers;

private:
TfliteNodeParserRegistry();

virtual ~TfliteNodeParserRegistry();
};

class TfliteNodeRegister {


+ 2
- 1
mindspore/lite/tools/optimizer/fusion/conv_transform_fusion.cc View File

@@ -52,6 +52,7 @@ int GetOutChannels(const CNodePtr &conv_node) {

void GenerateNewWeightConv2D(float *dst_weight, const float *conv_weight, const float *scale_weight, FmkType fmk,
int weight_shape_size, int kernel_num) {
MS_ASSERT(kernel_num > 0);
if (dst_weight == nullptr || conv_weight == nullptr || scale_weight == nullptr) {
return;
}
@@ -60,7 +61,6 @@ void GenerateNewWeightConv2D(float *dst_weight, const float *conv_weight, const
dst_weight[i] = conv_weight[i] * scale_weight[i % kernel_num];
}
} else {
MS_ASSERT(kernel_num > 0);
auto kernel_size = weight_shape_size / kernel_num;
for (int i = 0; i < kernel_num; i++) {
for (int j = 0; j < kernel_size; j++) {
@@ -75,6 +75,7 @@ void GenerateNewWeightConv2DTranspose(float *dst_weight, const float *scale_weig
if (dst_weight == nullptr || scale_weight == nullptr || weight_tensor == nullptr) {
return;
}
MS_ASSERT(group > 0);
auto weight_data = reinterpret_cast<float *>(weight_tensor->data_c());
if (fmk == lite::converter::FmkType_TF) {
auto cin_group = weight_tensor->shape()[3] / group;


+ 0
- 1
model_zoo/official/lite/MindSpore_inhand/imageObject/src/main/cpp/SceneMindSporeNetnative.cpp View File

@@ -66,7 +66,6 @@ std::string SceneProcessRunnetResult(const int RET_CATEGORY_SUM,
// Get a pointer to the first score.
float *temp_scores = static_cast<float *>(outputTensor->MutableData());

// float scores[RET_CATEGORY_SUM];
float scores = temp_scores[0];
int cat_loc = 0;
for (int i = 0; i < RET_CATEGORY_SUM; ++i) {


+ 0
- 3
model_zoo/official/lite/MindSpore_inhand/segmentation/src/main/java/com/mindspore/imagesegmentation/StyleRecyclerViewAdapter.java View File

@@ -46,9 +46,6 @@ public class StyleRecyclerViewAdapter extends RecyclerView.Adapter<StyleRecycler

@Override
public void onBindViewHolder(@NonNull StyleItemViewHolder holder, int position) {
// Glide.with(context).
// load(IMAGES[position]).
// into(holder.getImageView());
holder.imageView.setImageResource(IMAGES[position]);
holder.itemView.setTag(IMAGES[position]);
holder.itemView.setOnClickListener(view1 -> {


+ 0
- 1
model_zoo/official/lite/MindSpore_inhand/segmentation/src/main/java/com/mindspore/imagesegmentation/help/TrackingMobile.java View File

@@ -111,7 +111,6 @@ public class TrackingMobile {
ByteBuffer contentArray = BitmapUtils.bitmapToByteBuffer(scaledBitmap, imageSize, imageSize, IMAGE_MEAN, IMAGE_STD);

MSTensor inTensor = inputs.get(0);
// int byteLen = (int) inTensor.size();
inTensor.setData(contentArray);

// Run graph to infer results.


+ 0
- 1
model_zoo/official/lite/image_segmentation/app/src/main/java/com/mindspore/imagesegmentation/help/TrackingMobile.java View File

@@ -111,7 +111,6 @@ public class TrackingMobile {
ByteBuffer contentArray = BitmapUtils.bitmapToByteBuffer(scaledBitmap, imageSize, imageSize, IMAGE_MEAN, IMAGE_STD);

MSTensor inTensor = inputs.get(0);
// int byteLen = (int) inTensor.size();
inTensor.setData(contentArray);

// Run graph to infer results.


+ 0
- 1
model_zoo/official/lite/scene_detection/app/src/main/cpp/MindSporeNetnative.cpp View File

@@ -235,7 +235,6 @@ std::string ProcessRunnetResult(const int RET_CATEGORY_SUM, const char *const la
// Get a pointer to the first score.
float *temp_scores = static_cast<float *>(outputTensor->MutableData());

// float scores[RET_CATEGORY_SUM];
float scores = temp_scores[0];
int cat_loc = 0;
for (int i = 0; i < RET_CATEGORY_SUM; ++i) {


+ 0
- 4
model_zoo/official/lite/style_transfer/app/src/main/java/com/mindspore/styletransferdemo/StyleTransferModelExecutor.java View File

@@ -127,20 +127,16 @@ public class StyleTransferModelExecutor {
}

@SuppressLint("LongLogTag")
// public ModelExecutionResult execute(String contentImagePath, String styleImageName) {
public ModelExecutionResult execute(Bitmap contentImage, Bitmap styleBitmap) {
Log.i(TAG, "running models");

fullExecutionTime = SystemClock.uptimeMillis();
preProcessTime = SystemClock.uptimeMillis();

// Bitmap contentImage = ImageUtils.decodeBitmap(new File(contentImagePath));
ByteBuffer contentArray =
ImageUtils.bitmapToByteBuffer(contentImage, CONTENT_IMAGE_SIZE, CONTENT_IMAGE_SIZE, 0, 255);


// Bitmap styleBitmap =
// ImageUtils.loadBitmapFromResources(context, "thumbnails/" + styleImageName);
ByteBuffer input = ImageUtils.bitmapToByteBuffer(styleBitmap, STYLE_IMAGE_SIZE, STYLE_IMAGE_SIZE, 0, 255);




Loading…
Cancel
Save