| 252 | }; |
| 253 | |
| 254 | Status GetTableHandle(const string& input_name, OpKernelContext* ctx, |
| 255 | string* container, string* table_handle) { |
| 256 | { |
| 257 | mutex* mu; |
| 258 | TF_RETURN_IF_ERROR(ctx->input_ref_mutex(input_name, &mu)); |
| 259 | mutex_lock l(*mu); |
| 260 | Tensor tensor; |
| 261 | TF_RETURN_IF_ERROR(ctx->mutable_input(input_name, &tensor, true)); |
| 262 | if (tensor.NumElements() != 2) { |
| 263 | return errors::InvalidArgument( |
| 264 | "Lookup table handle must be scalar, but had shape: ", |
| 265 | tensor.shape().DebugString()); |
| 266 | } |
| 267 | auto h = tensor.flat<tstring>(); |
| 268 | *container = h(0); |
| 269 | *table_handle = h(1); |
| 270 | } |
| 271 | return Status::OK(); |
| 272 | } |
| 273 | |
| 274 | } // namespace |
| 275 |
no test coverage detected