ArmNN
 21.11
LstmTestImpl.hpp File Reference

Go to the source code of this file.

Functions

LayerTestResult< float, 2 > LstmLayerFloat32WithCifgWithPeepholeNoProjectionTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 2 > LstmLayerFloat32NoCifgNoPeepholeNoProjectionTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 2 > LstmLayerFloat32NoCifgWithPeepholeWithProjectionTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 2 > LstmLayerFloat32NoCifgWithPeepholeWithProjectionWithLayerNormTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 2 > LstmLayerInt16NoCifgNoPeepholeNoProjectionTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 2 > LstmLayerInt16WithCifgWithPeepholeNoProjectionTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 2 > LstmLayerInt16NoCifgWithPeepholeWithProjectionTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 2 > LstmLayerInt16NoCifgNoPeepholeNoProjectionInt16ConstantTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 2 > QuantizedLstmTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int8_t, 2 > QLstmTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int8_t, 2 > QLstmTest1 (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int8_t, 2 > QLstmTest2 (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 

Function Documentation

◆ LstmLayerFloat32NoCifgNoPeepholeNoProjectionTest()

LayerTestResult<float, 2> LstmLayerFloat32NoCifgNoPeepholeNoProjectionTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 2624 of file LstmTestImpl.cpp.

References armnn::Float32.

Referenced by TEST_SUITE().

2628 {
2629  armnn::TensorInfo inputDesc({2, 2}, armnn::DataType::Float32);
2630  std::vector<float> input = {2., 3., 3., 4.};
2631 
2632  armnn::TensorInfo outputDesc({2, 4}, armnn::DataType::Float32);
2633  std::vector<float> expectedOutput =
2634  {-0.02973187f, 0.1229473f, 0.20885126f, -0.15358765f,
2635  -0.0185422f, 0.11281417f, 0.24466537f, -0.1826292f};
2636 
2637  return LstmNoCifgNoPeepholeNoProjectionTestImpl<armnn::DataType::Float32>(
2638  workloadFactory, memoryManager, tensorHandleFactory,
2639  input, expectedOutput, inputDesc.GetShape(), outputDesc.GetShape());
2640 }

◆ LstmLayerFloat32NoCifgWithPeepholeWithProjectionTest()

LayerTestResult<float, 2> LstmLayerFloat32NoCifgWithPeepholeWithProjectionTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 2602 of file LstmTestImpl.cpp.

References armnn::Float32.

Referenced by TEST_SUITE().

2606 {
2607  armnn::TensorInfo inputDesc({ 2, 5 }, armnn::DataType::Float32);
2608  std::vector<float> input =
2609  {0.787926f, 0.151646f, 0.071352f, 0.118426f, 0.458058f,
2610  0.295743f, 0.544053f, 0.690064f, 0.858138f, 0.497181f};
2611 
2612  armnn::TensorInfo outputDesc({ 2, 16 }, armnn::DataType::Float32);
2613  std::vector<float> expectedOutput =
2614  {-0.00396806f, 0.029352f, -0.00279226f, 0.0159977f, -0.00835576f,
2615  -0.0211779f, 0.0283512f, -0.0114597f, 0.00907307f, -0.0244004f,
2616  -0.0152191f, -0.0259063f, 0.00914318f, 0.00415118f, 0.017147f,
2617  0.0134203f, -0.013869f, 0.0287268f, -0.00334693f, 0.00733398f, -0.0287926f,
2618  -0.0186926f, 0.0193662f, -0.0115437f, 0.00422612f, -0.0345232f,
2619  0.00223253f, -0.00957321f, 0.0210624f, 0.013331f, 0.0150954f, 0.02168f};
2620  return LstmLayerNoCifgWithPeepholeWithProjectionTestImpl<armnn::DataType::Float32>(
2621  workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput);
2622 }

◆ LstmLayerFloat32NoCifgWithPeepholeWithProjectionWithLayerNormTest()

LayerTestResult<float, 2> LstmLayerFloat32NoCifgWithPeepholeWithProjectionWithLayerNormTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 2642 of file LstmTestImpl.cpp.

References armnn::Float32.

Referenced by TEST_SUITE().

2646 {
2647  armnn::TensorInfo inputDesc({ 2, 5 }, armnn::DataType::Float32);
2648  std::vector<float> input =
2649  {0.7f, 0.8f, 0.1f, 0.2f, 0.3f, //batch 0
2650  0.3f, 0.2f, 0.9f, 0.8f, 0.1f}; //batch 1
2651 
2652  armnn::TensorInfo outputDesc({ 2, 3 }, armnn::DataType::Float32);
2653  std::vector<float> expectedOutput =
2654  { 0.0244077f, 0.128027f, -0.00170918f, //batch 0
2655  -0.00692428f, 0.0848741f, 0.063445f}; //batch 1
2656  return LstmLayerNoCifgWithPeepholeWithProjectionWithLayerNormTestImpl<armnn::DataType::Float32>(
2657  workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput);
2658 }

◆ LstmLayerFloat32WithCifgWithPeepholeNoProjectionTest()

LayerTestResult<float, 2> LstmLayerFloat32WithCifgWithPeepholeNoProjectionTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 2585 of file LstmTestImpl.cpp.

References armnn::Float32.

Referenced by TEST_SUITE().

2589 {
2590  armnn::TensorInfo inputDesc({ 2, 2 }, armnn::DataType::Float32);
2591  std::vector<float> input = { 2., 3., 3., 4. };
2592 
2593  armnn::TensorInfo outputDesc({ 2, 4 }, armnn::DataType::Float32);
2594  std::vector<float> expectedOutput =
2595  {-0.36444446f, -0.00352185f, 0.12886585f, -0.05163646f,
2596  -0.42734814f, -0.00478661f, 0.13455015f, -0.03560682f};
2597  return LstmLayerWithCifgWithPeepholeNoProjectionTestImpl<armnn::DataType::Float32>(
2598  workloadFactory, memoryManager, tensorHandleFactory,
2599  input, expectedOutput, inputDesc.GetShape(), outputDesc.GetShape());
2600 }

◆ LstmLayerInt16NoCifgNoPeepholeNoProjectionInt16ConstantTest()

LayerTestResult<int16_t, 2> LstmLayerInt16NoCifgNoPeepholeNoProjectionInt16ConstantTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 2754 of file LstmTestImpl.cpp.

References armnn::QSymmS16.

Referenced by TEST_SUITE().

2758 {
2759  const float qScale = 1.0f;
2760  const int32_t qOffset = 0;
2761 
2762  const armnn::DataType datatype = armnn::DataType::QSymmS16; // datatype & constants set to QSymm16
2763 
2764  armnn::TensorInfo inputDesc({2, 2}, datatype);
2765  std::vector<int16_t> input = armnnUtils::QuantizedVector<int16_t>({ 2.f, 3.f, 3.f, 4.f }, qScale, qOffset);
2766 
2767  armnn::TensorInfo outputDesc({2, 4}, datatype);
2768  std::vector<int16_t> expectedOutput = armnnUtils::QuantizedVector<int16_t>(
2769  {
2770  -0.02973187f, 0.12294730f, 0.20885126f, -0.15358765f,
2771  -0.01854220f, 0.11281417f, 0.24466537f, -0.18262920f
2772  },
2773  qScale, qOffset);
2774 
2775  return LstmNoCifgNoPeepholeNoProjectionTestImpl<datatype>(
2776  workloadFactory, memoryManager, tensorHandleFactory,
2777  input, expectedOutput, inputDesc.GetShape(), outputDesc.GetShape(),
2778  qScale, qOffset, datatype);
2779 }
DataType
Definition: Types.hpp:35

◆ LstmLayerInt16NoCifgNoPeepholeNoProjectionTest()

LayerTestResult<int16_t, 2> LstmLayerInt16NoCifgNoPeepholeNoProjectionTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 2660 of file LstmTestImpl.cpp.

References armnn::QAsymmU8, and armnn::QSymmS16.

Referenced by TEST_SUITE().

2664 {
2665  const float qScale = 1.0f;
2666  const int32_t qOffset = 0;
2667 
2668  const armnn::DataType datatype = armnn::DataType::QSymmS16;
2669  const armnn::DataType constantDatatype = armnn::DataType::QAsymmU8;
2670 
2671  armnn::TensorInfo inputDesc({2, 2}, datatype);
2672  std::vector<int16_t> input = armnnUtils::QuantizedVector<int16_t>({ 2.f, 3.f, 3.f, 4.f }, qScale, qOffset);
2673 
2674  armnn::TensorInfo outputDesc({2, 4}, datatype);
2675  std::vector<int16_t> expectedOutput = armnnUtils::QuantizedVector<int16_t>(
2676  {
2677  -0.02973187f, 0.12294730f, 0.20885126f, -0.15358765f,
2678  -0.01854220f, 0.11281417f, 0.24466537f, -0.18262920f
2679  },
2680  qScale, qOffset);
2681 
2682  return LstmNoCifgNoPeepholeNoProjectionTestImpl<datatype>(
2683  workloadFactory, memoryManager, tensorHandleFactory,
2684  input, expectedOutput, inputDesc.GetShape(), outputDesc.GetShape(),
2685  qScale, qOffset, constantDatatype);
2686 
2687 }
DataType
Definition: Types.hpp:35

◆ LstmLayerInt16NoCifgWithPeepholeWithProjectionTest()

LayerTestResult<int16_t, 2> LstmLayerInt16NoCifgWithPeepholeWithProjectionTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 2717 of file LstmTestImpl.cpp.

References armnn::QAsymmU8, and armnn::QSymmS16.

Referenced by TEST_SUITE().

2721 {
2722  const float qScale = 2.0f;
2723  const int32_t qOffset = 0;
2724 
2725  const armnn::DataType datatype = armnn::DataType::QSymmS16;
2726  const armnn::DataType constantDatatype = armnn::DataType::QAsymmU8;
2727 
2728  armnn::TensorInfo inputDesc({ 2, 5 }, datatype);
2729  std::vector<int16_t> input = armnnUtils::QuantizedVector<int16_t>(
2730  {
2731  0.787926f, 0.151646f, 0.071352f, 0.118426f, 0.458058f,
2732  0.295743f, 0.544053f, 0.690064f, 0.858138f, 0.497181f
2733  },
2734  qScale, qOffset);
2735 
2736  armnn::TensorInfo outputDesc({ 2, 16 }, datatype);
2737  std::vector<int16_t> expectedOutput = armnnUtils::QuantizedVector<int16_t>(
2738  {
2739  -0.00396806f, 0.02935200f, -0.00279226f, 0.01599770f,
2740  -0.00835576f, -0.02117790f, 0.02835120f, -0.01145970f,
2741  0.00907307f, -0.02440040f, -0.01521910f, -0.02590630f,
2742  0.00914318f, 0.00415118f, 0.01714700f, 0.01342030f,
2743  -0.01386900f, 0.02872680f, -0.00334693f, 0.00733398f,
2744  -0.02879260f, -0.01869260f, 0.01936620f, -0.01154370f,
2745  0.00422612f, -0.03452320f, 0.00223253f, -0.00957321f,
2746  0.02106240f, 0.01333100f, 0.01509540f, 0.02168000f
2747  },
2748  qScale, qOffset);
2749 
2750  return LstmLayerNoCifgWithPeepholeWithProjectionTestImpl<datatype>(
2751  workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput, qScale, qOffset, constantDatatype);
2752 }
DataType
Definition: Types.hpp:35

◆ LstmLayerInt16WithCifgWithPeepholeNoProjectionTest()

LayerTestResult<int16_t, 2> LstmLayerInt16WithCifgWithPeepholeNoProjectionTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 2689 of file LstmTestImpl.cpp.

References armnn::QAsymmU8, and armnn::QSymmS16.

Referenced by TEST_SUITE().

2693 {
2694  const float qScale = 1.0f;
2695  const int32_t qOffset = 0;
2696 
2697  const armnn::DataType datatype = armnn::DataType::QSymmS16;
2698  const armnn::DataType constantDatatype = armnn::DataType::QAsymmU8;
2699 
2700  armnn::TensorInfo inputDesc({ 2, 2 }, datatype);
2701  std::vector<int16_t> input = armnnUtils::QuantizedVector<int16_t>({ 2.f, 3.f, 3.f, 4.f }, qScale, qOffset);
2702 
2703  armnn::TensorInfo outputDesc({ 2, 4 }, datatype);
2704  std::vector<int16_t> expectedOutput = armnnUtils::QuantizedVector<int16_t>(
2705  {
2706  -0.36444446f, -0.00352185f, 0.12886585f, -0.05163646f,
2707  -0.42734814f, -0.00478661f, 0.13455015f, -0.03560682f
2708  },
2709  qScale, qOffset);
2710 
2711  return LstmLayerWithCifgWithPeepholeNoProjectionTestImpl<datatype>(
2712  workloadFactory, memoryManager, tensorHandleFactory,
2713  input, expectedOutput, inputDesc.GetShape(), outputDesc.GetShape(),
2714  qScale, qOffset, constantDatatype);
2715 }
DataType
Definition: Types.hpp:35

◆ QLstmTest()

LayerTestResult<int8_t, 2> QLstmTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 2801 of file LstmTestImpl.cpp.

References armnn::QAsymmS8.

Referenced by TEST_SUITE().

2805 {
2806  armnn::TensorInfo inputDesc({2, 5}, armnn::DataType::QAsymmS8);
2807  std::vector<int8_t> input = {90, 102, 13, 26, 38, 102, 13, 26, 51, 64};
2808 
2809  armnn::TensorInfo outputDesc({2, 4}, armnn::DataType::QAsymmS8);
2810  std::vector<int8_t> expectedOutput = {-15, 21, 14, 20, -15, 15, 5, 27};
2811 
2812  return QLstmTestImpl(workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput);
2813 }

◆ QLstmTest1()

LayerTestResult<int8_t, 2> QLstmTest1 ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 2815 of file LstmTestImpl.cpp.

References armnn::QAsymmS8.

Referenced by TEST_SUITE().

2819 {
2820  armnn::TensorInfo inputDesc({2, 5}, armnn::DataType::QAsymmS8);
2821  std::vector<int8_t> input = {90, 102, 13, 26, 38, 102, 13, 26, 51, 64};
2822 
2823  armnn::TensorInfo outputDesc({2, 3}, armnn::DataType::QAsymmS8);
2824  std::vector<int8_t> expectedOutput = {127, 127, -108, -67, 127, 127};
2825 
2826  return QLstmTestImpl1(workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput);
2827 }

◆ QLstmTest2()

LayerTestResult<int8_t, 2> QLstmTest2 ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 2829 of file LstmTestImpl.cpp.

References armnn::QAsymmS8.

Referenced by TEST_SUITE().

2833 {
2834  armnn::TensorInfo inputDesc({2, 5}, armnn::DataType::QAsymmS8);
2835  std::vector<int8_t> input = {90, 102, 13, 26, 38, 102, 13, 26, 51, 64};
2836 
2837  armnn::TensorInfo outputDesc({2, 3}, armnn::DataType::QAsymmS8);
2838  std::vector<int8_t> expectedOutput = {127, 127, 127, -128, 127, 127};
2839 
2840  return QLstmTestImpl2(workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput);
2841 }

◆ QuantizedLstmTest()

LayerTestResult<uint8_t, 2> QuantizedLstmTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 2785 of file LstmTestImpl.cpp.

References armnn::QAsymmU8.

Referenced by TEST_SUITE().

2789 {
2790  armnn::TensorInfo inputDesc({2, 2}, armnn::DataType::QAsymmU8);
2791  std::vector<uint8_t> input = {166, 179, 50, 150};
2792 
2793  armnn::TensorInfo outputDesc({2, 4}, armnn::DataType::QAsymmU8);
2794  std::vector<uint8_t> expectedOutput = {140, 151, 146, 112, 136, 156, 142, 112 };
2795 
2796  return QuantizedLstmTestImpl(workloadFactory, memoryManager, tensorHandleFactory,
2797  input, expectedOutput, inputDesc.GetShape(), outputDesc.GetShape());
2798 }