#include "kernels/LogSoftmax.h"
#include "kernels/TestUtils.h"
+#include "luci_interpreter/TestMemoryManager.h"
namespace luci_interpreter
{
using namespace testing;
-TEST(LogSoftmaxTest, Float)
+class LogSoftmaxTest : public ::testing::Test
+{
+protected:
+ void SetUp() override { _memory_manager = std::make_unique<TestMemoryManager>(); }
+
+ std::unique_ptr<IMemoryManager> _memory_manager;
+};
+
+TEST_F(LogSoftmaxTest, Float)
{
Shape input_shape{2, 4};
std::vector<float> input_data{
0, -6, 2, 4, //
3, -2, 10, 1, //
};
- Tensor input_tensor = makeInputTensor<DataType::FLOAT32>(input_shape, input_data);
+ Tensor input_tensor =
+ makeInputTensor<DataType::FLOAT32>(input_shape, input_data, _memory_manager.get());
Tensor output_tensor = makeOutputTensor(DataType::FLOAT32);
LogSoftmax kernel(&input_tensor, &output_tensor);
kernel.configure();
+ _memory_manager->allocate_memory(output_tensor);
kernel.execute();
std::vector<float> ref_output_data{
EXPECT_THAT(extractTensorData<float>(output_tensor), FloatArrayNear(ref_output_data));
}
-TEST(LogSoftmaxTest, Uint8)
+TEST_F(LogSoftmaxTest, Uint8)
{
float kMin = -10;
float kMax = 10;
0, -6, 2, 4, //
3, -2, 10, 1, //
};
- Tensor input_tensor =
- makeInputTensor<DataType::U8>({2, 4}, quant_param.first, quant_param.second, input_data);
+ Tensor input_tensor = makeInputTensor<DataType::U8>({2, 4}, quant_param.first, quant_param.second,
+ input_data, _memory_manager.get());
Tensor output_tensor = makeOutputTensor(DataType::U8, 16. / 256, 255);
LogSoftmax kernel(&input_tensor, &output_tensor);
kernel.configure();
+ _memory_manager->allocate_memory(output_tensor);
kernel.execute();
std::vector<float> ref_output_data{
::testing::ElementsAreArray({189, 93, 221, 253, 142, 63, 255, 111}));
}
-TEST(LogSoftmaxTest, InvalidInputOutputType_NEG)
+TEST_F(LogSoftmaxTest, InvalidInputOutputType_NEG)
{
std::vector<float> input_data{
0, -6, 2, 4, //
3, -2, 10, 1, //
};
- Tensor input_tensor = makeInputTensor<DataType::FLOAT32>({2, 4}, input_data);
+ Tensor input_tensor =
+ makeInputTensor<DataType::FLOAT32>({2, 4}, input_data, _memory_manager.get());
Tensor output_tensor = makeOutputTensor(DataType::U8, 16. / 256, 255);
LogSoftmax kernel(&input_tensor, &output_tensor);
EXPECT_ANY_THROW(kernel.configure());
}
-TEST(LogSoftmaxTest, InvalidOutputQuantParam_NEG)
+TEST_F(LogSoftmaxTest, InvalidOutputQuantParam_NEG)
{
std::pair<float, int32_t> quant_param = quantizationParams<uint8_t>(-10, 10);
std::vector<float> input_data{
0, -6, 2, 4, //
3, -2, 10, 1, //
};
- Tensor input_tensor =
- makeInputTensor<DataType::U8>({2, 4}, quant_param.first, quant_param.second, input_data);
+ Tensor input_tensor = makeInputTensor<DataType::U8>({2, 4}, quant_param.first, quant_param.second,
+ input_data, _memory_manager.get());
Tensor output_tensor = makeOutputTensor(DataType::U8, 20. / 256, 255);
LogSoftmax kernel(&input_tensor, &output_tensor);