ArmNN
 21.02
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 2701 of file LstmTestImpl.cpp.

References armnn::Float32.

Referenced by BOOST_AUTO_TEST_CASE().

2705 {
2706  armnn::TensorInfo inputDesc({2, 2}, armnn::DataType::Float32);
2707  boost::multi_array<float, 2> input = MakeTensor<float, 2>(inputDesc, std::vector<float>(
2708  {2., 3., 3., 4.}));
2709 
2710  armnn::TensorInfo outputDesc({2, 4}, armnn::DataType::Float32);
2711  boost::multi_array<float, 2> expectedOutput = MakeTensor<float, 2>(outputDesc, std::vector<float>(
2712  {{-0.02973187f, 0.1229473f, 0.20885126f, -0.15358765f,
2713  -0.0185422f, 0.11281417f, 0.24466537f, -0.1826292f}}));
2714 
2715  return LstmNoCifgNoPeepholeNoProjectionTestImpl<armnn::DataType::Float32>(
2716  workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput);
2717 }

◆ LstmLayerFloat32NoCifgWithPeepholeWithProjectionTest()

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

Definition at line 2678 of file LstmTestImpl.cpp.

References armnn::Float32.

Referenced by BOOST_AUTO_TEST_CASE().

2682 {
2683  armnn::TensorInfo inputDesc({ 2, 5 }, armnn::DataType::Float32);
2684  boost::multi_array<float, 2> input = MakeTensor<float, 2>(inputDesc, std::vector<float>(
2685  {0.787926f, 0.151646f, 0.071352f, 0.118426f, 0.458058f,
2686  0.295743f, 0.544053f, 0.690064f, 0.858138f, 0.497181f}));
2687 
2688  armnn::TensorInfo outputDesc({ 2, 16 }, armnn::DataType::Float32);
2689  boost::multi_array<float, 2> expectedOutput = MakeTensor<float, 2>(outputDesc, std::vector<float>(
2690  {-0.00396806f, 0.029352f, -0.00279226f, 0.0159977f, -0.00835576f,
2691  -0.0211779f, 0.0283512f, -0.0114597f, 0.00907307f, -0.0244004f,
2692  -0.0152191f, -0.0259063f, 0.00914318f, 0.00415118f, 0.017147f,
2693  0.0134203f, -0.013869f, 0.0287268f, -0.00334693f, 0.00733398f, -0.0287926f,
2694  -0.0186926f, 0.0193662f, -0.0115437f, 0.00422612f, -0.0345232f,
2695  0.00223253f, -0.00957321f, 0.0210624f, 0.013331f, 0.0150954f,
2696  0.02168f}));
2697  return LstmLayerNoCifgWithPeepholeWithProjectionTestImpl<armnn::DataType::Float32>(
2698  workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput);
2699 }

◆ LstmLayerFloat32NoCifgWithPeepholeWithProjectionWithLayerNormTest()

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

Definition at line 2719 of file LstmTestImpl.cpp.

References armnn::Float32.

Referenced by BOOST_AUTO_TEST_CASE().

2723 {
2724  armnn::TensorInfo inputDesc({ 2, 5 }, armnn::DataType::Float32);
2725  boost::multi_array<float, 2> input = MakeTensor<float, 2>(inputDesc, std::vector<float>(
2726  {0.7f, 0.8f, 0.1f, 0.2f, 0.3f, //batch 0
2727  0.3f, 0.2f, 0.9f, 0.8f, 0.1f})); //batch 1
2728 
2729  armnn::TensorInfo outputDesc({ 2, 3 }, armnn::DataType::Float32);
2730  boost::multi_array<float, 2> expectedOutput = MakeTensor<float, 2>(outputDesc, std::vector<float>(
2731  { 0.0244077f, 0.128027f, -0.00170918f, //batch 0
2732  -0.00692428f, 0.0848741f, 0.063445f})); //batch 1
2733  return LstmLayerNoCifgWithPeepholeWithProjectionWithLayerNormTestImpl<armnn::DataType::Float32>(
2734  workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput);
2735 }

