| 1903 | } |
| 1904 | |
| 1905 | flatbuffers::Offset<TensorInfo> SerializerStrategy::CreateTensorInfo(const armnn::TensorInfo& tensorInfo) |
| 1906 | { |
| 1907 | // Get the dimensions |
| 1908 | std::vector<unsigned int> shape; |
| 1909 | std::vector<bool> specificity; |
| 1910 | // This assumes that the TensorShape constructors have ensured that the size of m_DimensionsSpecificity |
| 1911 | // matches the size of dimensions. |
| 1912 | for(unsigned int dim = 0; dim < tensorInfo.GetShape().GetNumDimensions(); ++dim) |
| 1913 | { |
| 1914 | specificity.push_back(tensorInfo.GetShape().GetDimensionSpecificity(dim)); |
| 1915 | |
| 1916 | if (tensorInfo.GetShape().GetDimensionSpecificity(dim)) |
| 1917 | { |
| 1918 | shape.push_back(tensorInfo.GetShape()[dim]); |
| 1919 | } |
| 1920 | else |
| 1921 | { |
| 1922 | shape.push_back(0); |
| 1923 | } |
| 1924 | } |
| 1925 | |
| 1926 | if (tensorInfo.HasPerAxisQuantization()) |
| 1927 | { |
| 1928 | // Create FlatBuffer TensorInfo |
| 1929 | auto flatBufferTensorInfo = |
| 1930 | serializer::CreateTensorInfo(m_flatBufferBuilder, |
| 1931 | m_flatBufferBuilder.CreateVector(shape), |
| 1932 | GetFlatBufferDataType(tensorInfo.GetDataType()), |
| 1933 | tensorInfo.GetQuantizationScales()[0], |
| 1934 | tensorInfo.GetQuantizationOffset(), |
| 1935 | m_flatBufferBuilder.CreateVector(tensorInfo.GetQuantizationScales()), |
| 1936 | tensorInfo.GetQuantizationDim().value(), |
| 1937 | static_cast<unsigned int> |
| 1938 | (tensorInfo.GetShape().GetDimensionality()), |
| 1939 | m_flatBufferBuilder.CreateVector(specificity)); |
| 1940 | return flatBufferTensorInfo; |
| 1941 | } |
| 1942 | |
| 1943 | // Create FlatBuffer TensorInfo |
| 1944 | auto flatBufferTensorInfo = serializer::CreateTensorInfo(m_flatBufferBuilder, |
| 1945 | m_flatBufferBuilder.CreateVector(shape), |
| 1946 | GetFlatBufferDataType(tensorInfo.GetDataType()), |
| 1947 | tensorInfo.GetQuantizationScale(), |
| 1948 | tensorInfo.GetQuantizationOffset(), |
| 1949 | 0, |
| 1950 | 0, |
| 1951 | static_cast<unsigned int> |
| 1952 | (tensorInfo.GetShape().GetDimensionality()), |
| 1953 | m_flatBufferBuilder.CreateVector(specificity)); |
| 1954 | return flatBufferTensorInfo; |
| 1955 | } |
| 1956 | |
| 1957 | flatbuffers::Offset<serializer::ConstTensor> |
| 1958 | SerializerStrategy::CreateConstTensorInfo(const armnn::ConstTensor& constTensor) |
nothing calls this directly
no test coverage detected