| 96 | struct RegionOps : public NodeOps |
| 97 | { |
| 98 | bool Run(Node* node) |
| 99 | { |
| 100 | const Tensor* input_tensor = node->GetInputTensor(0); |
| 101 | Tensor* output_tensor = node->GetOutputTensor(0); |
| 102 | |
| 103 | const std::vector<int>& dims = input_tensor->GetShape().GetDim(); |
| 104 | |
| 105 | float* input = ( float* )get_tensor_mem(input_tensor); |
| 106 | float* output = ( float* )get_tensor_mem(output_tensor); |
| 107 | |
| 108 | Region* reorg_op = dynamic_cast<Region*>(node->GetOp()); |
| 109 | RegionParam* param = reorg_op->GetParam(); |
| 110 | |
| 111 | int hw = dims[2] * dims[3]; |
| 112 | int chw = dims[1] * hw; |
| 113 | int nchw = dims[0] * chw; |
| 114 | int num_box = param->num_box; |
| 115 | int num_class = param->num_classes; |
| 116 | int coords = param->coords; |
| 117 | memcpy(output, input, nchw * sizeof(float)); |
| 118 | |
| 119 | for(int b = 0; b < dims[0]; b++) |
| 120 | { |
| 121 | for(int n = 0; n < num_box; n++) |
| 122 | { |
| 123 | int index = entry_index(b, n * hw, 0, hw, chw, num_class); |
| 124 | logit_activate_array(output + index, 2 * hw); |
| 125 | index = entry_index(b, n * hw, coords, hw, chw, num_class); |
| 126 | logit_activate_array(output + index, hw); |
| 127 | index = entry_index(b, n * hw, coords + 1, hw, chw, num_class); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | int index = entry_index(0, 0, coords + 1, hw, chw, num_class); |
| 132 | softmax_cpu(input + index, num_class, dims[0] * num_box, chw / num_box, hw, hw, output + index); |
| 133 | |
| 134 | return true; |
| 135 | } |
| 136 | }; |
| 137 | |
| 138 | NodeOps* SelectFunc(const CPUInfo* cpu_info, Node* node) |
nothing calls this directly
no test coverage detected