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

Function Resize

tensorflow/lite/kernels/lsh_projection.cc:73–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71namespace lsh_projection {
72
73TfLiteStatus Resize(TfLiteContext* context, TfLiteNode* node) {
74 auto* params =
75 reinterpret_cast<TfLiteLSHProjectionParams*>(node->builtin_data);
76 TF_LITE_ENSURE(context, NumInputs(node) == 2 || NumInputs(node) == 3);
77 TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
78
79 const TfLiteTensor* hash = GetInput(context, node, 0);
80 TF_LITE_ENSURE_EQ(context, NumDimensions(hash), 2);
81 // Support up to 32 bits.
82 TF_LITE_ENSURE(context, SizeOfDimension(hash, 1) <= 32);
83
84 const TfLiteTensor* input = GetInput(context, node, 1);
85 TF_LITE_ENSURE(context, NumDimensions(input) >= 1);
86 TF_LITE_ENSURE(context, SizeOfDimension(input, 0) >= 1);
87
88 if (NumInputs(node) == 3) {
89 const TfLiteTensor* weight = GetInput(context, node, 2);
90 TF_LITE_ENSURE_EQ(context, NumDimensions(weight), 1);
91 TF_LITE_ENSURE_EQ(context, SizeOfDimension(weight, 0),
92 SizeOfDimension(input, 0));
93 }
94
95 TfLiteTensor* output = GetOutput(context, node, 0);
96 TfLiteIntArray* outputSize = TfLiteIntArrayCreate(1);
97 switch (params->type) {
98 case kTfLiteLshProjectionSparse:
99 outputSize->data[0] = SizeOfDimension(hash, 0);
100 break;
101 case kTfLiteLshProjectionDense:
102 outputSize->data[0] = SizeOfDimension(hash, 0) * SizeOfDimension(hash, 1);
103 break;
104 default:
105 return kTfLiteError;
106 }
107 return context->ResizeTensor(context, output, outputSize);
108}
109
110// Compute sign bit of dot product of hash(seed, input) and weight.
111// NOTE: use float as seed, and convert it to double as a temporary solution

Callers 11

RuntimeShapeMethod · 0.50
ReplaceWithMethod · 0.50
BuildFromMethod · 0.50
SetWeightsFromArrayMethod · 0.50
AppendMethod · 0.50
MaybeResizeMethod · 0.50
resize_uninitializedMethod · 0.50

Calls 8

NumInputsFunction · 0.85
GetInputFunction · 0.85
NumDimensionsFunction · 0.85
SizeOfDimensionFunction · 0.85
GetOutputFunction · 0.85
TfLiteIntArrayCreateFunction · 0.85
ResizeTensorMethod · 0.80
NumOutputsFunction · 0.70

Tested by

no test coverage detected