Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1787 from xsacha/FP16
Browse files Browse the repository at this point in the history
Add FP16
  • Loading branch information
ruslo authored Mar 19, 2019
2 parents b9d11ac + d8f109e commit c04cf08
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/configs/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ hunter_default_version(CsvParserCPlusPlus VERSION 1.0.1)
hunter_default_version(Eigen VERSION 3.3.7)
hunter_default_version(EnumGroup VERSION 0.0.1)
hunter_default_version(Expat VERSION 2.1.1)
hunter_default_version(FP16 VERSION 0.0.0-febbb1c-p0)
hunter_default_version(FakeIt VERSION 2.0.3)
hunter_default_version(Fruit VERSION 3.1.1-p0)
hunter_default_version(FunctionalPlus VERSION 0.2-p0)
Expand Down
27 changes: 27 additions & 0 deletions cmake/projects/FP16/hunter.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 2016-2019, Ruslan Baratov
# All rights reserved.

# !!! DO NOT PLACE HEADER GUARDS HERE !!!

include(hunter_add_version)
include(hunter_cacheable)
include(hunter_download)
include(hunter_pick_scheme)
include(hunter_cmake_args)

hunter_add_version(
PACKAGE_NAME
FP16
VERSION
0.0.0-febbb1c-p0
URL
"https://github.com/hunter-packages/FP16/archive/v0.0.0-febbb1c-p0.tar.gz"
SHA1
86a7e35a2193e60440ea152628ade89eff4cd0cd
)

hunter_cmake_args(FP16 CMAKE_ARGS FP16_BUILD_BENCHMARKS=OFF FP16_BUILD_TESTS=OFF)

hunter_pick_scheme(DEFAULT url_sha1_cmake)
hunter_cacheable(FP16)
hunter_download(PACKAGE_NAME FP16)
21 changes: 21 additions & 0 deletions docs/packages/pkg/FP16.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. spelling::

FP

.. index::
single: cpu ; FP16

.. _pkg.FP16:

FP16
====

- `Official <https://github.com/Maratyszcza/FP16>`__
- `Hunterized <https://github.com/hunter-packages/FP16>`__
- `Example <https://github.com/ruslo/hunter/blob/master/examples/FP16/CMakeLists.txt>`__
- Added by `xsacha <https://github.com/xsacha>`__ (`pr-1787 <https://github.com/ruslo/hunter/pull/1787>`__)

.. literalinclude:: /../examples/FP16/CMakeLists.txt
:language: cmake
:start-after: # DOCUMENTATION_START {
:end-before: # DOCUMENTATION_END }
18 changes: 18 additions & 0 deletions examples/FP16/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2016-2018, Ruslan Baratov
# All rights reserved.

cmake_minimum_required(VERSION 3.2)

# Emulate HunterGate:
# * https://github.com/hunter-packages/gate
include("../common.cmake")

project(download-FP16)

# DOCUMENTATION_START {
hunter_add_package(FP16)
find_package(FP16 REQUIRED)

add_executable(boo boo.cpp)
target_link_libraries(boo PUBLIC FP16::fp16)
# DOCUMENTATION_END }
16 changes: 16 additions & 0 deletions examples/FP16/boo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <fp16.h>

int main() {
// Test FP16
const uint16_t min_po2_f16 = UINT16_C(0x0400);
const float min_po2_value = fp16_ieee_to_fp32_value(min_po2_f16);

const uint16_t positive_infinity_f16 = UINT16_C(0x7C00);
const uint16_t negative_infinity_f16 = UINT16_C(0xFC00);

const uint32_t positive_infinity_f32 = UINT32_C(0x7F800000);
const uint32_t negative_infinity_f32 = UINT32_C(0xFF800000);


return 0;
}

0 comments on commit c04cf08

Please sign in to comment.