| 931 | explicit LookupTableImportOp(OpKernelConstruction* ctx) : OpKernel(ctx) {} |
| 932 | |
| 933 | void Compute(OpKernelContext* ctx) override { |
| 934 | lookup::LookupInterface* table; |
| 935 | OP_REQUIRES_OK(ctx, GetLookupTable("table_handle", ctx, &table)); |
| 936 | core::ScopedUnref unref_me(table); |
| 937 | |
| 938 | DataType expected_input_0 = |
| 939 | (ctx->input_dtype(0) == DT_RESOURCE) ? DT_RESOURCE : DT_STRING_REF; |
| 940 | DataTypeVector expected_inputs = {expected_input_0, table->key_dtype(), |
| 941 | table->value_dtype()}; |
| 942 | OP_REQUIRES_OK(ctx, ctx->MatchSignature(expected_inputs, {})); |
| 943 | |
| 944 | const Tensor& keys = ctx->input(1); |
| 945 | const Tensor& values = ctx->input(2); |
| 946 | OP_REQUIRES_OK(ctx, table->CheckKeyAndValueTensorsForImport(keys, values)); |
| 947 | |
| 948 | int memory_used_before = 0; |
| 949 | if (ctx->track_allocations()) { |
| 950 | memory_used_before = table->MemoryUsed(); |
| 951 | } |
| 952 | OP_REQUIRES_OK(ctx, table->ImportValues(ctx, keys, values)); |
| 953 | if (ctx->track_allocations()) { |
| 954 | ctx->record_persistent_memory_allocation(table->MemoryUsed() - |
| 955 | memory_used_before); |
| 956 | } |
| 957 | } |
| 958 | }; |
| 959 | |
| 960 | REGISTER_KERNEL_BUILDER(Name("LookupTableImport").Device(DEVICE_CPU), |
nothing calls this directly
no test coverage detected