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

Method Compute

tensorflow/core/kernels/lookup_table_op.cc:786–810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

784 explicit LookupTableFindOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}
785
786 void Compute(OpKernelContext* ctx) override {
787 lookup::LookupInterface* table;
788 OP_REQUIRES_OK(ctx, GetLookupTable("table_handle", ctx, &table));
789 core::ScopedUnref unref_me(table);
790
791 // Input 0 could be a STRING_REF or a RESOURCE
792 DataType expected_input_0 =
793 (ctx->input_dtype(0) == DT_RESOURCE) ? DT_RESOURCE : DT_STRING_REF;
794 DataTypeVector expected_inputs = {expected_input_0, table->key_dtype(),
795 table->value_dtype()};
796 DataTypeVector expected_outputs = {table->value_dtype()};
797 OP_REQUIRES_OK(ctx, ctx->MatchSignature(expected_inputs, expected_outputs));
798
799 const Tensor& key = ctx->input(1);
800 const Tensor& default_value = ctx->input(2);
801 OP_REQUIRES_OK(ctx, table->CheckFindArguments(key, default_value));
802
803 TensorShape output_shape = key.shape();
804 output_shape.RemoveLastDims(table->key_shape().dims());
805 output_shape.AppendShape(table->value_shape());
806 Tensor* out;
807 OP_REQUIRES_OK(ctx, ctx->allocate_output("values", output_shape, &out));
808
809 OP_REQUIRES_OK(ctx, table->Find(ctx, key, out, default_value));
810 }
811};
812
813REGISTER_KERNEL_BUILDER(Name("LookupTableFind").Device(DEVICE_CPU),

Callers

nothing calls this directly

Calls 15

GetLookupTableFunction · 0.85
MatchSignatureMethod · 0.80
CheckFindArgumentsMethod · 0.80
RemoveLastDimsMethod · 0.80
allocate_outputMethod · 0.80
input_dtypeMethod · 0.45
key_dtypeMethod · 0.45
value_dtypeMethod · 0.45
inputMethod · 0.45
shapeMethod · 0.45
dimsMethod · 0.45
key_shapeMethod · 0.45

Tested by

no test coverage detected