Main Content

getInt8ToSingleConversionExponent

Class: dlhdl.Processor
Namespace: dlhdl

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

Since R2024b

Description

exponentValue = getInt8ToSingleConversionExponent(hProc) returns the exponent value for the int8-to-single data type conversion for the last hardware output 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 Int8 To Single Conversion block.

exponentValue = getInt8ToSingleConversionExponent(hProc,Name=Value) returns the exponent value using one or more arguments specified by 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 last hardware output 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 = 'fc1000'

Data Types: char

Output Arguments

expand all

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

Examples

expand all

Retrieve the int8-to-single 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 int8-to-single data type conversion exponent for the last network hardware output layer.

int8ToSingleExp = getInt8ToSingleConversionExponent(hProc)
### Int8 To Single conversion exponent for "fc1000" Layer is -4.
int8ToSingleExp =
    -4

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

Int8ToSingleExp2 = getInt8ToSingleConversionExponent(hProc,Layer='prob')
### Int8 To Single conversion exponent for "prob" Layer is -4.
Int8ToSingleExp2 =
    -4

Algorithms

The scaling algorithm used to convert int8-to-single data is singleData = int8Data * 2^(int8ToSingleExponent). The int8toSingleExponent is the output of the getInt8ToSingleConversionExponent method.

Version History

Introduced in R2024b