AI-TensorFlow-Libtensorflow
view release on metacpan or search on metacpan
lib/AI/TensorFlow/Libtensorflow/Buffer.pm view on Meta::CPAN
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Buffer - Buffer that holds pointer to data with length
=head1 SYNOPSIS
use aliased 'AI::TensorFlow::Libtensorflow::Buffer' => 'Buffer';
=head1 DESCRIPTION
C<TFBuffer> is a data structure that stores a pointer to a block of data, the
length of the data, and optionally a deallocator function for memory
management.
This structure is typically used in C<libtensorflow> to store the data for a
serialized protocol buffer.
=head1 CONSTRUCTORS
=head2 New
=over 2
C<<<
New()
>>>
=back
my $buffer = Buffer->New();
ok $buffer, 'created an empty buffer';
is $buffer->length, 0, 'with a length of 0';
Create an empty buffer. Useful for passing as an output parameter.
B<Returns>
=over 4
=item L<TFBuffer|AI::TensorFlow::Libtensorflow::Lib::Types/TFBuffer>
Empty buffer.
=back
B<C API>: L<< C<TF_NewBuffer>|AI::TensorFlow::Libtensorflow::Manual::CAPI/TF_NewBuffer >>
=head2 NewFromString
=over 2
C<<<
NewFromString( $proto )
>>>
=back
Makes a copy of the input and sets an appropriate deallocator. Useful for
passing in read-only, input protobufs.
my $data = 'bytes';
my $buffer = Buffer->NewFromString(\$data);
ok $buffer, 'create buffer from string';
is $buffer->length, bytes::length($data), 'same length as string';
B<Parameters>
=over 4
=item ScalarRef[Bytes] $proto
=back
B<Returns>
=over 4
=item L<TFBuffer|AI::TensorFlow::Libtensorflow::Lib::Types/TFBuffer>
Contains a copy of the input data from C<$proto>.
=back
B<C API>: L<< C<TF_NewBufferFromString>|AI::TensorFlow::Libtensorflow::Manual::CAPI/TF_NewBufferFromString >>
=head1 ATTRIBUTES
=head2 data
An C<opaque> pointer to the buffer.
=head2 length
Length of the buffer as a C<size_t>.
=head2 data_deallocator
A C<CodeRef> for the deallocator.
=head1 DESTRUCTORS
=head2 DESTROY
B<C API>: L<< C<TF_DeleteBuffer>|AI::TensorFlow::Libtensorflow::Manual::CAPI/TF_DeleteBuffer >>
=head1 AUTHOR
Zakariyya Mughal <zmughal@cpan.org>
=head1 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
=cut
( run in 1.585 second using v1.01-cache-2.11-cpan-5b529ec07f3 )