Matrix-Matrix Multiplication
Description
This sample implements matrix-matrix multiplication: C = αAB + βC, where A, B, and C are 16 x 16 matrices, meaning that m = 16, n = 16, and k = 16. The result is also a 16 x 16 matrix.
Figure 1 Sample diagram
Principles
The following table lists the key functions involved in this sample.
|
Initialization |
|
|---|---|
|
Device Management |
|
|
Stream Management |
|
|
Memory Management |
|
|
Data Transfer |
aclrtMemcpy (used when the app runs on the host):
Data transfer is not required if your app runs in the board environment. |
|
Single-Operator Execution |
|
Directory Structure
The sample directory is organized as follows:
├── inc
│ ├── common.h //Header file that declares common functions (such as the file reading function)
│ ├── gemm_runner.h //Header file that declares the functions related to matrix multiplication
├── run
│ ├── out
│ │ ├──test_data
│ │ │ ├── config
│ │ │ │ ├── acl.json //Configuration file for system initialization
│ │ │ │ ├── gemm.json //Description information file of the matrix multiplication operator
│ │ │ ├── data
│ │ │ │ ├── generate_data.py //Script for generating the data of matrix A and matrix B
├── src
│ ├── CMakeLists.txt //Build script
│ ├── common.cpp //Implementation file of common functions (such as the file reading function)
│ ├── gemm_main.cpp //Implementation file of the main function
│ ├── gemm_runner.cpp //Implementation file for executing functions related to matrix multiplication
Parent topic: App Samples