◆ LstmLayerFloat32WithCifgWithPeepholeNoProjectionTest()

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

Definition at line 2661 of file LstmTestImpl.cpp.

References armnn::Float32.

Referenced by BOOST_AUTO_TEST_CASE().

2665 {
2666  armnn::TensorInfo inputDesc({ 2, 2 }, armnn::DataType::Float32);
2667  boost::multi_array<float, 2> input = MakeTensor<float, 2>(inputDesc, std::vector<float>(
2668  { 2., 3., 3., 4. }));
2669 
2670  armnn::TensorInfo outputDesc({ 2, 4 }, armnn::DataType::Float32);
2671  boost::multi_array<float, 2> expectedOutput = MakeTensor<float, 2>(outputDesc, std::vector<float>(
2672  {-0.36444446f, -0.00352185f, 0.12886585f, -0.05163646f,
2673  -0.42734814f, -0.00478661f, 0.13455015f, -0.03560682f}));
2674  return LstmLayerWithCifgWithPeepholeNoProjectionTestImpl<armnn::DataType::Float32>(
2675  workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput);
2676 }

◆ LstmLayerInt16NoCifgNoPeepholeNoProjectionInt16ConstantTest()

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

Definition at line 2843 of file LstmTestImpl.cpp.

References armnn::QSymmS16.

Referenced by BOOST_AUTO_TEST_CASE().

2847 {
2848  const float qScale = 1.0f;
2849  const int32_t qOffset = 0;
2850 
2851  const armnn::DataType datatype = armnn::DataType::QSymmS16; // datatype & constants set to QSymm16
2852 
2853  armnn::TensorInfo inputDesc({2, 2}, datatype);
2854  boost::multi_array<int16_t , 2> input =
2855  MakeTensor<int16_t , 2>(inputDesc,
2856  armnnUtils::QuantizedVector<int16_t>({ 2.f, 3.f, 3.f, 4.f }, qScale, qOffset));
2857 
2858  armnn::TensorInfo outputDesc({2, 4}, datatype);
2859  boost::multi_array<int16_t, 2> expectedOutput =
2860  MakeTensor<int16_t, 2>(
2861  outputDesc,
2862  armnnUtils::QuantizedVector<int16_t>(
2863  {
2864  -0.02973187f, 0.12294730f, 0.20885126f, -0.15358765f,
2865  -0.01854220f, 0.11281417f, 0.24466537f, -0.18262920f
2866  },
2867  qScale, qOffset));
2868 
2869  return LstmNoCifgNoPeepholeNoProjectionTestImpl<datatype>(
2870  workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput, qScale, qOffset, datatype);
2871 }
DataType
Definition: Types.hpp:32

◆ LstmLayerInt16NoCifgNoPeepholeNoProjectionTest()

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

Definition at line 2737 of file LstmTestImpl.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

2741 {
2742  const float qScale = 1.0f;
2743  const int32_t qOffset = 0;
2744 
2745  const armnn::DataType datatype = armnn::DataType::QSymmS16;
2746  const armnn::DataType constantDatatype = armnn::DataType::QAsymmU8;
2747 
2748  armnn::TensorInfo inputDesc({2, 2}, datatype);
2749  boost::multi_array<int16_t , 2> input = MakeTensor<int16_t , 2>(
2750  inputDesc,
2751  armnnUtils::QuantizedVector<int16_t>({ 2.f, 3.f, 3.f, 4.f }, qScale, qOffset));
2752 
2753  armnn::TensorInfo outputDesc({2, 4}, datatype);
2754  boost::multi_array<int16_t, 2> expectedOutput = MakeTensor<int16_t, 2>(
2755  outputDesc,
2756  armnnUtils::QuantizedVector<int16_t>(
2757  {
2758  -0.02973187f, 0.12294730f, 0.20885126f, -0.15358765f,
2759  -0.01854220f, 0.11281417f, 0.24466537f, -0.18262920f
2760  },
2761  qScale, qOffset));
2762 
2763  return LstmNoCifgNoPeepholeNoProjectionTestImpl<datatype>(
2764  workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput, qScale, qOffset, constantDatatype);
2765 
2766 }
DataType
Definition: Types.hpp:32

