Sets "rets" to be the output of "ctx". Validates rets' types based on "kernel".
| 97 | // Sets "rets" to be the output of "ctx". Validates rets' types based |
| 98 | // on "kernel". |
| 99 | Status SetOutputs(const OpKernel* kernel, OpKernelContext* ctx, |
| 100 | gtl::ArraySlice<Tensor> rets) { |
| 101 | if (rets.size() != ctx->num_outputs()) { |
| 102 | return errors::Internal("Expect to produce ", ctx->num_outputs(), |
| 103 | " tensors, but only get ", rets.size()); |
| 104 | } |
| 105 | for (int i = 0; i < rets.size(); ++i) { |
| 106 | if (rets[i].dtype() != kernel->output_type(i)) { |
| 107 | return errors::Internal("Expect ", i, "-th output is of type ", |
| 108 | DataTypeString(kernel->output_type(i)), |
| 109 | " but get ", DataTypeString(rets[i].dtype())); |
| 110 | } |
| 111 | ctx->set_output(i, rets[i]); |
| 112 | } |
| 113 | return Status::OK(); |
| 114 | } |
| 115 | |
| 116 | void SetRunOptions(OpKernelContext* ctx, FunctionLibraryRuntime::Options* opts, |
| 117 | bool always_collect_stats) { |
no test coverage detected