Browse Source

single op parser add check for json input

pull/580/head
wxl 4 years ago
parent
commit
0db1ef1fc9
2 changed files with 10 additions and 5 deletions
  1. +3
    -3
      ge/offline/single_op_parser.cc
  2. +7
    -2
      ge/offline/single_op_parser.h

+ 3
- 3
ge/offline/single_op_parser.cc View File

@@ -210,7 +210,7 @@ void from_json(const Json &j, SingleOpTensorDesc &desc) {
desc.dynamic_input_name = dynamic_input_name->get<string>(); desc.dynamic_input_name = dynamic_input_name->get<string>();
} }
if (!is_tensor_valid) { if (!is_tensor_valid) {
ge::AttrUtils::SetBool(&desc, kSingleOpTensorDescValid, is_tensor_valid);
desc.SetValidFlag(is_tensor_valid);
} }
} }


@@ -315,7 +315,7 @@ bool SingleOpParser::Validate(const SingleOpDesc &op_desc) {


int index = 0; int index = 0;
for (auto &tensor_desc : op_desc.input_desc) { for (auto &tensor_desc : op_desc.input_desc) {
if (ge::AttrUtils::GetBool(&tensor_desc)) {
if (!tensor_desc.GetValidFlag()) {
ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"}, ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"},
{"intput", "datatype or format", std::to_string(index)}); {"intput", "datatype or format", std::to_string(index)});
GELOGE(PARAM_INVALID, "Input's dataType or format is invalid when the index is %d", index); GELOGE(PARAM_INVALID, "Input's dataType or format is invalid when the index is %d", index);
@@ -333,7 +333,7 @@ bool SingleOpParser::Validate(const SingleOpDesc &op_desc) {


index = 0; index = 0;
for (auto &tensor_desc : op_desc.output_desc) { for (auto &tensor_desc : op_desc.output_desc) {
if (ge::AttrUtils::GetBool(&tensor_desc)) {
if (!tensor_desc.GetValidFlag()) {
ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"}, ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"},
{"output", "datatype", std::to_string(index)}); {"output", "datatype", std::to_string(index)});
GELOGE(PARAM_INVALID, "Output's dataType is invalid when the index is %d", index); GELOGE(PARAM_INVALID, "Output's dataType is invalid when the index is %d", index);


+ 7
- 2
ge/offline/single_op_parser.h View File

@@ -23,12 +23,15 @@


#include "ge/ge_api_error_codes.h" #include "ge/ge_api_error_codes.h"
#include "graph/types.h" #include "graph/types.h"
#include "graph/detail/attributes_holder.h"
#include "graph/ge_attr_value.h" #include "graph/ge_attr_value.h"
#include "graph/op_desc.h" #include "graph/op_desc.h"


namespace ge { namespace ge {
struct SingleOpTensorDesc: public AttrHolder {
struct SingleOpTensorDesc {
public:
bool GetValidFlag() { return is_valid_; }
void SetValidFlag(bool is_valid) { is_valid_ = is_valid; }
public:
std::string name; std::string name;
std::vector<int64_t> dims; std::vector<int64_t> dims;
std::vector<int64_t> ori_dims; std::vector<int64_t> ori_dims;
@@ -37,6 +40,8 @@ struct SingleOpTensorDesc: public AttrHolder {
ge::Format ori_format = ge::FORMAT_RESERVED; ge::Format ori_format = ge::FORMAT_RESERVED;
ge::DataType type = ge::DT_UNDEFINED; ge::DataType type = ge::DT_UNDEFINED;
std::string dynamic_input_name; std::string dynamic_input_name;
private:
bool is_valid_ = true;
}; };


struct SingleOpAttr { struct SingleOpAttr {


Loading…
Cancel
Save