Skip to content
Snippets Groups Projects
Commit f0100a63 authored by Maxence Naud's avatar Maxence Naud
Browse files

[Fix] missing include in Scaling_Op kernel

parent 782a87ec
No related branches found
No related tags found
1 merge request!23Tiling
......@@ -9,11 +9,12 @@
*
********************************************************************************/
#ifndef __AIDGE_CPU_OPERATOR_ScalingIMPL_FORWARD_KERNEL_H__
#define __AIDGE_CPU_OPERATOR_ScalingIMPL_FORWARD_KERNEL_H__
#ifndef AIDGE_CPU_OPERATOR_SCALINGIMPL_FORWARD_KERNEL_H
#define AIDGE_CPU_OPERATOR_SCALINGIMPL_FORWARD_KERNEL_H
#include <cmath>
#include <cstddef>
#include "aidge/utils/Registrar.hpp"
#include "aidge/backend/cpu/operator/ScalingImpl.hpp"
//TODO : improve propagate, n2d2 :
......@@ -59,12 +60,13 @@ const O& clamp(const O& x, const O& min, const O& max)
}
template<class O>
O saturate(O value, std::size_t quantizedNbBits, bool isOutputUnsigned) {
O saturate(const O value, const std::size_t quantizedNbBits, const bool isOutputUnsigned) {
// TODO: no assertions in kernel
assert(quantizedNbBits > 0);
const O min = isOutputUnsigned?0:
const O min = isOutputUnsigned ? 0 :
-(1ll << (quantizedNbBits - 1ll));
const O max = isOutputUnsigned?(1ll << quantizedNbBits) - 1ll:
const O max = isOutputUnsigned ? (1ll << quantizedNbBits) - 1ll :
(1ll << (quantizedNbBits - 1ll)) - 1ll;
return clamp(value, min, max);
......@@ -79,8 +81,8 @@ void ScalingImpl_cpu_forward_kernel(const Scaling_Op::Attrs& attrs,
const I* input = static_cast<const I*>(input_);
O* output = static_cast<O*>(output_);
const I& scalingFactor = static_cast<const I&>(std::get<0>(attrs));
std::size_t quantizedNbBits = static_cast<std::size_t>(std::get<1>(attrs));
bool isOutputUnsigned = static_cast<bool>(std::get<2>(attrs));
const std::size_t quantizedNbBits = static_cast<std::size_t>(std::get<1>(attrs));
const bool isOutputUnsigned = static_cast<bool>(std::get<2>(attrs));
for (std::size_t i = 0; i < inputLenght; ++i) {
output[i] = input[i] * scalingFactor;
......@@ -101,4 +103,4 @@ static Registrar<ScalingImplForward_cpu> registrarScalingImplForward_cpu_Float64
} // namespace
} // namespace Aidge
#endif /* __AIDGE_CPU_OPERATOR_ScalingIMPL_FORWARD_KERNEL_H__ */
#endif /* AIDGE_CPU_OPERATOR_SCALINGIMPL_FORWARD_KERNEL_H */
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment