scalesim.compute package
Submodules
scalesim.compute.operand_matrix module
- class scalesim.compute.operand_matrix.operand_matrix[source]
Bases:
objectClass which creates the ifmap, filter and ofmap operand matrices to be used in compute simulation
- calc_filter_elem_addr(i, j)[source]
Method to calculate the address of a filter element.
- Returns:
Filter pixel address
- calc_ifmap_elem_addr(i, j)[source]
Method to calculate the address of an ifmap element.
- Returns:
Ifmap pixel address
- calc_ofmap_elem_addr(i, j)[source]
Method to calculate the address of an ofmap element.
- Returns:
Ifmap pixel address
- create_operand_matrices()[source]
Method to create ifmap, filter and ofmap operand matrices.
- Returns:
None
- get_all_operand_matrix()[source]
Method to get ifmap, filter and ofmap operand matrices.
- Returns:
Ifmap, filter and ofmap operand matrices
- get_filter_matrix_part(start_row=0, num_rows=-1, start_col=0, num_cols=-1)[source]
Method to get a part or full filter operand matrix if no error. If error, return the error code.
- Parameters:
start_row – Start row index
num_rows – Number of rows in the output matrix
start_col – Start col index
num_cols – Number of columns in the output matrix
- Returns:
Error code, A part or full filter operand matrix
- get_ifmap_matrix_part(start_row=0, num_rows=-1, start_col=0, num_cols=-1)[source]
Method to get a part or full ifmap operand matrix if no error. If error, return the error code.
- Parameters:
start_row – Start row index
num_rows – Number of rows in the output matrix
start_col – Start col index
num_cols – Number of columns in the output matrix
- Returns:
Error code, A part or full ifmap operand matrix
- get_ofmap_matrix_part(start_row=0, num_rows=-1, start_col=0, num_cols=-1)[source]
Method to get a part or full ofmap operand matrix if no error. If error, return the error code.
- Parameters:
start_row – Start row index
num_rows – Number of rows in the output matrix
start_col – Start col index
num_cols – Number of columns in the output matrix
- Returns:
Error code, A part or full ofmap operand matrix
- set_params(config_obj, topoutil_obj, layer_id=0)[source]
Method to set the operand matrix parameters for housekeeping.
- Parameters:
config_obj – Object of scalesim.scale_config which is used to lookup the architecture and run parameters set by the user
topoutil_obj – Object of scalesim.topology_utils which is used to preprocess the workload dimensions
layer_id – Layer number of the workload
- Returns:
None
scalesim.compute.systolic_compute_is module
- scalesim.compute.systolic_compute_is.skew_matrix(input_matrix_np)[source]
Method to add skew to the input matix to maintain systolic array flow. .. rubric:: Example
Input matrix 1 1 1 1 1 1 1 1 1
- Output matrix
1 1 1
1 1 1
1 1 1
- Parameters:
input_matrix_np – input matrix to be skewed
- Returns:
None
- class scalesim.compute.systolic_compute_is.systolic_compute_is[source]
Bases:
objectClass which runs the compute simulation in input stationary dataflow
- create_demand_matrices()[source]
Method to create ifmap, filter and ofmap demand matrices from the operand matrices. They contain several folds of ifmap, filter and ofmap demands. The folding happens because operand matrices are generally larger than systolic array dimensions.
- Returns:
None
- create_prefetch_matrices()[source]
Method to create ifmap and filter prefetch matrices. These matrices are prefetched in the SRAM before running memory simulation.
- Returns:
None
- get_avg_compute_utilization()[source]
Method to get average compute utilization on the systolic array.
- Returns:
Average compute utilization
- get_avg_mapping_efficiency()[source]
Method to get average mapping efficincy on the systolic array.
- Returns:
Average mapping efficincy
- get_demand_matrices()[source]
Method to get ifmap, filter and ofmap demand matrices.
- Returns:
Ifmap, filter and ofmap demand matrices
- get_filter_prefetch_mat()[source]
Method to get filter prefetch matrix.
- Returns:
Filter prefetch matrix
- get_filter_requests()[source]
Method to get filter read requests.
- Returns:
Number of filter read requests
- get_ifmap_prefetch_mat()[source]
Method to get ifmap prefetch matrix.
- Returns:
Ifmap prefetch matrix
- get_ifmap_requests()[source]
Method to get ifmap read requests.
- Returns:
Number of ifmap read requests
- get_ofmap_requests()[source]
Method to get ofmap write requests.
- Returns:
Number of ofmap write requests
- get_prefetch_matrices()[source]
Method to get ifmap and filter prefetch matrices.
- Returns:
Ifmap and filter prefetch matrices
- set_params(config_obj=<scalesim.scale_config.scale_config object>, ifmap_op_mat=array([[0.]]), ofmap_op_mat=array([[0.]]), filter_op_mat=array([[0.]]))[source]
Method to set the input stationary run parameters for housekeeping.
- Parameters:
config_obj – Object of scalesim.scale_config which is used to lookup the architecture and run parameters set by the user
ifmap_op_mat – Ifmap operand matrix
filter_op_mat – Filter operand matrix
ofmap_op_mat – Ofmap operand matrix
- Returns:
None
scalesim.compute.systolic_compute_os module
- scalesim.compute.systolic_compute_os.skew_matrix(input_matrix_np)[source]
Method to add skew to the input matix to maintain systolic array flow. .. rubric:: Example
Input matrix 1 1 1 1 1 1 1 1 1
- Output matrix
1 1 1
1 1 1
1 1 1
- Parameters:
input_matrix_np – input matrix to be skewed
- Returns:
None
- class scalesim.compute.systolic_compute_os.systolic_compute_os[source]
Bases:
objectClass which runs the compute simulation in output stationary dataflow
- create_demand_matrices()[source]
Method to create ifmap, filter and ofmap demand matrices from the operand matrices. They contain several folds of ifmap, filter and ofmap demands. The folding happens because operand matrices are generally larger than systolic array dimensions.
- Returns:
None
- create_prefetch_matrices()[source]
Method to create ifmap and filter prefetch matrices. These matrices are prefetched in the SRAM before running memory simulation.
- Returns:
None
- get_avg_compute_utilization()[source]
Method to get average compute utilization on the systolic array.
- Returns:
Average compute utilization
- get_avg_mapping_efficiency()[source]
Method to get average mapping efficincy on the systolic array.
- Returns:
Average mapping efficincy
- get_demand_matrices()[source]
Method to get ifmap, filter and ofmap demand matrices.
- Returns:
Ifmap, filter and ofmap demand matrices
- get_filter_prefetch_mat()[source]
Method to get filter prefetch matrix.
- Returns:
Filter prefetch matrix
- get_filter_requests()[source]
Method to get filter read requests.
- Returns:
Number of filter read requests
- get_ifmap_prefetch_mat()[source]
Method to get ifmap prefetch matrix.
- Returns:
Ifmap prefetch matrix
- get_ifmap_requests()[source]
Method to get ifmap read requests.
- Returns:
Number of ifmap read requests
- get_ofmap_requests()[source]
Method to get ofmap write requests.
- Returns:
Number of ofmap write requests
- get_prefetch_matrices()[source]
Method to get ifmap and filter prefetch matrices.
- Returns:
Ifmap and filter prefetch matrices
- set_params(config_obj=<scalesim.scale_config.scale_config object>, ifmap_op_mat=array([[0.]]), ofmap_op_mat=array([[0.]]), filter_op_mat=array([[0.]]))[source]
Method to set the output stationary run parameters for housekeeping.
- Parameters:
config_obj – Object of scalesim.scale_config which is used to lookup the architecture and run parameters set by the user
ifmap_op_mat – Ifmap operand matrix
filter_op_mat – Filter operand matrix
ofmap_op_mat – Ofmap operand matrix
- Returns:
None
scalesim.compute.systolic_compute_ws module
- scalesim.compute.systolic_compute_ws.skew_matrix(input_matrix_np)[source]
Method to add skew to the input matix to maintain systolic array flow. .. rubric:: Example
Input matrix 1 1 1 1 1 1 1 1 1
- Output matrix
1 1 1
1 1 1
1 1 1
- Parameters:
input_matrix_np – input matrix to be skewed
- Returns:
None
- class scalesim.compute.systolic_compute_ws.systolic_compute_ws[source]
Bases:
objectClass which runs the compute simulation in weight stationary dataflow
- create_demand_matrices()[source]
Method to create ifmap, filter and ofmap demand matrices from the operand matrices. They contain several folds of ifmap, filter and ofmap demands. The folding happens because operand matrices are generally larger than systolic array dimensions.
- Returns:
None
- create_prefetch_matrices()[source]
Method to create ifmap and filter prefetch matrices. These matrices are prefetched in the SRAM before running memory simulation.
- Returns:
None
- get_avg_compute_utilization()[source]
Method to get average compute utilization on the systolic array.
- Returns:
Average compute utilization
- get_avg_mapping_efficiency()[source]
Method to get average mapping efficincy on the systolic array.
- Returns:
Average mapping efficincy
- get_demand_matrices()[source]
Method to get ifmap, filter and ofmap demand matrices.
- Returns:
Ifmap, filter and ofmap demand matrices
- get_filter_prefetch_mat()[source]
Method to get filter prefetch matrix.
- Returns:
Filter prefetch matrix
- get_filter_requests()[source]
Method to get filter read requests.
- Returns:
Number of filter read requests
- get_ifmap_prefetch_mat()[source]
Method to get ifmap prefetch matrix.
- Returns:
Ifmap prefetch matrix
- get_ifmap_requests()[source]
Method to get ifmap read requests.
- Returns:
Number of ifmap read requests
- get_ofmap_requests()[source]
Method to get ofmap write requests.
- Returns:
Number of ofmap write requests
- get_prefetch_matrices()[source]
Method to get ifmap and filter prefetch matrices.
- Returns:
Ifmap and filter prefetch matrices
- set_params(config_obj=<scalesim.scale_config.scale_config object>, ifmap_op_mat=array([[0.]]), ofmap_op_mat=array([[0.]]), filter_op_mat=array([[0.]]))[source]
Method to set the weight stationary run parameters for housekeeping.
- Parameters:
config_obj – Object of scalesim.scale_config which is used to lookup the architecture and run parameters set by the user
ifmap_op_mat – Ifmap operand matrix
filter_op_mat – Filter operand matrix
ofmap_op_mat – Ofmap operand matrix
- Returns:
None