MCPcopy Create free account
hub / github.com/ARM-software/armnn / CreateTensorInfo

Method CreateTensorInfo

src/armnnSerializer/Serializer.cpp:1905–1955  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1903}
1904
1905flatbuffers::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
1957flatbuffers::Offset<serializer::ConstTensor>
1958 SerializerStrategy::CreateConstTensorInfo(const armnn::ConstTensor& constTensor)

Callers

nothing calls this directly

Calls 12

GetFlatBufferDataTypeFunction · 0.85
push_backMethod · 0.80
GetQuantizationScalesMethod · 0.80
GetQuantizationDimMethod · 0.80
GetDimensionalityMethod · 0.80
GetNumDimensionsMethod · 0.45
GetShapeMethod · 0.45
GetDataTypeMethod · 0.45
GetQuantizationOffsetMethod · 0.45
valueMethod · 0.45
GetQuantizationScaleMethod · 0.45

Tested by

no test coverage detected