Skip to content

Commit 11fadda

Browse files
committed
Add TF_Library class
Move `GetAllOpList()` method there. Fixes <#8>.
1 parent 9dfa831 commit 11fadda

File tree

7 files changed

+66
-45
lines changed

7 files changed

+66
-45
lines changed

Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- Add `::TFLibrary` class. Move `GetAllOpList()` method there.
12
0.0.3 2022-12-15 10:46:52-0500
23

34
- Features

README.pod

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,6 @@ Version number for the C<libtensorflow> library.
3434

3535
B<C API>: L<< C<TF_Version>|AI::TensorFlow::Libtensorflow::Manual::CAPI/TF_Version >>
3636

37-
=head2 GetAllOpList
38-
39-
=over 2
40-
41-
C<<<
42-
GetAllOpList()
43-
>>>
44-
45-
=back
46-
47-
my $buf = Libtensorflow->GetAllOpList();
48-
cmp_ok $buf->length, '>', 0, 'Got OpList buffer';
49-
50-
B<Returns>
51-
52-
=over 4
53-
54-
=item L<TFBuffer|AI::TensorFlow::Libtensorflow::Lib::Types/TFBuffer>
55-
56-
Contains a serialized C<OpList> proto for ops registered in this address space.
57-
58-
=back
59-
60-
B<C API>: L<< C<TF_GetAllOpList>|AI::TensorFlow::Libtensorflow::Manual::CAPI/TF_GetAllOpList >>
61-
6237
=head1 AUTHOR
6338

6439
Zakariyya Mughal <[email protected]>

lib/AI/TensorFlow/Libtensorflow.pm

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use AI::TensorFlow::Libtensorflow::Output;
1818
use AI::TensorFlow::Libtensorflow::Input;
1919

2020
use AI::TensorFlow::Libtensorflow::ApiDefMap;
21+
use AI::TensorFlow::Libtensorflow::TFLibrary;
2122

2223
use AI::TensorFlow::Libtensorflow::ImportGraphDefOptions;
2324
use AI::TensorFlow::Libtensorflow::ImportGraphDefResults;
@@ -55,23 +56,6 @@ Version number for the C<libtensorflow> library.
5556
=cut
5657
$ffi->attach( 'Version' => [], 'string' );#}}}
5758

58-
=classmethod GetAllOpList
59-
60-
=for :signature
61-
GetAllOpList()
62-
63-
my $buf = Libtensorflow->GetAllOpList();
64-
cmp_ok $buf->length, '>', 0, 'Got OpList buffer';
65-
66-
=for :returns
67-
= TFBuffer
68-
Contains a serialized C<OpList> proto for ops registered in this address space.
69-
70-
=tf_capi TF_GetAllOpList
71-
72-
=cut
73-
$ffi->attach( 'GetAllOpList' => [], 'TF_Buffer' );
74-
7559
1;
7660

7761
=head1 SYNOPSIS

lib/AI/TensorFlow/Libtensorflow/ApiDefMap.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $ffi->mangler(AI::TensorFlow::Libtensorflow::Lib->mangler_default);
1515
use AI::TensorFlow::Libtensorflow::Status;
1616
1717
my $map = ApiDefMap->New(
18-
AI::TensorFlow::Libtensorflow->GetAllOpList,
18+
AI::TensorFlow::Libtensorflow::TFLibrary->GetAllOpList,
1919
my $status = AI::TensorFlow::Libtensorflow::Status->New
2020
);
2121
ok $map, 'Created ApiDefMap';

lib/AI/TensorFlow/Libtensorflow/Lib.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,15 @@ typedef struct TF_DeviceList TF_DeviceList;
173173

174174
=head3 TF_Library
175175
176+
L<AI::TensorFlow::Libtensorflow::TFLibrary>
177+
176178
=begin TF_CAPI_DEF
177179
178180
typedef struct TF_Library TF_Library;
179181
180182
=end TF_CAPI_DEF
181183
=cut
182-
$ffi->type('opaque' => 'TF_Library');
184+
$ffi->type('object(AI::TensorFlow::Libtensorflow::TFLibrary)' => 'TF_Library');
183185

184186
=head3 TF_ApiDefMap
185187
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package AI::TensorFlow::Libtensorflow::TFLibrary;
2+
# ABSTRACT: TensorFlow dynamic library handle and ops
3+
4+
use strict;
5+
use warnings;
6+
7+
use AI::TensorFlow::Libtensorflow::Lib qw(arg);
8+
my $ffi = AI::TensorFlow::Libtensorflow::Lib->ffi;
9+
10+
=construct LoadLibrary
11+
12+
=tf_capi TF_LoadLibrary
13+
14+
=cut
15+
$ffi->attach( [ 'LoadLibrary' => 'LoadLibrary' ] => [
16+
arg string => 'library_filename',
17+
arg TF_Status => 'status',
18+
] => 'TF_Library' => sub {
19+
my ($xs, $class, @rest) = @_;
20+
$xs->(@rest);
21+
} );
22+
23+
=method GetOpList
24+
25+
=tf_capi TF_GetOpList
26+
27+
=cut
28+
$ffi->attach( [ 'GetOpList' => 'GetOpList' ] => [
29+
arg TF_Library => 'lib_handle'
30+
] => 'TF_Buffer' );
31+
32+
=destruct DESTROY
33+
34+
=tf_capi TF_DeleteLibraryHandle
35+
36+
=cut
37+
$ffi->attach( [ 'DeleteLibraryHandle' => 'DESTROY' ] => [
38+
arg TF_Library => 'lib_handle'
39+
] => 'void' );
40+
41+
=classmethod GetAllOpList
42+
43+
=for :signature
44+
GetAllOpList()
45+
46+
my $buf = AI::TensorFlow::Libtensorflow::TFLibrary->GetAllOpList();
47+
cmp_ok $buf->length, '>', 0, 'Got OpList buffer';
48+
49+
=for :returns
50+
= TFBuffer
51+
Contains a serialized C<OpList> proto for ops registered in this address space.
52+
53+
=tf_capi TF_GetAllOpList
54+
55+
=cut
56+
$ffi->attach( 'GetAllOpList' => [], 'TF_Buffer' );
57+
58+
59+
1;

t/upstream/CAPI/013_GetAllOpList.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use TF_TestQuiet;
66
use aliased 'AI::TensorFlow::Libtensorflow';
77

88
subtest "(CAPI, GetAllOpList)" => sub {
9-
my $buf = Libtensorflow->GetAllOpList();
9+
my $buf = AI::TensorFlow::Libtensorflow::TFLibrary->GetAllOpList();
1010
ok $buf;
1111
};
1212

0 commit comments

Comments
 (0)