# TPU-Kernel Samples
## 1. Introduction
TPU-Kernel Development Kit provides an easy way to program on TPU directly.
Developers can write their codes on device(TPU) and host with C/CPP languages.
The device codes will be compiled with the base firmware lib into a full firmware that can be loaded by driver.
When the full firmware is loaded, The host codes can call the communication interface to pass the customed protocol parameters to device, and run the functions customized.
TPU-Kernel will be used to fulfill the following cases:
* Some high-performance senario, such as pre-process, post-processing
* Implement some customed algorithm to do computationally intensive tasks
* Research on BM1684X architecture and Instruction Sets
Here is the main content introduction in TPU-Kernel Development Kit
``` shell
├── README.md # the current file
├── doc
│ └── TPU-KERNEL开发参考手册.pdf
├── scripts
│ ├── envsetup.sh # set up the environment, including downloading toolchains and set up env
│ └── ...
├── include
│ ├── tpu_defs.h # some common definitions, can be used for both host and device codes
│ ├── tpu_fp16.h # fp16 definitions
│ ├── common.h # some type definitions
│ ├── device/tpu_kernel.h # device operators interface, ONLY allowed used in device codes
│ └── ...
├── lib
│ ├── libbm1684x.a # the base firmware lib for device codes to be linked to
│ └── ...
├── samples # some samples to demonstrate how to develop
│ ├── README.md # usage for compiling and using the codes
│ ├── host # codes running on the host
│ ├── device # codes running on the device(TPU)
│ ├── include # the protocol parameters for host and device communication
│ └── ...
└── firmware
└── bm1684x.bin_v<VERSION>-<COMMIT>-<DATA> # original firmware to restore the device system
```
## 2. Environment Set Up
TPU-Kernel Development Kit depends on libsophon and cross toolchains
### Install libsophon-dev and driver
The following deb package should be downloaded from sophgo website first:
* sophon-libsophon_*.deb
* sophon-libsophon-dev_*.deb
* sophon-driver_*.deb
and install:
``` shell
sudo dpkg -i sophon-driver*.deb
sudo dpkg -i sophon-libsophon*.deb
```
### Install cross toolchains
The following cross compilers will be used for TPU-Kernel development
* [gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu](https://releases.linaro.org/components/toolchain/binaries/6.3-2017.05/aarch64-linux-gnu/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu.tar.xz)
* [gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf](https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz)
We provide an easy way to download and initialize:
``` shell
source scripts/envsetup.sh
# the scripts do the following things:
# 1. Check existance of toolchains_dir
# 2. If needed, download the cross toolchains into 'toolchains_dir'
# 3. Set CROSS_TOOLCHAINS environment variable.
# 4. Set TPU-Kernel base dir to TPUKERNEL_TOP for writing build scripts or other use
```
If you have cross toolchains already, just run the following commands to avoid downloading toolchains from Internet
``` shell
export CROSS_TOOLCHAINS=path/to/your/toolchains
source scripts/envsetup.sh
```
## 3. More
* Directory 'samples' contains some typical operators including GEMM, TopK and some CV ops, guiding developers to learn how to programming on TPU, how to map algorithm on TPU properly, and so on.
* Directory 'doc' provides the programming reference which reveal many TPU details and interfaces can be used.
没有合适的资源?快使用搜索试试~ 我知道了~
1684-tpu-kernel相关
需积分: 5 0 下载量 101 浏览量
2024-04-12
14:29:11
上传
评论
收藏 1.46MB GZ 举报
温馨提示
共19个文件
sh:4个
7-e74df266-230710:4个
lds:3个
1684-tpu-kernel相关
资源推荐
资源详情
资源评论
收起资源包目录
tpu-kernel-1684_v3.1.7-e74df266-230710.tar.gz (19个子文件)
tpu-kernel-1684_v3.1.7-e74df266-230710
include
device
lib
doc
samples
test_instruction_perf.cpp 7KB
README.md 783B
firmware
bm1684_tcm_icache.bin_v3.1.7-e74df266-230710 431KB
bm1684_ddr_icache.bin_v3.1.7-e74df266-230710 1.07MB
bm1684_tcm.bin_v3.1.7-e74df266-230710 431KB
bm1684_ddr.bin_v3.1.7-e74df266-230710 1.07MB
libbm1684.a 63KB
README.md 4KB
scripts
build_firmware.sh 848B
bm168x_tcm.lds 2KB
firmware_pack.py 2KB
Makefile.device 2KB
prepare_toolchains.sh 606B
load_firmware.py 2KB
envsetup.sh 1KB
bm168x_ddr.lds 5KB
firmware_info.py 3KB
bm168x_standalone_ddr.lds 2KB
version_info.sh 220B
共 19 条
- 1
资源评论
滴答滴答滴嗒滴
- 粉丝: 568
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功