| 657 | } |
| 658 | |
| 659 | Status OpKernelContext::allocate_output(int index, const TensorShape& shape, |
| 660 | Tensor** tensor) { |
| 661 | if (index < 0) { |
| 662 | return errors::Internal("allocate_output with bad index=", index, |
| 663 | " kernel=", params_->op_kernel->name()); |
| 664 | } |
| 665 | if (index >= num_outputs()) { |
| 666 | return errors::Internal("allocate_output with bad index=", index, |
| 667 | " num_outputs=", num_outputs(), |
| 668 | " kernel=", params_->op_kernel->name()); |
| 669 | } |
| 670 | bool forward_expected = |
| 671 | (params_->forward_from_array != nullptr && index >= 0 && |
| 672 | params_->forward_from_array[index] >= 0); |
| 673 | if (forward_expected) { |
| 674 | return errors::Internal( |
| 675 | "Explicit allocate_output call where input forwarding required. Try " |
| 676 | "turning off the ScopedAllocator optimizer."); |
| 677 | } |
| 678 | AllocatorAttributes attr = output_alloc_attr(index); |
| 679 | return allocate_output(index, shape, tensor, attr); |
| 680 | } |
| 681 | |
| 682 | Status OpKernelContext::allocate_output(StringPiece name, |
| 683 | const TensorShape& shape, |