Main Content

getSingleToInt8ConversionExponent

Class: dlhdl.Processor
Namespace: dlhdl

Retrieve exponent value for single-to-int8 data type conversion

Since R2024b

Description

exponentValue = getSingleToInt8ConversionExponent(hProc) returns the exponent value for the single-to-int8 data type conversion for the input layer of the network specified by the deep learning processor object hProc. Use the exponentValue output argument as an input to the Deep Learning HDL Single To Int8 Conversion block.

exponentValue = getSingleToInt8ConversionExponent(hProc,Name=Value) returns the exponent value for the single-to-int8 data type conversion using one or more arguments specified by optional name-value arguments.

example

Input Arguments

expand all

Deep learning processor, specified as a dlhdl.Processor object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Network layer name, specified as a character vector. If you do not specify a layer name, the default layer name is the name of the input layer of the network in the dlhdl.Processor object. The layer name must be the name of a layer in the network specified in the dlhdl.Processor object.

Example: Layer='conv1'

Data Types: char

Output Arguments

expand all

Conversion exponent returned as a scalar constant of data type int8.

Examples

expand all

Retrieve the single-to-int8 data type conversion exponent for a ResNet-18 network.

Create a ResNet-18 network object.

net = resnet18;

Create a random input image of size 224-by-224-by-3 and quantize the network object.

inputSize = net.Layers(1).InputSize;
img = rand(inputSize);
dlQuantObj = dlquantizer(net,ExecutionEnvironment="fpga");
dlQuantObj.calibrate(img)
hPC = dlhdl.ProcessorConfig(Bitstream="zcu102_int8");
hProc = dlhdl.Processor(Network=dlQuantObj,ProcessorConfig=hPC);

Retrieve the single-to-int8 data type conversion exponent for the network input layer.

singletoInt8Exp = getSingleToInt8ConversionExponent(hProc)
### Single To Int8 conversion exponent for "data" Layer is -5.
singletoInt8Exp =
    -5

Retrieve the single-to-int8 data type conversion exponent for the network conv1 layer.

singletoInt8Exp2 = getSingleToInt8ConversionExponent(hProc,Layer='conv1')
### Single To Int8 conversion exponent for "conv1" Layer is -5.
singletoInt8Exp2 =
    -5

Algorithms

The scaling algorithm used to convert single-to-int8 data is int8data = singleData * 2^(-singleToInt8Exponent). The singleToInt8Exponent is the output of the getSingleToInt8ConversionExponent method.

Version History

Introduced in R2024b