MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Compute

Method Compute

tensorflow/core/kernels/lookup_table_op.cc:823–847  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
850REGISTER_KERNEL_BUILDER(Name("LookupTableInsert").Device(DEVICE_CPU),

Callers

nothing calls this directly

Calls 11

GetLookupTableFunction · 0.85
MatchSignatureMethod · 0.80
track_allocationsMethod · 0.80
input_dtypeMethod · 0.45
key_dtypeMethod · 0.45
value_dtypeMethod · 0.45
inputMethod · 0.45
MemoryUsedMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected