File: fp16_help.py

package info (click to toggle)
theano 1.0.3+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 30,752 kB
  • sloc: python: 141,182; ansic: 9,505; makefile: 259; sh: 214; pascal: 81
file content (42 lines) | stat: -rw-r--r-- 755 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from __future__ import absolute_import, print_function, division


def work_dtype(dtype):
    """
    Return the data type for working memory.

    """
    if dtype == 'float16':
        return 'float32'
    else:
        return dtype


def load_w(dtype):
    """
    Return the function name to load data.

    This should be used like this::

        code = '%s(ival)' % (load_w(input_type),)

    """
    if dtype == 'float16':
        return 'ga_half2float'
    else:
        return ''


def write_w(dtype):
    """
    Return the function name to write data.

    This should be used like this::

        code = 'res = %s(oval)' % (write_w(output_type),)

    """
    if dtype == 'float16':
        return 'ga_float2half'
    else:
        return ''