ModelEvaluator

Applicable Products

Product

Supported

Ascend 950PR&950DT products

√

Atlas A3 products

√

Atlas A2 products

√

Atlas 200I/500 A2 inference products

√

Atlas inference products

√

Atlas training products

√

Description

Provides a Python instance based on the input data of the bin type for a model to calibrate and infer the model.

Prototype

1
2
class ModelEvaluator(AutoCalibrationEvaluatorBase):
def __init__(self, data_dir, input_shape, data_types):

Parameters

Parameter

Input/Output

Description

data_dir

Input

Path of the .bin dataset that matches the model.

A string.

Format: "data/input1/;data/input2/"

Constraints:

  • The path can contain letters, digits, underscores (_), hyphens (-), and periods (.).
  • If the model has multiple inputs and each input has multiple batches of data, these batches must be stored in different directories and the file in the directories must be arranged in ascending order by name. All input paths must be enclosed in double quotation marks ("") and separated with semicolons (;).
  • The shape of arrays stored in a single .bin file must match that specified by input_shape. For example, if the shape of arrays stored in a single .bin file is 1 × 224 × 224 × 3, that specified in input_shape must also be 1 × 224 × 224 × 3. If multiple .bin files are required for quantization, you can adjust the batch number by using batch_num.

input_shape

Input

Input shape

A string.

Format: "input_name1:n1,c1,h1,w1;input_name2:n2,c2,h2,w2"

Constraints: The specified nodes must be enclosed in double quotation marks ("") and separated with semicolons (;).

data_types

Input

Input data type.

A string.

Format: "float32;float64"

Constraints: If a model has multiple inputs with different data types, the data type of each input must be specified separately. The specified data types must be placed in double quotation marks ("") in the order of the input nodes, and all input data types must be enclosed in double quotation marks ("") and separated by semicolons (;).

Returns

Returns a Python instance.

Example

1
2
3
4
5
6
import amct_pytorch as amct

evaluator = amct.ModelEvaluator(
    data_dir="./data/input_bin/", 
    input_shape="input:32,3,224,224", 
    data_types="float32")