MCPcopy Create free account
hub / github.com/OAID/Tengine / kernel_run

Function kernel_run

executor/operator/common/scale.cpp:41–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40template <typename data_type>
41void kernel_run(void* in_data, void* out_data, void* gamma_data, void* beta_data, const TShape shape)
42{
43 const std::vector<int> dims = shape.GetDim();
44 int batch_number = dims[0];
45 int channel_num = dims[1];
46 int channel_size = dims[2] * dims[3];
47 int img_size = channel_num * channel_size;
48
49 data_type* input = ( data_type* )in_data;
50 data_type* gamma = ( data_type* )gamma_data;
51 data_type* beta = ( data_type* )beta_data;
52 data_type* output = ( data_type* )out_data;
53
54 for(int i = 0; i < batch_number; i++)
55 {
56 for(int c = 0; c < channel_num; c++)
57 {
58 int offset = i * img_size + c * channel_size;
59 for(int l = 0; l < channel_size; l++)
60 {
61 if(beta != nullptr)
62 output[offset + l] = input[offset + l] * gamma[c] + beta[c];
63 else
64 output[offset + l] = input[offset + l] * gamma[c];
65 }
66 }
67 }
68}
69
70struct ScaleOps : public NodeOps
71{

Callers 15

AiderMethod · 0.85
RunMethod · 0.85
RunMethod · 0.85
pool_kernelMethod · 0.85
AiderMethod · 0.85
RunMethod · 0.85
RunMethod · 0.85
pool_kernelMethod · 0.85
RunMethod · 0.85
RunNCHWMethod · 0.85
RunMethod · 0.85
RunMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected