ArmNN
 22.02
LstmTestImpl.cpp 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 > LstmLayerFloat32NoCifgWithPeepholeWithProjectionTest (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 > 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 2626 of file LstmTestImpl.cpp.

References armnn::Float32.

Referenced by TEST_SUITE().

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

◆ LstmLayerFloat32NoCifgWithPeepholeWithProjectionTest()

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

Definition at line 2604 of file LstmTestImpl.cpp.

References armnn::Float32.

Referenced by TEST_SUITE().

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

◆ LstmLayerFloat32NoCifgWithPeepholeWithProjectionWithLayerNormTest()

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

Definition at line 2644 of file LstmTestImpl.cpp.

References armnn::Float32.

Referenced by TEST_SUITE().

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

◆ LstmLayerFloat32WithCifgWithPeepholeNoProjectionTest()

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

Definition at line 2587 of file LstmTestImpl.cpp.

References armnn::Float32.

Referenced by TEST_SUITE().

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

◆ LstmLayerInt16NoCifgNoPeepholeNoProjectionInt16ConstantTest()

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

Definition at line 2756 of file LstmTestImpl.cpp.

References armnn::QSymmS16.

Referenced by TEST_SUITE().

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

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

Referenced by TEST_SUITE().

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

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

Referenced by TEST_SUITE().

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

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

Referenced by TEST_SUITE().

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

References armnn::QAsymmS8.

Referenced by TEST_SUITE().

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

◆ QLstmTest1()

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

Definition at line 2817 of file LstmTestImpl.cpp.

References armnn::QAsymmS8.

Referenced by TEST_SUITE().

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

◆ QLstmTest2()

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

Definition at line 2831 of file LstmTestImpl.cpp.

References armnn::QAsymmS8.

Referenced by TEST_SUITE().

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

◆ QuantizedLstmTest()

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

Definition at line 2787 of file LstmTestImpl.cpp.

References armnn::QAsymmU8.

Referenced by TEST_SUITE().

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