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

Function ShouldStepInRecursion

tensorflow/lite/kernels/skip_gram.cc:68–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68bool ShouldStepInRecursion(const TfLiteSkipGramParams* params,
69 const std::vector<int>& stack, int stack_idx,
70 int num_words) {
71 // If current stack size and next word enumeration are within valid range.
72 if (stack_idx < params->ngram_size && stack[stack_idx] + 1 < num_words) {
73 // If this stack is empty, step in for first word enumeration.
74 if (stack_idx == 0) {
75 return true;
76 }
77 // If next word enumeration are within the range of max_skip_size.
78 // NOTE: equivalent to
79 // next_word_idx = stack[stack_idx] + 1
80 // next_word_idx - stack[stack_idx-1] <= max_skip_size + 1
81 if (stack[stack_idx] - stack[stack_idx - 1] <= params->max_skip_size) {
82 return true;
83 }
84 }
85 return false;
86}
87
88TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
89 auto* params = reinterpret_cast<TfLiteSkipGramParams*>(node->builtin_data);

Callers 1

EvalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected