28 const float *input_data,
30 const float *filter_data,
39 const int batches = input_shape.
dims(0);
40 const int input_depth = input_shape.
dims(3);
41 const int output_depth = filter_shape.
dims(0);
42 const int input_height = input_shape.
dims(1);
43 const int input_width = input_shape.
dims(2);
44 const int filter_height = filter_shape.
dims(1);
45 const int filter_width = filter_shape.
dims(2);
59 for (
int i = 0; i < num_elements; i++)
61 output_data[i] = 0.0f;
65 for (
int batch = 0; batch < batches; ++batch)
67 for (
int in_y = 0; in_y < input_height; ++in_y)
69 for (
int in_x = 0; in_x < input_width; ++in_x)
71 for (
int in_channel = 0; in_channel < input_depth; ++in_channel)
74 const int out_x_origin = (in_x * stride_width) - pad_width;
75 const int out_y_origin = (in_y * stride_height) - pad_height;
76 for (
int filter_y = 0; filter_y < filter_height; ++filter_y)
78 for (
int filter_x = 0; filter_x < filter_width; ++filter_x)
80 for (
int out_channel = 0; out_channel < output_depth; ++out_channel)
83 const int out_x = out_x_origin + filter_x;
84 const int out_y = out_y_origin + filter_y;
86 if ((out_x >= 0) && (out_x < output_width) && (out_y >= 0) &&
87 (out_y < output_height))
90 input_data[
offset(input_shape.
dimsData(), batch, in_y, in_x, in_channel)];
91 float filter_value = filter_data[
offset(filter_shape.
dimsData(), out_channel,
92 filter_y, filter_x, in_channel)];
94 input_value * filter_value;
104 for (
int batch = 0; batch < batches; ++batch)
106 for (
int out_y = 0; out_y < output_height; ++out_y)
108 for (
int out_x = 0; out_x < output_width; ++out_x)
110 for (
int out_channel = 0; out_channel < output_depth; ++out_channel)
115 acc += bias_data[out_channel];
void TransposeConv(const ConvParams ¶ms, const luci_interpreter::RuntimeShape &input_shape, const float *input_data, const luci_interpreter::RuntimeShape &filter_shape, const float *filter_data, const luci_interpreter::RuntimeShape &bias_shape, const float *bias_data, const luci_interpreter::RuntimeShape &output_shape, float *output_data)