Browse Source

[MSLITE] FuzzTest.

feature/build-system-rewrite
wangshaocong 4 years ago
parent
commit
22ad253b48
7 changed files with 48 additions and 4 deletions
  1. +3
    -1
      mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/CMakeLists.txt
  2. +8
    -0
      mindspore/lite/src/lite_model.h
  3. +5
    -1
      mindspore/lite/src/ops/CMakeLists.txt
  4. +3
    -1
      mindspore/lite/src/runtime/kernel/arm/CMakeLists.txt
  5. +1
    -1
      mindspore/lite/src/runtime/kernel/arm/base/reshape_base.cc
  6. +25
    -0
      mindspore/lite/src/tensor.cc
  7. +3
    -0
      mindspore/lite/tools/cropper/build_cropper_config.sh

+ 3
- 1
mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/CMakeLists.txt View File

@@ -35,7 +35,9 @@ file(GLOB KERNEL_SRC
${NNACL_DIR}/fp32_grad/*.c
#${NNACL_DIR}/experiment/HPC-generator/*.c
)

if(NOT MSLITE_ENABLE_RUNTIME_PASS)
list(REMOVE_ITEM KERNEL_SRC ${NNACL_DIR}/infer/shape_fusion_infer.c)
endif()
if((NOT DEFINED MSLITE_ENABLE_INT8) OR MSLITE_ENABLE_INT8)
file(GLOB KERNEL_SRC_INT8
${NNACL_DIR}/int8/*.c


+ 8
- 0
mindspore/lite/src/lite_model.h View File

@@ -134,9 +134,17 @@ class LiteModel : public Model {
node->node_type_ = GetPrimitiveType(c_node->primitive(), schema_version_);
#ifdef ENABLE_MODEL_OBF
auto src_prim = reinterpret_cast<const schema::Primitive *>(c_node->primitive());
if (src_prim == nullptr) {
delete node;
return false;
}
auto src_prim_type = src_prim->value_type();
unsigned char *dst_prim = nullptr;
if (src_prim_type == schema::PrimitiveType_GenOP) {
if (i >= this->all_nodes_stat_.size() || i >= this->all_prims_type_.size()) {
delete node;
return false;
}
auto src_node_stat = this->all_nodes_stat_[i];
auto dst_prim_type = this->all_prims_type_[i];
auto ret = DeObfuscatePrimitive(src_prim, src_node_stat, &dst_prim, schema::PrimitiveType(dst_prim_type));


+ 5
- 1
mindspore/lite/src/ops/CMakeLists.txt View File

@@ -12,6 +12,9 @@ file(GLOB OPS_SRC
${CMAKE_CURRENT_SOURCE_DIR}/*.cc
${CMAKE_CURRENT_SOURCE_DIR}/populate/*.cc
)
if(NOT MSLITE_ENABLE_RUNTIME_PASS)
list(REMOVE_ITEM OPS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/populate/custom_populate.cc)
endif()
if(MSLITE_ENABLE_STRING_KERNEL)
file(GLOB OPS_SRC_STRING
${CMAKE_CURRENT_SOURCE_DIR}/populate/string/*.cc
@@ -55,4 +58,5 @@ if(MSLITE_ENABLE_V0)
endif()

add_library(cpu_ops_mid OBJECT ${OPS_SRC})
add_dependencies(cpu_ops_mid fbs_src fbs_inner_src)
add_dependencies(cpu_ops_mid fbs_src fbs_inner_src)


+ 3
- 1
mindspore/lite/src/runtime/kernel/arm/CMakeLists.txt View File

@@ -4,7 +4,9 @@ file(GLOB KERNEL_SRC
${CMAKE_CURRENT_SOURCE_DIR}/base/*.cc
${CMAKE_CURRENT_SOURCE_DIR}/fp32/*.cc
)

if(NOT MSLITE_ENABLE_RUNTIME_PASS)
list(REMOVE_ITEM KERNEL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/fp32/shape_fusion_fp32.cc)
endif()
if(MSLITE_ENABLE_INT8)
file(GLOB INT8_KERNEL_SRC
${CMAKE_CURRENT_SOURCE_DIR}/int8/*.cc


+ 1
- 1
mindspore/lite/src/runtime/kernel/arm/base/reshape_base.cc View File

@@ -51,7 +51,7 @@ int ReshapeBaseCPUKernel::Run() {

if (in_tensor->allocator() == nullptr || in_tensor->allocator() != out_tensor->allocator() ||
in_tensor->allocator() != ms_context_->allocator || /* runtime allocator */
op_parameter_->is_train_session_) {
in_tensor->allocator()->RefCount(in_tensor->data()) == -1 || op_parameter_->is_train_session_) {
CHECK_NULL_RETURN(out_tensor->data());
CHECK_NULL_RETURN(in_tensor->data());
MS_CHECK_FALSE(in_tensor->Size() == 0, RET_ERROR);


+ 25
- 0
mindspore/lite/src/tensor.cc View File

@@ -107,6 +107,7 @@ bool Tensor::operator==(const Tensor &tensor) {
}

int32_t Tensor::Batch() const {
// Only 2D or 4D tensors have valid batch.
if (this->shape_.size() != 4 && this->shape_.size() != 2) {
MS_LOG(ERROR) << "Unsupported tensor shape: " << this->shape().size();
return RET_ERROR;
@@ -123,8 +124,14 @@ int32_t Tensor::Batch() const {
return this->shape_[0];
case mindspore::HWCK:
case mindspore::CHWK:
if (this->shape_.size() != 4) {
return RET_ERROR;
}
return this->shape_[3];
case mindspore::HWKC:
if (this->shape_.size() != 4) {
return RET_ERROR;
}
return this->shape_[2];
case mindspore::CKHW:
return this->shape_[1];
@@ -135,6 +142,7 @@ int32_t Tensor::Batch() const {
}

int32_t Tensor::Channel() const {
// Only 2D or 4D tensors have valid channel.
if (this->shape_.size() != 4 && this->shape_.size() != 2) {
MS_LOG(ERROR) << "Unsupported tensor shape: " << this->shape().size();
return RET_ERROR;
@@ -146,12 +154,18 @@ int32_t Tensor::Channel() const {
case mindspore::NC4:
return this->shape_[1];
case mindspore::HWCK:
if (this->shape_.size() != 4) {
return RET_ERROR;
}
return this->shape_[2];
case mindspore::HWKC:
case mindspore::NHWC:
case mindspore::NHWC4:
case mindspore::NC4HW4:
case mindspore::KHWC:
if (this->shape_.size() != 4) {
return RET_ERROR;
}
return this->shape_[3];
case mindspore::CKHW:
case mindspore::CHWK:
@@ -162,6 +176,7 @@ int32_t Tensor::Channel() const {
}

int32_t Tensor::Height() const {
// Only 2D or 4D tensors have valid height.
if (this->shape_.size() != 4 && this->shape_.size() != 2) {
MS_LOG(ERROR) << "Unsupported tensor shape: " << this->shape().size();
return RET_ERROR;
@@ -170,6 +185,9 @@ int32_t Tensor::Height() const {
case mindspore::NCHW:
case mindspore::KCHW:
case mindspore::CKHW:
if (this->shape_.size() != 4) {
return RET_ERROR;
}
return this->shape_[2];
case mindspore::NHWC:
case mindspore::NHWC4:
@@ -189,6 +207,7 @@ int32_t Tensor::Height() const {
}

int32_t Tensor::Width() const {
// Only 2D or 4D tensors have valid width.
if (this->shape_.size() != 4 && this->shape_.size() != 2) {
MS_LOG(ERROR) << "Unsupported tensor shape: " << this->shape().size();
return RET_ERROR;
@@ -197,12 +216,18 @@ int32_t Tensor::Width() const {
case mindspore::NCHW:
case mindspore::KCHW:
case mindspore::CKHW:
if (this->shape_.size() != 4) {
return RET_ERROR;
}
return this->shape_[3];
case mindspore::KHWC:
case mindspore::NHWC:
case mindspore::NHWC4:
case mindspore::NC4HW4:
case mindspore::CHWK:
if (this->shape_.size() != 4) {
return RET_ERROR;
}
return this->shape_[2];
case mindspore::HWCK:
case mindspore::HWKC:


+ 3
- 0
mindspore/lite/tools/cropper/build_cropper_config.sh View File

@@ -207,7 +207,10 @@ getCommonFile() {
mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/nnacl_utils.c
mindspore/lite/src/runtime/infer_manager.cc
mindspore/lite/src/ops/populate/populate_register.cc
mindspore/lite/src/ops/populate/custom_populate.cc
mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/infer/infer_register.c
mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/infer/shape_fusion_infer.c
mindspore/lite/src/runtime/kernel/arm/fp32/shape_fusion_fp32.cc
mindspore/core/utils/status.cc
)
# save train files


Loading…
Cancel
Save