| 248 | } |
| 249 | |
| 250 | void GetValues(OpKernelContext* context, int input_index, float* v_1, |
| 251 | float* v_2) { |
| 252 | // Tensor mutable_input(int index, False); |
| 253 | const Tensor& t = context->input(input_index); |
| 254 | OP_REQUIRES(context, t.dims() == 1, |
| 255 | errors::InvalidArgument("t must be 1-dimensional", |
| 256 | t.shape().DebugString())); |
| 257 | OP_REQUIRES(context, t.NumElements() == 2, |
| 258 | errors::InvalidArgument("t must have two elements", |
| 259 | t.shape().DebugString())); |
| 260 | |
| 261 | auto data_vec = t.flat<float>().data(); |
| 262 | *v_1 = data_vec[0]; |
| 263 | *v_2 = data_vec[1]; |
| 264 | } |
| 265 | |
| 266 | template <typename Device, typename T> |
| 267 | class ScaleAndTranslateOp : public OpKernel { |