| 291 | } |
| 292 | |
| 293 | Status GetInitializableLookupTable(const string& input_name, |
| 294 | OpKernelContext* ctx, |
| 295 | InitializableLookupTable** table) { |
| 296 | LookupInterface* lookup_table; |
| 297 | DataType handle_dtype; |
| 298 | TF_RETURN_IF_ERROR(ctx->input_dtype(input_name, &handle_dtype)); |
| 299 | if (handle_dtype == DT_RESOURCE) { |
| 300 | ResourceHandle handle; |
| 301 | TF_RETURN_IF_ERROR(HandleFromInput(ctx, input_name, &handle)); |
| 302 | TF_RETURN_IF_ERROR(LookupResource(ctx, handle, &lookup_table)); |
| 303 | *table = lookup_table->GetInitializableLookupTable(); |
| 304 | if (*table == nullptr) { |
| 305 | lookup_table->Unref(); |
| 306 | return errors::InvalidArgument("Table ", handle.container(), " ", |
| 307 | handle.name(), " is not initializable"); |
| 308 | } |
| 309 | } else { |
| 310 | string container; |
| 311 | string table_handle; |
| 312 | TF_RETURN_IF_ERROR( |
| 313 | GetTableHandle(input_name, ctx, &container, &table_handle)); |
| 314 | TF_RETURN_IF_ERROR(ctx->resource_manager()->Lookup(container, table_handle, |
| 315 | &lookup_table)); |
| 316 | *table = lookup_table->GetInitializableLookupTable(); |
| 317 | if (*table == nullptr) { |
| 318 | lookup_table->Unref(); |
| 319 | return errors::InvalidArgument("Table ", container, " ", table_handle, |
| 320 | " is not initializable"); |
| 321 | } |
| 322 | } |
| 323 | return Status::OK(); |
| 324 | } |
| 325 | |
| 326 | Status CheckTableDataTypes(const LookupInterface& table, DataType key_dtype, |
| 327 | DataType value_dtype, const string& table_name) { |
no test coverage detected