◆ LstmLayerInt16NoCifgWithPeepholeWithProjectionTest()

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

Definition at line 2800 of file LstmTestImpl.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

2804 {
2805  const float qScale = 2.0f;
2806  const int32_t qOffset = 0;
2807 
2808  const armnn::DataType datatype = armnn::DataType::QSymmS16;
2809  const armnn::DataType constantDatatype = armnn::DataType::QAsymmU8;
2810 
2811  armnn::TensorInfo inputDesc({ 2, 5 }, datatype);
2812  boost::multi_array<int16_t, 2> input =
2813  MakeTensor<int16_t, 2>(
2814  inputDesc,
2815  armnnUtils::QuantizedVector<int16_t>(
2816  {
2817  0.787926f, 0.151646f, 0.071352f, 0.118426f, 0.458058f,
2818  0.295743f, 0.544053f, 0.690064f, 0.858138f, 0.497181f
2819  },
2820  qScale, qOffset));
2821 
2822  armnn::TensorInfo outputDesc({ 2, 16 }, datatype);
2823  boost::multi_array<int16_t, 2> expectedOutput =
2824  MakeTensor<int16_t, 2>(
2825  outputDesc,
2826  armnnUtils::QuantizedVector<int16_t>(
2827  {
2828  -0.00396806f, 0.02935200f, -0.00279226f, 0.01599770f,
2829  -0.00835576f, -0.02117790f, 0.02835120f, -0.01145970f,
2830  0.00907307f, -0.02440040f, -0.01521910f, -0.02590630f,
2831  0.00914318f, 0.00415118f, 0.01714700f, 0.01342030f,
2832  -0.01386900f, 0.02872680f, -0.00334693f, 0.00733398f,
2833  -0.02879260f, -0.01869260f, 0.01936620f, -0.01154370f,
2834  0.00422612f, -0.03452320f, 0.00223253f, -0.00957321f,
2835  0.02106240f, 0.01333100f, 0.01509540f, 0.02168000f
2836  },
2837  qScale, qOffset));
2838 
2839  return LstmLayerNoCifgWithPeepholeWithProjectionTestImpl<datatype>(
2840  workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput, qScale, qOffset, constantDatatype);
2841 }
DataType
Definition: Types.hpp:32

◆ LstmLayerInt16WithCifgWithPeepholeNoProjectionTest()

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

Definition at line 2768 of file LstmTestImpl.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

2772 {
2773  const float qScale = 1.0f;
2774  const int32_t qOffset = 0;
2775 
2776  const armnn::DataType datatype = armnn::DataType::QSymmS16;
2777  const armnn::DataType constantDatatype = armnn::DataType::QAsymmU8;
2778 
2779  armnn::TensorInfo inputDesc({ 2, 2 }, datatype);
2780  boost::multi_array<int16_t, 2> input =
2781  MakeTensor<int16_t, 2>(
2782  inputDesc,
2783  armnnUtils::QuantizedVector<int16_t>({ 2.f, 3.f, 3.f, 4.f }, qScale, qOffset));
2784 
2785  armnn::TensorInfo outputDesc({ 2, 4 }, datatype);
2786  boost::multi_array<int16_t, 2> expectedOutput =
2787  MakeTensor<int16_t, 2>(
2788  outputDesc,
2789  armnnUtils::QuantizedVector<int16_t>(
2790  {
2791  -0.36444446f, -0.00352185f, 0.12886585f, -0.05163646f,
2792  -0.42734814f, -0.00478661f, 0.13455015f, -0.03560682f
2793  },
2794  qScale, qOffset));
2795 
2796  return LstmLayerWithCifgWithPeepholeNoProjectionTestImpl<datatype>(
2797  workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput, qScale, qOffset, constantDatatype);
2798 }
DataType
Definition: Types.hpp:32

