| 24 | namespace tensorflow { |
| 25 | |
| 26 | void SwitchOp::Compute(OpKernelContext* context) { |
| 27 | const Tensor& outputPorts = context->input(1); |
| 28 | OP_REQUIRES(context, TensorShapeUtils::IsScalar(outputPorts.shape()), |
| 29 | errors::InvalidArgument("The second input must be a scalar, " |
| 30 | "but it has shape ", |
| 31 | outputPorts.shape().DebugString())); |
| 32 | |
| 33 | bool pred = outputPorts.scalar<bool>()(); |
| 34 | int port = (pred) ? 1 : 0; |
| 35 | if (context->input_is_ref(0)) { |
| 36 | context->forward_ref_input_to_ref_output(0, port); |
| 37 | } else { |
| 38 | context->set_output(port, context->input(0)); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | void SwitchNOp::Compute(OpKernelContext* context) { |
| 43 | const Tensor& output_index_t = context->input(1); |
nothing calls this directly
no test coverage detected