diff options
Diffstat (limited to 'libs/ARMComputeEx/arm_compute/core/CL/CLKernelLibraryEx.h')
-rw-r--r-- | libs/ARMComputeEx/arm_compute/core/CL/CLKernelLibraryEx.h | 148 |
1 files changed, 102 insertions, 46 deletions
diff --git a/libs/ARMComputeEx/arm_compute/core/CL/CLKernelLibraryEx.h b/libs/ARMComputeEx/arm_compute/core/CL/CLKernelLibraryEx.h index 026487077..e4e752ef9 100644 --- a/libs/ARMComputeEx/arm_compute/core/CL/CLKernelLibraryEx.h +++ b/libs/ARMComputeEx/arm_compute/core/CL/CLKernelLibraryEx.h @@ -14,6 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/** + * @file CLKernelLibraryEx.h + * @ingroup COM_AI_RUNTIME + * @brief This file is a cloned version of CLKernelLibrary.h in ACL. This file defines + * an interface for CLKernelLibrary.cpp which adds more OpenCL kernels on top of ACL. + */ + #ifndef __ARM_COMPUTE_CLKERNELLIBRARY_EX_H__ #define __ARM_COMPUTE_CLKERNELLIBRARY_EX_H__ @@ -27,58 +35,76 @@ namespace arm_compute { -/** CLKernelLibrary class */ +/** + * @brief Class to build OpenCL kernels added from nnfw + * */ class CLKernelLibraryEx { using StringSet = std::set<std::string>; private: - /** Default Constructor. */ + /** + * @brief Construct a new CLKernelLibraryEx object + */ CLKernelLibraryEx(); public: - /** Prevent instances of this class from being copied */ + /** + * @brief Prevent instances of this class from being copied. + */ CLKernelLibraryEx(const CLKernelLibraryEx &) = delete; - /** Prevent instances of this class from being copied */ + + /** + * @brief Prevent instances of this class from being copied. + */ const CLKernelLibraryEx &operator=(const CLKernelLibraryEx &) = delete; - /** Access the KernelLibrary singleton. - * @return The KernelLibrary instance. + + /** + * @brief Get the KernelLibrary singleton. + * @return The KernelLibrary instance */ static CLKernelLibraryEx &get(); - /** Initialises the kernel library. - * - * @param[in] kernel_path (Optional) Path of the directory from which kernel sources are loaded. - * @param[in] context (Optional) CL context used to create programs. - * @param[in] device (Optional) CL device for which the programs are created. - */ - void init(std::string kernel_path = ".", cl::Context context = cl::Context::getDefault(), - cl::Device device = cl::Device::getDefault()) + + /** + * @brief Initialise the kernel library. + * @param[in] kernel_path Path of the directory from which kernel sources are loaded. + * @param[in] context CL context used to create programs. + * @param[in] device CL device for which the programs are created. + * @return N/A + */ + void init(std::string kernel_path, cl::Context context, cl::Device device) { _kernel_path = std::move(kernel_path); _context = std::move(context); _device = std::move(device); } - /** Sets the path that the kernels reside in. - * - * @param[in] kernel_path Path of the kernel. + + /** + * @brief Set the path that the kernels reside in. + * @param[in] kernel_path Path of the directory from which kernel sources are loaded. + * @return N/A */ void set_kernel_path(const std::string &kernel_path) { _kernel_path = kernel_path; }; - /** Gets the path that the kernels reside in. + + /** + * @brief Get the path that the kernels reside in. + * @return the path of kernel files */ std::string get_kernel_path() { return _kernel_path; }; - /** Gets the source of the selected program. - * + + /** + * @brief Get the source of the selected program. * @param[in] program_name Program name. - * * @return Source of the selected program. */ std::string get_program_source(const std::string &program_name); - /** Sets the CL context used to create programs. - * + + /** + * @brief Set the CL context used to create programs. * @note Setting the context also resets the device to the * first one available in the new context. - * * @param[in] context A CL context. + * @return N/A */ void set_context(cl::Context context) { @@ -102,42 +128,56 @@ public: } } - /** Accessor for the associated CL context. - * + /** + * @brief Return associated CL context. * @return A CL context. */ cl::Context &context() { return _context; } - /** Sets the CL device for which the programs are created. - * + /** + * @brief Set the CL device for which the programs are created. * @param[in] device A CL device. + * @return N/A */ void set_device(cl::Device device) { _device = std::move(device); } - /** Return the device version - * + /** + * @brief Gets the CL device for which the programs are created. + * @return A CL device. + */ + cl::Device &get_device() { return _device; } + + /** + * @brief Return the device version * @return The content of CL_DEVICE_VERSION */ std::string get_device_version(); - /** Creates a kernel from the kernel library. - * + + /** + * @brief Create a kernel from the kernel library. * @param[in] kernel_name Kernel name. * @param[in] build_options_set Kernel build options as a set. - * * @return The created kernel. */ Kernel create_kernel(const std::string &kernel_name, const StringSet &build_options_set = {}) const; - /** Find the maximum number of local work items in a workgroup can be supported for the kernel. - * + + /** + * @brief Find the maximum number of local work items in a workgroup can be supported for the + * kernel. + * @param[in] kernel kernel object */ + size_t max_local_workgroup_size(const cl::Kernel &kernel) const; - /** Return the default NDRange for the device. - * + /** + * @brief Return the default NDRange for the device. + * @return default NDRangeof the device */ cl::NDRange default_ndrange() const; - /** Clear the library's cache of binary programs + /** + * @brief Clear the library's cache of binary programs + * @return N/A */ void clear_programs_cache() { @@ -145,29 +185,45 @@ public: _built_programs_map.clear(); } - /** Access the cache of built OpenCL programs */ + /** + * @brief Access the cache of built OpenCL programs + * @return program map data structure of which key is name of kernel and value is + * kerel source name. (*.cl) + */ const std::map<std::string, cl::Program> &get_built_programs() const { return _built_programs_map; } - /** Add a new built program to the cache - * + /** + * @brief Add a new built program to the cache * @param[in] built_program_name Name of the program * @param[in] program Built program to add to the cache + * @return N/A */ void add_built_program(const std::string &built_program_name, cl::Program program); + /** + * @brief Returns true if FP16 is supported by the CL device + * @return true if the CL device supports FP16 + */ + bool fp16_supported() const; + + /** + * @brief Returns true if int64_base_atomics extension is supported by the CL device + * @return true if the CL device supports int64_base_atomics extension + */ + bool int64_base_atomics_supported() const; + private: - /** Load program and its dependencies. - * + /** + * @brief Load program and its dependencies. * @param[in] program_name Name of the program to load. */ const Program &load_program(const std::string &program_name) const; - /** Concatenates contents of a set into a single string. - * + /** + * @brief Concatenates contents of a set into a single string. * @param[in] s Input set to concatenate. - * * @return Concatenated string. */ std::string stringify_set(const StringSet &s) const; |