Skip to content

Commit

Permalink
Merge branch 'master' into set-output-type-for-greedy-decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov authored Jan 31, 2024
2 parents f0fc479 + 408f5c1 commit be6aff0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions .ci/azure/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ jobs:
-DENABLE_CPPLINT=OFF ^
-DENABLE_SAMPLES=OFF ^
-DENABLE_PYTHON=ON ^
-DENABLE_JS=OFF ^
-DCMAKE_C_COMPILER:PATH="$(MSVC_COMPILER_PATH)" ^
-DCMAKE_CXX_COMPILER:PATH="$(MSVC_COMPILER_PATH)" ^
$(OPENVINO_REPO_DIR)
Expand Down
28 changes: 25 additions & 3 deletions modules/nvidia_plugin/src/ops/clamp_cudnn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <cuda/float16.hpp>
#include <cuda/runtime.hpp>
#include <cuda_operation_registry.hpp>
#include <ngraph/util.hpp>
#include <type_traits>

#include "converters.hpp"
Expand Down Expand Up @@ -128,13 +127,36 @@ WorkbufferRequest ClampCuDnnOp::GetWorkBufferRequest() const {
return {{el_size, el_size}, {}};
}

namespace {
template <typename T>
T double_to_int(double x, double float_to_int_converter(double)) {
if (!std::is_integral<T>()) {
OPENVINO_THROW("Function double_to_int template parameter must be an integral type.");
}

x = float_to_int_converter(x);

double min_t = static_cast<double>(std::numeric_limits<T>::min());
if (x < min_t) {
return std::numeric_limits<T>::min();
}

double max_t = static_cast<double>(std::numeric_limits<T>::max());
if (x > max_t) {
return std::numeric_limits<T>::max();
}

return static_cast<T>(x);
}
}

template <typename T>
void ClampCuDnnOp::initBuffers(const Buffers& buffers) const {
T max{};
T min{};
if constexpr (std::is_integral<T>()) {
max = ngraph::double_to_int<T>(max_, std::floor);
min = ngraph::double_to_int<T>(min_, std::ceil);
max = double_to_int<T>(max_, std::floor);
min = double_to_int<T>(min_, std::ceil);
} else {
max = static_cast<T>(max_);
min = static_cast<T>(min_);
Expand Down

0 comments on commit be6aff0

Please sign in to comment.