| 821 | explicit LookupTableInsertOp(OpKernelConstruction* ctx) : OpKernel(ctx) {} |
| 822 | |
| 823 | void Compute(OpKernelContext* ctx) override { |
| 824 | lookup::LookupInterface* table; |
| 825 | OP_REQUIRES_OK(ctx, GetLookupTable("table_handle", ctx, &table)); |
| 826 | core::ScopedUnref unref_me(table); |
| 827 | |
| 828 | DataType expected_input_0 = |
| 829 | (ctx->input_dtype(0) == DT_RESOURCE) ? DT_RESOURCE : DT_STRING_REF; |
| 830 | DataTypeVector expected_inputs = {expected_input_0, table->key_dtype(), |
| 831 | table->value_dtype()}; |
| 832 | OP_REQUIRES_OK(ctx, ctx->MatchSignature(expected_inputs, {})); |
| 833 | |
| 834 | const Tensor& keys = ctx->input(1); |
| 835 | const Tensor& values = ctx->input(2); |
| 836 | OP_REQUIRES_OK(ctx, table->CheckKeyAndValueTensorsForInsert(keys, values)); |
| 837 | |
| 838 | int64 memory_used_before = 0; |
| 839 | if (ctx->track_allocations()) { |
| 840 | memory_used_before = table->MemoryUsed(); |
| 841 | } |
| 842 | OP_REQUIRES_OK(ctx, table->Insert(ctx, keys, values)); |
| 843 | if (ctx->track_allocations()) { |
| 844 | ctx->record_persistent_memory_allocation(table->MemoryUsed() - |
| 845 | memory_used_before); |
| 846 | } |
| 847 | } |
| 848 | }; |
| 849 | |
| 850 | REGISTER_KERNEL_BUILDER(Name("LookupTableInsert").Device(DEVICE_CPU), |
nothing calls this directly
no test coverage detected