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

Function ConvertToPIOHW4

tensorflow/lite/delegates/gpu/common/convert.cc:167–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167Status ConvertToPIOHW4(absl::Span<const float> in, const OHWI& shape,
168 absl::Span<float> out) {
169 if (in.size() != shape.DimensionsProduct()) {
170 return InvalidArgumentError(absl::StrCat(
171 "ConvertToPIOHW4: Input data size does not match expected size: ",
172 in.size(), " != ", shape.DimensionsProduct()));
173 }
174 if (out.size() != GetElementsSizeForPIOHW4(shape)) {
175 return InvalidArgumentError(absl::StrCat(
176 "ConvertToPIOHW4: Output data size does not match expected size: ",
177 out.size(), " != ", GetElementsSizeForPIOHW4(shape)));
178 }
179
180 int32_t output_channels = shape.o * shape.i;
181 int32_t num_planes =
182 IntegralDivideRoundUp(output_channels, kPiohw4ChannelsInPlane);
183 float* output = out.data();
184 for (int p = 0; p < num_planes; ++p) {
185 for (int h = 0; h < shape.h; ++h) {
186 for (int w = 0; w < shape.w; ++w) {
187 for (int c = 0; c < kPiohw4ChannelsInPlane; ++c) {
188 int output_c = p * kPiohw4ChannelsInPlane + c;
189 (*output++) = output_c >= output_channels
190 ? 0
191 : in[shape.LinearIndex({output_c % shape.o, h, w,
192 output_c / shape.o})];
193 }
194 }
195 }
196 }
197 return OkStatus();
198}
199
200std::vector<float> ConvertToPIOHW4(
201 const Tensor<OHWI, DataType::FLOAT32>& tensor) {

Callers 2

GenerateCodeMethod · 0.85
DepthWiseConvolutionFunction · 0.85

Calls 10

GetElementsSizeForPIOHW4Function · 0.85
OkStatusFunction · 0.85
InvalidArgumentErrorFunction · 0.70
IntegralDivideRoundUpFunction · 0.70
StrCatFunction · 0.50
sizeMethod · 0.45
DimensionsProductMethod · 0.45
dataMethod · 0.45
LinearIndexMethod · 0.45
IgnoreErrorMethod · 0.45

Tested by

no test coverage detected