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

Method PadContext

tensorflow/lite/kernels/pad.cc:37–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35
36struct PadContext {
37 PadContext(TfLiteContext* context, TfLiteNode* node) {
38 input = GetInput(context, node, 0);
39 paddings = GetInput(context, node, 1);
40 if (NumInputs(node) == 3) {
41 constant_values = GetOptionalInputTensor(context, node, 2);
42 } else {
43 constant_values = nullptr;
44 }
45 output = GetOutput(context, node, 0);
46 dims = NumDimensions(input);
47
48 resizing_category = ResizingCategory::kGenericResize;
49 const int paddings_total = GetTensorShape(paddings).FlatSize();
50 const int32* paddings_data = GetTensorData<int32>(paddings);
51 // Paddings will be a n,2 array, and we need to detect 4D arrays with the
52 // pattern { {0,0}, {a, b}, {c, d}, {0,0} }.
53 if (IsConstantTensor(paddings) && paddings_total == 8 &&
54 (paddings_data[0] == 0 && paddings_data[1] == 0) &&
55 (paddings_data[6] == 0 && paddings_data[7] == 0)) {
56 resizing_category = ResizingCategory::kImageStyle;
57 }
58 }
59 const TfLiteTensor* constant_values;
60 const TfLiteTensor* input;
61 const TfLiteTensor* paddings;

Callers

nothing calls this directly

Calls 8

GetInputFunction · 0.85
NumInputsFunction · 0.85
GetOptionalInputTensorFunction · 0.85
GetOutputFunction · 0.85
NumDimensionsFunction · 0.85
FlatSizeMethod · 0.80
IsConstantTensorFunction · 0.70
GetTensorShapeFunction · 0.50

Tested by

no test coverage detected