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

Function SelectEval

tensorflow/lite/kernels/select.cc:64–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64TfLiteStatus SelectEval(TfLiteContext* context, TfLiteNode* node) {
65 const TfLiteTensor* input_condition =
66 GetInput(context, node, kInputTensorCondition);
67 const TfLiteTensor* input_x = GetInput(context, node, kInputTensorX);
68 const TfLiteTensor* input_y = GetInput(context, node, kInputTensorY);
69 TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
70
71 bool is_rank_one = !HaveSameShapes(input_condition, input_x);
72
73#define TF_LITE_SELECT(type, op) \
74 reference_ops::op(GetTensorShape(input_condition), \
75 GetTensorData<bool>(input_condition), \
76 GetTensorShape(input_x), GetTensorData<type>(input_x), \
77 GetTensorShape(input_y), GetTensorData<type>(input_y), \
78 GetTensorShape(output), GetTensorData<type>(output));
79
80#define TF_LITE_SWITCH(type, op) \
81 switch (type) { \
82 break; \
83 case kTfLiteBool: \
84 TF_LITE_SELECT(bool, op); \
85 break; \
86 case kTfLiteFloat32: \
87 TF_LITE_SELECT(float, op); \
88 break; \
89 case kTfLiteUInt8: \
90 TF_LITE_SELECT(uint8_t, op); \
91 break; \
92 case kTfLiteInt8: \
93 TF_LITE_SELECT(int8_t, op); \
94 break; \
95 case kTfLiteInt16: \
96 TF_LITE_SELECT(int16_t, op); \
97 break; \
98 case kTfLiteInt32: \
99 TF_LITE_SELECT(int32_t, op); \
100 break; \
101 case kTfLiteInt64: \
102 TF_LITE_SELECT(int64_t, op); \
103 break; \
104 default: \
105 context->ReportError(context, \
106 "Does not support type other than bool|float|int, " \
107 "got %d", \
108 type); \
109 return kTfLiteError; \
110 }
111
112 if (is_rank_one) {
113 TF_LITE_SWITCH(input_x->type, RankOneSelect);
114 } else {
115 TF_LITE_SWITCH(input_x->type, Select);
116 }
117
118#undef TF_LITE_SELECT
119#undef TF_LITE_SWITCH
120 return kTfLiteOk;
121}

Callers

nothing calls this directly

Calls 3

GetInputFunction · 0.85
GetOutputFunction · 0.85
HaveSameShapesFunction · 0.85

Tested by

no test coverage detected