| 159 | }; |
| 160 | |
| 161 | struct KernelTypeParser : ArgsIterator<KernelTypeParser> { |
| 162 | KernelType kernel_type{KernelType::DENSE_TENSOR_KERNEL}; |
| 163 | |
| 164 | // TODO(chenweihang): deal with multiple diff input Tensors |
| 165 | // TODO(chenweihang): add global device guard method to set backend |
| 166 | void operator()(const Tensor& x) { |
| 167 | if (phi::SelectedRows::classof(x.impl().get())) { |
| 168 | kernel_type = KernelType::SELECTED_ROWS_KERNEL; |
| 169 | } else if (phi::SparseCooTensor::classof(x.impl().get())) { |
| 170 | kernel_type = KernelType::SPARSE_COO_KERNEL; |
| 171 | } else if (phi::SparseCsrTensor::classof(x.impl().get())) { |
| 172 | kernel_type = KernelType::SPARSE_CSR_KERNEL; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | // skip other type args, these args don't used in kernel selection |
| 177 | template <typename T> |
| 178 | void operator()(const T& x) { |
| 179 | // do nothing |
| 180 | } |
| 181 | }; |
| 182 | |
| 183 | /* ------------------ for auto parallel ----------------------- */ |
| 184 |
no outgoing calls
no test coverage detected