This function will set the op attrs required. If an attr has the value of None, then it will read the AttrDef to get the default value and set that instead. Any failure in this function will simply fall back to the slow path.
| 671 | // instead. Any failure in this function will simply fall back to the slow |
| 672 | // path. |
| 673 | void SetOpAttrWithDefaults( |
| 674 | TFE_Context* ctx, TFE_Op* op, const tensorflow::OpDef::AttrDef& attr, |
| 675 | const char* attr_name, PyObject* attr_value, |
| 676 | tensorflow::gtl::FlatMap<string, tensorflow::int64>* attr_list_sizes, |
| 677 | TF_Status* status) { |
| 678 | unsigned char is_list = 0; |
| 679 | const TF_AttrType type = TFE_OpGetAttrType(op, attr_name, &is_list, status); |
| 680 | if (TF_GetCode(status) != TF_OK) return; |
| 681 | if (attr_value == Py_None) { |
| 682 | if (is_list != 0) { |
| 683 | SetOpAttrListDefault(ctx, op, attr, attr_name, type, attr_list_sizes, |
| 684 | status); |
| 685 | } else { |
| 686 | SetOpAttrScalarDefault(ctx, op, attr.default_value(), attr_name, |
| 687 | attr_list_sizes, status); |
| 688 | } |
| 689 | } else { |
| 690 | if (is_list != 0) { |
| 691 | SetOpAttrList(ctx, op, attr_name, attr_value, type, attr_list_sizes, |
| 692 | status); |
| 693 | } else { |
| 694 | SetOpAttrScalar(ctx, op, attr_name, attr_value, type, attr_list_sizes, |
| 695 | status); |
| 696 | } |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | PyObject* GetPythonObjectFromInt(int num) { |
| 701 | #if PY_MAJOR_VERSION >= 3 |
no test coverage detected