You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

tensorflow_merge_parser.cc 2.1 kB

5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * Copyright 2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include "parser/tensorflow/tensorflow_merge_parser.h"
  17. #include "framework/common/debug/ge_log.h"
  18. #include "common/util.h"
  19. #include "graph/debug/ge_attr_define.h"
  20. #include "parser/common/op_parser_factory.h"
  21. #include "framework/omg/parser/parser_types.h"
  22. #include "graph/def_types.h"
  23. using domi::TENSORFLOW;
  24. using ge::parser::MERGE;
  25. namespace ge {
  26. Status TensorFlowMergeParser::ParseParams(const Message *op_src, ge::OpDescPtr &op_desc) {
  27. GE_CHECK_NOTNULL(op_src);
  28. GE_CHECK_NOTNULL(op_desc);
  29. const domi::tensorflow::NodeDef *node = PtrToPtr<const Message, const domi::tensorflow::NodeDef>(op_src);
  30. domi::tensorflow::AttrValue attr_num;
  31. if (!(TensorFlowUtil::FindAttrValue(node, ATTR_NAME_N, attr_num))) {
  32. GELOGW("In NodeDef %s dynamic attr [%s] is not exist.", op_desc->GetName().c_str(), ATTR_NAME_N.c_str());
  33. }
  34. int32_t input_tensor_num = attr_num.i();
  35. // add dynamic input
  36. graphStatus ret = op_desc->AddDynamicInputDesc("x", input_tensor_num);
  37. if (ret != GRAPH_SUCCESS) {
  38. REPORT_CALL_ERROR("E19999", "Add Dynamic InputDesc name:x to node:%s(%s) failed",
  39. op_desc->GetName().c_str(), op_desc->GetType().c_str());
  40. GELOGE(FAILED, "Add dynamic input:x for node:%s failed.", op_desc->GetName().c_str());
  41. return FAILED;
  42. }
  43. GELOGI("add dynamic input for Merge op [%s], num:%d", op_desc->GetName().c_str(), input_tensor_num);
  44. return SUCCESS;
  45. }
  46. REGISTER_OP_PARSER_CREATOR(TENSORFLOW, MERGE, TensorFlowMergeParser);
  47. }