| 685 | } |
| 686 | |
| 687 | std::shared_ptr<KernelWrap> OpenCLRuntime::buildKernelFromSource(const std::string& source, const std::string &kernelName, |
| 688 | const std::set<std::string> &buildOptions, int precisionLevel) { |
| 689 | std::string buildOptionsStr; |
| 690 | if (precisionLevel != 1) { |
| 691 | buildOptionsStr = "-DFLOAT=half -DFLOAT4=half4 -DFLOAT8=half8 -DFLOAT16=half16 -DRI_F=read_imageh -DWI_F=write_imageh -DCONVERT_FLOAT4=convert_half4 -DMNN_SUPPORT_FP16"; |
| 692 | } else { |
| 693 | buildOptionsStr = "-DFLOAT=float -DFLOAT4=float4 -DFLOAT8=float8 -DRI_F=read_imagef -DFLOAT16=float16 -DWI_F=write_imagef -DCONVERT_FLOAT4=convert_float4"; |
| 694 | } |
| 695 | |
| 696 | if(isSetWorkGroupAttribute) { |
| 697 | buildOptionsStr += " -DSET_ATTRIBUTE=true"; |
| 698 | } else { |
| 699 | buildOptionsStr += " -DSET_ATTRIBUTE=false"; |
| 700 | } |
| 701 | for (auto &option : buildOptions) { |
| 702 | buildOptionsStr += " " + option; |
| 703 | } |
| 704 | buildOptionsStr += mDefaultBuildParams; |
| 705 | |
| 706 | cl::Program::Sources sources; |
| 707 | sources.push_back(source); |
| 708 | cl::Program program = cl::Program(context(), sources); |
| 709 | auto status = this->buildProgram(buildOptionsStr, &program); |
| 710 | if (!status) { |
| 711 | FUNC_PRINT_ALL(kernelName.c_str(), s); |
| 712 | } |
| 713 | // mBuildProgramMap.emplace(key, program); |
| 714 | |
| 715 | cl_int res; |
| 716 | std::shared_ptr<cl::Kernel> kernel; |
| 717 | kernel.reset(new cl::Kernel(program, kernelName.c_str(), &res)); |
| 718 | MNN_CHECK_CL_SUCCESS(res, "getKernel"); |
| 719 | std::shared_ptr<KernelWrap> kw(new KernelWrap(kernel, nullptr)); |
| 720 | return kw; |
| 721 | } |
| 722 | |
| 723 | |
| 724 | uint64_t OpenCLRuntime::getMaxWorkGroupSize(std::shared_ptr<KernelWrap> kernel) { |
no test coverage detected