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

Method Compute

tensorflow/core/kernels/sdca_ops.cc:305–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303 : OpKernel(context) {}
304
305 void Compute(OpKernelContext* context) override {
306 const Tensor& input = context->input(0);
307 OP_REQUIRES(context, TensorShapeUtils::IsVector(input.shape()),
308 errors::InvalidArgument("Input must be a vector, got shape ",
309 input.shape().DebugString()));
310 Tensor* out;
311 const int64 num_elements = input.NumElements();
312 OP_REQUIRES_OK(context, context->allocate_output(
313 0, TensorShape({num_elements, 2}), &out));
314
315 const auto in_values = input.flat<tstring>();
316 auto out_values = out->matrix<int64>();
317
318 for (int64 i = 0; i < num_elements; ++i) {
319 const Fprint128 fprint = Fingerprint128(in_values(i));
320 // Never return 0 or 1 as the first value of the hash to allow these to
321 // safely be used as sentinel values (e.g. dense hash table empty key).
322 out_values(i, 0) = TF_PREDICT_TRUE(fprint.low64 >= 2)
323 ? fprint.low64
324 : fprint.low64 + ~static_cast<uint64>(1);
325 out_values(i, 1) = fprint.high64;
326 }
327 }
328};
329REGISTER_KERNEL_BUILDER(Name("SdcaFprint").Device(DEVICE_CPU), SdcaFprint);
330

Callers

nothing calls this directly

Calls 8

InvalidArgumentFunction · 0.85
Fingerprint128Function · 0.85
allocate_outputMethod · 0.80
TensorShapeClass · 0.50
inputMethod · 0.45
shapeMethod · 0.45
DebugStringMethod · 0.45
NumElementsMethod · 0.45

Tested by

no test coverage detected