| 411 | } |
| 412 | |
| 413 | string GenEagerPythonOp::GetEagerNotAllowedError() { |
| 414 | bool eager_allowed = true; |
| 415 | string ref_arg; |
| 416 | for (int i = 0; i < op_def_.input_arg_size(); ++i) { |
| 417 | const auto& arg = op_def_.input_arg(i); |
| 418 | if (arg.is_ref()) { |
| 419 | eager_allowed = false; |
| 420 | DCHECK_EQ(op_def_.input_arg(i).name(), api_def_.in_arg(i).name()); |
| 421 | ref_arg = api_def_.in_arg(i).rename_to(); |
| 422 | } |
| 423 | } |
| 424 | for (int i = 0; i < op_def_.output_arg_size(); ++i) { |
| 425 | const auto& arg = op_def_.output_arg(i); |
| 426 | if (arg.is_ref()) { |
| 427 | eager_allowed = false; |
| 428 | DCHECK_EQ(op_def_.output_arg(i).name(), api_def_.out_arg(i).name()); |
| 429 | ref_arg = api_def_.out_arg(i).rename_to(); |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | if (eager_allowed) return ""; |
| 434 | |
| 435 | return strings::StrCat("raise RuntimeError(\"", op_name_, |
| 436 | " op does not support eager execution. ", "Arg '", |
| 437 | ref_arg, "' is a ref.\")\n"); |
| 438 | } |
| 439 | |
| 440 | void GenEagerPythonOp::ExpectListArg(const string& indentation, |
| 441 | const string& arg_name, string* output) { |