NAME

AI::TensorFlow::Libtensorflow::DataType - Datatype enum

SYNOPSIS

use AI::TensorFlow::Libtensorflow::DataType qw(FLOAT @DTYPES);
use List::Util qw(max);

my $dtype = FLOAT;
is FLOAT->Size, 4, 'FLOAT is 4 bytes large';
is max(map { $_->Size } @DTYPES), 16,
  'Largest type has sizeof() == 16 bytes';

DESCRIPTION

Enum representing native data types used inside of containers such as TFTensor.

CONSTANTS

STRING

String.

BOOL

Boolean.

HALF

16-bit half-precision floating-point (float16).

FLOAT

32-bit single-precision floating-point (float32).

DOUBLE

64-bit double-precision floating-point (float64).

BFLOAT16

16-bit truncated floating-point.

COMPLEX64

32-bit single-precision complex floating-point.

COMPLEX128

64-bit double-precision complex floating-point.

INT8

8-bit signed integer.

INT16

16-bit signed integer.

INT32

32-bit signed integer.

INT64

64-bit signed integer.

UINT8

8-bit unsigned integer.

UINT16

16-bit unsigned integer.

UINT32

32-bit unsigned integer.

UINT64

64-bit unsigned integer.

QINT8

8-bit quantized signed integer.

QINT16

16-bit quantized signed integer.

QINT32

32-bit quantized signed integer.

QUINT8

8-bit quantized unsigned integer.

QUINT16

16-bit quantized unsigned integer.

RESOURCE

Handle to a mutable resource.

VARIANT

Variant.

METHODS

Size

my $size = $dtype->Size();

Returns

size_t

The number of bytes used for the DataType $dtype. Returns 0 for variable length types such as STRING or for invalid types.

C API: TF_DataTypeSize

OPERATORS

==

Numeric equality of the underlying enum integer value.

use AI::TensorFlow::Libtensorflow::DataType qw(FLOAT);
cmp_ok FLOAT, '==', FLOAT, 'Compare FLOAT objects numerically';
cmp_ok FLOAT, '==', 1    , 'FLOAT enumeration is internally 1';

eq

Compare string equality against type name.

use AI::TensorFlow::Libtensorflow::DataType qw(FLOAT);
cmp_ok FLOAT, 'eq', 'FLOAT', 'Compare FLOAT object to string';

""

Stringification to the name of the enumerated type name (e.g., FLOAT, DOUBLE).

use AI::TensorFlow::Libtensorflow::DataType qw(DOUBLE);
is "@{[ DOUBLE ]}", 'DOUBLE', 'Stringifies';

AUTHOR

Zakariyya Mughal <zmughal@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2022-2023 by Auto-Parallel Technologies, Inc.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004