◆ QLstmTest()

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

Definition at line 2894 of file LstmTestImpl.cpp.

References armnn::QAsymmS8.

Referenced by BOOST_AUTO_TEST_CASE().

2898 {
2899  armnn::TensorInfo inputDesc({2, 5}, armnn::DataType::QAsymmS8);
2900  boost::multi_array<int8_t, 2> input = MakeTensor<int8_t, 2>(inputDesc, std::vector<int8_t>(
2901  {90, 102, 13, 26, 38, 102, 13, 26, 51, 64}));
2902 
2903  armnn::TensorInfo outputDesc({2, 4}, armnn::DataType::QAsymmS8);
2904  boost::multi_array<int8_t, 2> expectedOutput = MakeTensor<int8_t, 2>(outputDesc, std::vector<int8_t>(
2905  {-15, 21, 14, 20, -15, 15, 5, 27}));
2906 
2907  return QLstmTestImpl(workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput);
2908 }

◆ QLstmTest1()

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

Definition at line 2910 of file LstmTestImpl.cpp.

References armnn::QAsymmS8.

Referenced by BOOST_AUTO_TEST_CASE().

2914 {
2915  armnn::TensorInfo inputDesc({2, 5}, armnn::DataType::QAsymmS8);
2916  boost::multi_array<int8_t, 2> input = MakeTensor<int8_t, 2>(inputDesc, std::vector<int8_t>(
2917  {90, 102, 13, 26, 38, 102, 13, 26, 51, 64}));
2918 
2919  armnn::TensorInfo outputDesc({2, 3}, armnn::DataType::QAsymmS8);
2920  boost::multi_array<int8_t, 2> expectedOutput = MakeTensor<int8_t, 2>(outputDesc, std::vector<int8_t>(
2921  {127, 127, -108, -67, 127, 127}));
2922 
2923  return QLstmTestImpl1(workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput);
2924 }

◆ QLstmTest2()

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

Definition at line 2926 of file LstmTestImpl.cpp.

References armnn::QAsymmS8.

Referenced by BOOST_AUTO_TEST_CASE().

2930 {
2931  armnn::TensorInfo inputDesc({2, 5}, armnn::DataType::QAsymmS8);
2932  boost::multi_array<int8_t, 2> input = MakeTensor<int8_t, 2>(inputDesc, std::vector<int8_t>(
2933  {90, 102, 13, 26, 38, 102, 13, 26, 51, 64}));
2934 
2935  armnn::TensorInfo outputDesc({2, 3}, armnn::DataType::QAsymmS8);
2936  boost::multi_array<int8_t, 2> expectedOutput = MakeTensor<int8_t, 2>(outputDesc, std::vector<int8_t>(
2937  {127, 127, 127, -128, 127, 127}));
2938 
2939  return QLstmTestImpl2(workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput);
2940 }

◆ QuantizedLstmTest()

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

Definition at line 2877 of file LstmTestImpl.cpp.

References armnn::QAsymmU8.

2881 {
2882  armnn::TensorInfo inputDesc({2, 2}, armnn::DataType::QAsymmU8);
2883  boost::multi_array<uint8_t, 2> input = MakeTensor<uint8_t, 2>(inputDesc, std::vector<uint8_t>(
2884  {166, 179, 50, 150}));
2885 
2886  armnn::TensorInfo outputDesc({2, 4}, armnn::DataType::QAsymmU8);
2887  boost::multi_array<uint8_t, 2> expectedOutput = MakeTensor<uint8_t, 2>(outputDesc, std::vector<uint8_t>(
2888  {140, 151, 146, 112, 136, 156, 142, 112 }));
2889 
2890  return QuantizedLstmTestImpl(workloadFactory, memoryManager, tensorHandleFactory, input, expectedOutput);
2891 }