Skip to content

Commit

Permalink
Define float16_t type in public headers (OpenNMT#841)
Browse files Browse the repository at this point in the history
* Define float16_t type in public headers

The type was hidden in commit
OpenNMT@b3038b8,
but it is actually required by some public functions.

* Cleanup install rule
  • Loading branch information
guillaumekln authored Jun 20, 2022
1 parent ca0b9db commit e34a88c
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ install(
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/ctranslate2"
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h*"
)
3 changes: 3 additions & 0 deletions include/ctranslate2/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
#include <cstdint>
#include <string>

#include <half_float/half.hpp>

#include "devices.h"

namespace ctranslate2 {

using dim_t = int64_t; // This type should be signed.
using float16_t = half_float::half;

enum class DataType {
FLOAT,
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion src/cuda/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "ctranslate2/types.h"

#include "utils.h"
#include "type_dispatch.h"

#if !defined(__CUDACC__) || !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 530
# define CUDA_CAN_USE_HALF 1
Expand Down
2 changes: 0 additions & 2 deletions src/ops/multinomial_cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "ctranslate2/random.h"

#include "type_dispatch.h"

namespace ctranslate2 {
namespace ops {

Expand Down
1 change: 0 additions & 1 deletion src/ops/multinomial_gpu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <cub/block/block_reduce.cuh>
#include <cub/block/block_scan.cuh>

#include "type_dispatch.h"
#include "cuda/helpers.h"
#include "cuda/random.h"

Expand Down
4 changes: 0 additions & 4 deletions src/type_dispatch.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#pragma once

#include <half_float/half.hpp>

#include "ctranslate2/types.h"

namespace ctranslate2 {

using float16_t = half_float::half;

// Inspired by
// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/types.h
// for matching enum values and C++ types.
Expand Down
1 change: 0 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ add_executable(ctranslate2_test
test.cc)
target_include_directories(ctranslate2_test PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../src
${CMAKE_CURRENT_SOURCE_DIR}/../third_party
)
target_link_libraries(ctranslate2_test
${PROJECT_NAME}
Expand Down

0 comments on commit e34a88c

Please sign in to comment.