| 710 | } |
| 711 | |
| 712 | void TFE_OpSetAttrShape(TFE_Op* op, const char* attr_name, const int64_t* dims, |
| 713 | const int num_dims, TF_Status* out_status) { |
| 714 | if (num_dims > tensorflow::TensorShape::MaxDimensions()) { |
| 715 | TF_SetStatus(out_status, TF_INVALID_ARGUMENT, |
| 716 | tensorflow::strings::StrCat( |
| 717 | "Value specified for `", attr_name, "` has ", num_dims, |
| 718 | " dimensions which is over the limit of ", |
| 719 | tensorflow::TensorShape::MaxDimensions(), ".") |
| 720 | .c_str()); |
| 721 | return; |
| 722 | } |
| 723 | tensorflow::TensorShapeProto proto; |
| 724 | if (num_dims < 0) { |
| 725 | proto.set_unknown_rank(true); |
| 726 | } else { |
| 727 | for (int d = 0; d < num_dims; ++d) { |
| 728 | proto.add_dim()->set_size(dims[d]); |
| 729 | } |
| 730 | } |
| 731 | op->operation.MutableAttrs()->Set(attr_name, proto); |
| 732 | } |
| 733 | |
| 734 | void TFE_OpSetAttrFunction(TFE_Op* op, const char* attr_name, |
| 735 | const TFE_Op* value) { |