MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / AddArgToSig

Function AddArgToSig

tensorflow/core/framework/node_def_util.cc:460–513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

458
459template <class NodeDefOrAttrSlice>
460Status AddArgToSig(const NodeDefOrAttrSlice& node_or_attrs,
461 const OpDef::ArgDef& arg_def, DataTypeVector* sig) {
462 const int original_size = sig->size();
463 if (!arg_def.number_attr().empty()) {
464 // Same type repeated "repeats" times.
465 int32 repeats = -1;
466 TF_RETURN_IF_ERROR(
467 GetNodeAttr(node_or_attrs, arg_def.number_attr(), &repeats));
468 if (repeats < 0) {
469 return errors::InvalidArgument("Value for number_attr() ", repeats,
470 " < 0");
471 }
472
473 if (!arg_def.type_attr().empty()) {
474 DataType dtype;
475 TF_RETURN_IF_ERROR(
476 GetNodeAttr(node_or_attrs, arg_def.type_attr(), &dtype));
477 for (int i = 0; i < repeats; ++i) {
478 sig->push_back(dtype);
479 }
480 } else if (arg_def.type() != DT_INVALID) {
481 for (int i = 0; i < repeats; ++i) {
482 sig->push_back(arg_def.type());
483 }
484 } else {
485 return errors::InvalidArgument("Missing type or type_attr field in ",
486 ProtoShortDebugString(arg_def));
487 }
488 } else if (!arg_def.type_attr().empty()) {
489 const AttrValue* attr_value;
490 TF_RETURN_IF_ERROR(
491 AttrSlice(node_or_attrs).Find(arg_def.type_attr(), &attr_value));
492 sig->push_back(attr_value->type());
493 } else if (!arg_def.type_list_attr().empty()) {
494 const AttrValue* attr_value;
495 TF_RETURN_IF_ERROR(
496 AttrSlice(node_or_attrs).Find(arg_def.type_list_attr(), &attr_value));
497 for (int dtype : attr_value->list().type()) {
498 sig->push_back(static_cast<DataType>(dtype));
499 }
500 } else if (arg_def.type() != DT_INVALID) {
501 sig->push_back(arg_def.type());
502 } else {
503 return errors::InvalidArgument("No type fields in ",
504 ProtoShortDebugString(arg_def));
505 }
506 if (arg_def.is_ref()) {
507 // For all types that were added by this function call, make them refs.
508 for (size_t i = original_size; i < sig->size(); ++i) {
509 (*sig)[i] = MakeRefType((*sig)[i]);
510 }
511 }
512 return Status::OK();
513}
514
515} // namespace
516

Callers 3

InputTypesForNodeFunction · 0.85
OutputTypeForNodeFunction · 0.85
OutputTypesForNodeFunction · 0.85

Calls 11

InvalidArgumentFunction · 0.85
AttrSliceClass · 0.85
MakeRefTypeFunction · 0.85
listMethod · 0.80
is_refMethod · 0.80
typeMethod · 0.65
GetNodeAttrFunction · 0.50
sizeMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45
FindMethod · 0.45

Tested by

no test coverage detected