diff options
author | Vidhya Sudhan Loganathan <vidhyasudhan.loganathan@arm.com> | 2018-05-25 13:21:26 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:52:54 +0000 |
commit | f1f490634f3273e4669f16e663071554df291bea (patch) | |
tree | 3e4e39f3aa5a7ef26cd0d01079a971ad949738e4 /arm_compute | |
parent | 2345f4349761d6c78200f43e1a78289d215825c4 (diff) | |
download | ComputeLibrary-f1f490634f3273e4669f16e663071554df291bea.tar.gz |
COMPMID-655 : Check FP16 is supported by the GPU
Change-Id: I507b04680a4e88426b682bd0be03bccb560ec78d
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/132589
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'arm_compute')
-rw-r--r-- | arm_compute/core/CL/CLKernelLibrary.h | 6 | ||||
-rw-r--r-- | arm_compute/core/CL/CLValidate.h | 38 | ||||
-rw-r--r-- | arm_compute/core/Validate.h | 37 |
3 files changed, 81 insertions, 0 deletions
diff --git a/arm_compute/core/CL/CLKernelLibrary.h b/arm_compute/core/CL/CLKernelLibrary.h index f0dc0b24cf..97537c05d0 100644 --- a/arm_compute/core/CL/CLKernelLibrary.h +++ b/arm_compute/core/CL/CLKernelLibrary.h @@ -329,6 +329,12 @@ public: */ void add_built_program(const std::string &built_program_name, cl::Program program); + /** Returns true if FP16 is supported by the CL device + * + * @return true if the CL device supports FP16 + */ + bool fp16_supported() const; + private: /** Load program and its dependencies. * diff --git a/arm_compute/core/CL/CLValidate.h b/arm_compute/core/CL/CLValidate.h new file mode 100644 index 0000000000..6252f00d3e --- /dev/null +++ b/arm_compute/core/CL/CLValidate.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_CL_VALIDATE_H__ +#define __ARM_COMPUTE_CL_VALIDATE_H__ + +#include "arm_compute/core/Validate.h" + +namespace arm_compute +{ +#define ARM_COMPUTE_ERROR_ON_F16_UNSUPPORTED(tensor) \ + ARM_COMPUTE_ERROR_THROW_ON(::arm_compute::error_on_unsupported_fp16(__func__, __FILE__, __LINE__, tensor, CLKernelLibrary::get().fp16_supported())) + +#define ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(tensor) \ + ARM_COMPUTE_RETURN_ON_ERROR(::arm_compute::error_on_unsupported_fp16(__func__, __FILE__, __LINE__, tensor, CLKernelLibrary::get().fp16_supported())) + +} // namespace arm_compute +#endif /* __ARM_COMPUTE_CL_VALIDATE_H__ */ diff --git a/arm_compute/core/Validate.h b/arm_compute/core/Validate.h index d7a90480fc..4ef94f2c6d 100644 --- a/arm_compute/core/Validate.h +++ b/arm_compute/core/Validate.h @@ -804,6 +804,43 @@ inline arm_compute::Status error_on_data_type_channel_not_in(const char *functio #define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c, ...) \ ARM_COMPUTE_RETURN_ON_ERROR(::arm_compute::error_on_data_type_channel_not_in(__func__, __FILE__, __LINE__, t, c, __VA_ARGS__)) +/** Return an error if the data type of the passed tensor info is FP16 and FP16 extension is not supported by the device. + * + * @param[in] function Function in which the error occurred. + * @param[in] file Name of the file where the error occurred. + * @param[in] line Line on which the error occurred. + * @param[in] tensor_info Tensor info to validate. + * @param[in] is_fp16_supported Is fp16 supported by the device. + * + * @return Status + */ +inline arm_compute::Status error_on_unsupported_fp16(const char *function, const char *file, const int line, + const ITensorInfo *tensor_info, bool is_fp16_supported) +{ + ARM_COMPUTE_RETURN_ERROR_ON_LOC(tensor_info == nullptr, function, file, line); + ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG((tensor_info->data_type() == DataType::F16 && !is_fp16_supported), + function, file, line, "FP16 not supported by the device"); + return arm_compute::Status{}; +} + +/** Return an error if the data type of the passed tensor is FP16 and FP16 extension is not supported by the device. + * + * @param[in] function Function in which the error occurred. + * @param[in] file Name of the file where the error occurred. + * @param[in] line Line on which the error occurred. + * @param[in] tensor Tensor to validate. + * @param[in] is_fp16_supported Is fp16 supported by the device. + * + * @return Status + */ +inline arm_compute::Status error_on_unsupported_fp16(const char *function, const char *file, const int line, + const ITensor *tensor, bool is_fp16_supported) +{ + ARM_COMPUTE_RETURN_ERROR_ON_LOC(tensor == nullptr, function, file, line); + ARM_COMPUTE_RETURN_ON_ERROR(::arm_compute::error_on_unsupported_fp16(function, file, line, tensor->info(), is_fp16_supported)); + return arm_compute::Status{}; +} + /** Return an error if the tensor is not 2D. * * @param[in] function Function in which the error occurred. |