| 106 | } |
| 107 | |
| 108 | bool Run(Node* node) |
| 109 | { |
| 110 | Tensor* input_tensor = node->GetInputTensor(0); |
| 111 | Tensor* output_tensor = node->GetOutputTensor(0); |
| 112 | const TShape& shape = output_tensor->GetShape(); |
| 113 | int elem_num = shape.GetSize(); |
| 114 | ReLu* relu_op = dynamic_cast<ReLu*>(node->GetOp()); |
| 115 | ReLuParam* param = relu_op->GetParam(); |
| 116 | float* data = ( float* )get_tensor_mem(input_tensor); |
| 117 | float* out_data = ( float* )get_tensor_mem(output_tensor); |
| 118 | float negativeslope = param->negative_slope; |
| 119 | |
| 120 | int cpu_number = cpu_info->GetCPUNumber(); |
| 121 | int block = elem_num >> 8; |
| 122 | block = block > 0 ? block : 1; |
| 123 | int num_task = cpu_number < block ? cpu_number : block; |
| 124 | int step = elem_num / num_task; |
| 125 | |
| 126 | if(num_task == 1) |
| 127 | relu_kernel( 0, 0, &step, data, out_data, negativeslope); |
| 128 | else |
| 129 | { |
| 130 | MULTI_THREAD_START(num_task, step, p_id, p_param) |
| 131 | relu_kernel(0, p_id, p_param, data, out_data, negativeslope); |
| 132 | MULTI_THREAD_END(); |
| 133 | } |
| 134 | if(num_task * step != elem_num) |
| 135 | { |
| 136 | int offset = num_task * step; |
| 137 | int remain_num = elem_num - offset; |
| 138 | relu_kernel(0, 0, &remain_num, data + offset, out_data + offset, negativeslope); |
| 139 | } |
| 140 | |
| 141 | return true; |
| 142 | } |
| 143 | }; |
| 144 | |
| 145 | NodeOps* SelectFunc(const CPUInfo* cpu_info, Node* node) |
nothing calls this directly
no test coverage detected