Skip to content
Snippets Groups Projects
Commit b76754c4 authored by Jerome Hue's avatar Jerome Hue Committed by Maxence Naud
Browse files

Add basic test for Spikegen functions

parent d12e93cd
No related branches found
No related tags found
3 merge requests!414Update version 0.5.1 -> 0.6.0,!408[Add] Dropout Operator,!351feat: add rate spikegen for snns
/********************************************************************************
* Copyright (c) 2025 CEA-List
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
#include <cstdint> // std::uint8_t, std::uint16_t, std::int32_t
#include <vector> // std::vector
#include <catch2/catch_test_macros.hpp>
#include "aidge/data/Spikegen.hpp"
#include "aidge/data/Tensor.hpp"
#include "aidge/utils/ArrayHelpers.hpp"
#include "aidge/utils/TensorUtils.hpp"
namespace Aidge
{
TEST_CASE("[core/data] SpikeGen zeros", "[SpikeGen]") {
auto input = Tensor(Array1D<float, 3>({0,0,0}));
auto expectedOutput = Tensor(Array2D<float, 3, 3>({{{0,0,0}, {0,0,0}, {0,0,0}}}));
auto spikes = spikegenRate(std::make_shared<Tensor>(input), 3);
REQUIRE(approxEq<float>(spikes, expectedOutput));
}
TEST_CASE("[core/data] SpikeGen ones", "[SpikeGen]") {
auto input = Tensor(Array1D<float, 3>({1,1,1}));
auto expectedOutput = Tensor(Array2D<float, 3, 3>({{{1,1,1}, {1,1,1}, {1,1,1}}}));
auto spikes = spikegenRate(std::make_shared<Tensor>(input), 3);
REQUIRE(approxEq<float>(spikes, expectedOutput));
}
} // namespace Aidge
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