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

Method Compute

tensorflow/core/kernels/lookup_table_op.cc:933–957  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
960REGISTER_KERNEL_BUILDER(Name("LookupTableImport").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
ImportValuesMethod · 0.45

Tested by

no test coverage detected