LoginSignup
4
0

More than 3 years have passed since last update.

2020年の浮動小数点数

Last updated at Posted at 2020-06-30

はじめに

2020年5月半ばに発表されたNVIDIAのAmpereアーキテクチャの記事を眺めているとBF16とかTF32とか聞きなれない用語が出てくるのでざっと調べてみた。

浮動小数点数

簡単には計算機上において符号+指数部+仮数部で数値を表す形式。
多くの言語の型にfloatとあるのはFloating Point Numberから。FP16,FP32なんて型のFPもFloating Pointの略。

IEEE754

まずは広く使われている浮動小数点数の整理から。
IEEE754、正式にはIEEE Standard for Floating-Point Arithmetic (ANSI/IEEE Std 754-2008)として規格されている浮動小数点数のうちいくつかを下記表に挙げる。

IEEE754名 一般名 指数部 仮数部 合計
binary16 半精度(half,FP16) 5 bits 10 bits 16 bits
binary32 単精度(single,FP32) 8 bits 23 bits 32 bits
binary64 倍精度(double,FP64) 11 bits 52 bits 64 bits

FP16はNVIDIA Pascalアーキテクチャからサポートされる。
IntelのCPUもIvy BridgeからFP32との変換命令セット(F16C)をサポートする。

BF16

名称 指数部 仮数部 合計
bfloat16(BF16) 8 bits 7 bits 16 bits

FP32と同じ8bitsの指数部により、-256〜256の範囲の整数を正しく表現できる。それによりINT8から変換しても精度を失わない。
GoogleのTPUでも採用されている様子。

TF32

名称 指数部 仮数部 合計
Tensor Float 32(TF32) 8 bits 10 bits 19 bits

FP32,BF16と同じ8bitsの指数部、半精度と同じ10bitsの仮数部を持つ。
合計19bitsは内部処理で用いられ、入出力は32bitsになるからTF32という名称らしい。

おわりに

Tesla A100いじってみたい。

参考

免責

記事の内容は個人の見解であり、所属組織を代表するものではありません。

4
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0