AI-TensorFlow-Libtensorflow

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

maint/inc/PreloadPodWeaver.pm
maint/process-capi.pl
maint/process-notebook.pl
perlcritic.rc
t/01_hello_tf.t
t/02_load_graph.t
t/03_create_tftensor.t
t/04_allocate_tftensor.t
t/05_session_run.t
t/AI/TensorFlow/Libtensorflow.t
t/lib/TF_TestQuiet.pm
t/lib/TF_Utils.pm
t/models/README
t/models/graph.pb
t/upstream/CAPI/001_Version.t
t/upstream/CAPI/002_Status.t
t/upstream/CAPI/003_Tensor.t
t/upstream/CAPI/004_MalformedTensor.t
t/upstream/CAPI/005_AllocateTensor.t
t/upstream/CAPI/006_MaybeMove.t
t/upstream/CAPI/007_LibraryLoadFunctions.t

MANIFEST  view on Meta::CPAN

t/upstream/CAPI/022_Session_Min_CPU.t
t/upstream/CAPI/023_Session_Min_XLA_CPU.t
t/upstream/CAPI/024_Session_Min_GPU.t
t/upstream/CAPI/025_Session_Min_XLA_GPU.t
t/upstream/CAPI/026_SessionPRun.t
t/upstream/CAPI/027_ShapeInferenceError.t
t/upstream/CAPI/028_GetOpDef.t
t/upstream/CAPI/029_SavedModel.t
t/upstream/CAPI/030_SavedModelNullArgsAreValid.t
t/upstream/CAPI/031_DeletingNullPointerIsSafe.t
t/upstream/CAPI/032_TestBitcastFrom_Reshape.t
t/upstream/CAPI/033_TestFromProto.t
t/upstream/CAPI/034_TestTensorAligned.t
t/upstream/CAPI/035_TestTensorIsNotAligned.t
t/upstream/CAPI/036_MessageBufferConversion.t
t/upstream/CAPI/037_TestTensorNonScalarBytesAllocateDelete.t
t/upstream/CAPI/TEMPLATE
t/upstream/tensorflow/cc/saved_model/testdata/half_plus_two/00000123/assets/foo.txt
t/upstream/tensorflow/cc/saved_model/testdata/half_plus_two/00000123/saved_model.pb
t/upstream/tensorflow/cc/saved_model/testdata/half_plus_two/00000123/variables/variables.data-00000-of-00001
t/upstream/tensorflow/cc/saved_model/testdata/half_plus_two/00000123/variables/variables.index
weaver.ini
xt/author/critic.t
xt/author/pod-linkcheck.t
xt/author/pod-snippets.t

META.json  view on Meta::CPAN

         "requires" : {
            "ExtUtils::MakeMaker" : "0",
            "perl" : "5.014"
         }
      },
      "develop" : {
         "requires" : {
            "Moose" : "0",
            "Moose::Role" : "0",
            "Pod::Simple::Search" : "0",
            "Test::More" : "0.88",
            "Test::Perl::Critic" : "0",
            "Test::Pod::LinkCheck::Lite" : "0",
            "Test::Pod::Snippets" : "0",
            "Test::Pod::Snippets::Parser" : "0",
            "With::Roles" : "0"
         },
         "suggests" : {
            "CLI::Osprey" : "0",
            "Data::Printer" : "0",
            "File::Find::Rule" : "0",
            "Function::Parameters" : "0",
            "Hook::LexWrap" : "0",
            "List::SomeUtils" : "0",
            "Module::Runtime" : "0",

META.json  view on Meta::CPAN

            "Data::Printer" : "0",
            "PDL" : "0"
         }
      },
      "test" : {
         "requires" : {
            "Data::Dumper" : "0",
            "PDL" : "0",
            "PDL::Core" : "0",
            "Path::Tiny" : "0",
            "Test2::V0" : "0",
            "Test::More" : "0",
            "aliased" : "0",
            "lib" : "0",
            "perl" : "5.014"
         }
      }
   },
   "release_status" : "stable",
   "resources" : {
      "homepage" : "https://github.com/EntropyOrg/perl-AI-TensorFlow-Libtensorflow",
      "repository" : {

META.yml  view on Meta::CPAN

---
abstract: 'Bindings for Libtensorflow deep learning library'
author:
  - 'Zakariyya Mughal <zmughal@cpan.org>'
build_requires:
  Data::Dumper: '0'
  PDL: '0'
  PDL::Core: '0'
  Path::Tiny: '0'
  Test2::V0: '0'
  Test::More: '0'
  aliased: '0'
  lib: '0'
  perl: '5.014'
configure_requires:
  ExtUtils::MakeMaker: '0'
  perl: '5.014'
dynamic_config: 0
generated_by: 'Dist::Zilla version 6.030, CPAN::Meta::Converter version 2.150010'
license: apache
meta-spec:

Makefile.PL  view on Meta::CPAN

    "namespace::autoclean" => 0,
    "overload" => 0,
    "strict" => 0,
    "warnings" => 0
  },
  "TEST_REQUIRES" => {
    "Data::Dumper" => 0,
    "PDL" => 0,
    "PDL::Core" => 0,
    "Path::Tiny" => 0,
    "Test2::V0" => 0,
    "Test::More" => 0,
    "aliased" => 0,
    "lib" => 0
  },
  "VERSION" => "0.0.7",
  "test" => {
    "TESTS" => "t/*.t t/AI/TensorFlow/*.t t/upstream/CAPI/*.t"
  }
);


Makefile.PL  view on Meta::CPAN

  "FFI::Platypus::Type::PtrObject" => 0,
  "Feature::Compat::Defer" => 0,
  "List::Util" => 0,
  "Module::Runtime" => 0,
  "PDL" => 0,
  "PDL::Core" => 0,
  "Package::Variant" => 0,
  "Path::Tiny" => 0,
  "Sub::Delete" => 0,
  "Sub::Quote" => 0,
  "Test2::V0" => 0,
  "Test::More" => 0,
  "Type::Library" => "0.008",
  "Type::Utils" => 0,
  "Types::Common" => 0,
  "Types::Standard" => 0,
  "aliased" => 0,
  "base" => 0,
  "constant" => 0,
  "feature" => 0,
  "lib" => 0,
  "namespace::autoclean" => 0,

dist.ini  view on Meta::CPAN

-remove = License
GatherDir.exclude_filename = EMPLOYERS.pdf
;; Jupyter Notebook
GatherDir.exclude_match[0]   = ^notebook/.*
GatherDir.exclude_match[1]   = ^notebook/.*\.ipynb
GatherDir.exclude_match[2]   = ^notebook/.ipynb_checkpoints
GatherDir.exclude_match[3]   = ^docker/
; [PodWeaver]
; authordep Pod::Elemental::Transformer::List
; authordep Pod::Weaver::Section::AllowOverride
[RunExtraTests]
;; For xt/author/pod-linkcheck.t
; authordep Test::Pod::LinkCheck::Lite
;; For xt/author/pod-snippets.t
; authordep Test::Pod::Snippets
; authordep Pod::Simple::Search
; authordep With::Roles

[Test::Perl::Critic]
; authordep Perl::Critic::Community

[Prereqs / RuntimeRequires]
; Needs Perl v5.14 for Feature::Compat::Defer
perl = 5.014
FFI::Platypus = 2.00
FFI::C = 0.12
FFI::CheckLib = 0
FFI::Platypus::Type::Enum = 0
FFI::Platypus::Type::PtrObject = 0

lib/AI/TensorFlow/Libtensorflow/Manual/Notebook/InferenceUsingTFHubEnformerGeneExprPredModel.pod  view on Meta::CPAN


    my $encoded  = $encoder->index( $p->dummy(0) );

    return $encoded;
}

####

{

say "Testing one-hot encoding:\n";

my $onehot_test_seq = "ACGTNtgcan";
my $test_encoded = one_hot_dna( $onehot_test_seq );
$SHOW_ENCODER = 0;

say "One-hot encoding of sequence '$onehot_test_seq' is:";
say $test_encoded->info, $test_encoded;

}

lib/AI/TensorFlow/Libtensorflow/Manual/Notebook/InferenceUsingTFHubEnformerGeneExprPredModel.pod  view on Meta::CPAN


    use overload '""' => \&_op_stringify;

    sub _op_stringify { sprintf "%s:%s", $_[0]->seq_id // "(no sequence)", $_[0]->to_FTstring }
}

#####

{

say "Testing interval resizing:\n";
sub _debug_resize {
    my ($interval, $to, $msg) = @_;

    my $resized_interval = $interval->resize($to);

    die "Wrong interval size for $interval --($to)--> $resized_interval"
        unless $resized_interval->length == $to;

    say sprintf "Interval: %s -> %s, length %2d : %s",
        $interval,
        $resized_interval, $resized_interval->length,
        $msg;
}

for my $interval_spec ( [4, 8], [5, 8], [5, 9], [6, 9]) {
    my ($start, $end) = @$interval_spec;
    my $test_interval = Interval->new( -seq_id => 'chr11', -start => $start, -end => $end );
    say sprintf "Testing interval %s with length %d", $test_interval, $test_interval->length;
    say "-----";
    for(0..5) {
        my $base = $test_interval->length;
        my $to = $base + $_;
        _debug_resize $test_interval, $to, "$base -> $to (+ $_)";
    }
    say "";
}

}

lib/AI/TensorFlow/Libtensorflow/Manual/Notebook/InferenceUsingTFHubEnformerGeneExprPredModel.pod  view on Meta::CPAN

        sprintf "%s...%s (length %d)", uc substr($seq, 0, $n), uc substr($seq, -$n), length $seq;
    } else {
        sprintf "%s (length %d)", uc $seq, length $seq;
    }
}

####

{

say "Testing sequence extraction:";

say "1 base: ",   seq_info
    extract_sequence( $hg_db,
        Interval->new( -seq_id => 'chr11',
            -start => 35_082_742 + 1,
            -end   => 35_082_742 + 1 ) );

say "3 bases: ",  seq_info
    extract_sequence( $hg_db,
        Interval->new( -seq_id => 'chr11',

lib/AI/TensorFlow/Libtensorflow/Manual/Notebook/InferenceUsingTFHubEnformerGeneExprPredModel.pod  view on Meta::CPAN

  
      my $encoded  = $encoder->index( $p->dummy(0) );
  
      return $encoded;
  }
  
  ####
  
  {
  
  say "Testing one-hot encoding:\n";
  
  my $onehot_test_seq = "ACGTNtgcan";
  my $test_encoded = one_hot_dna( $onehot_test_seq );
  $SHOW_ENCODER = 0;
  
  say "One-hot encoding of sequence '$onehot_test_seq' is:";
  say $test_encoded->info, $test_encoded;
  
  }

B<STREAM (STDOUT)>:

  Testing one-hot encoding:
  
  Encoder is
  PDL: Float D [5,4]
  [
   [0 1 0 0 0]
   [0 0 1 0 0]
   [0 0 0 1 0]
   [0 0 0 0 1]
  ]
  

lib/AI/TensorFlow/Libtensorflow/Manual/Notebook/InferenceUsingTFHubEnformerGeneExprPredModel.pod  view on Meta::CPAN

  
      use overload '""' => \&_op_stringify;
  
      sub _op_stringify { sprintf "%s:%s", $_[0]->seq_id // "(no sequence)", $_[0]->to_FTstring }
  }
  
  #####
  
  {
  
  say "Testing interval resizing:\n";
  sub _debug_resize {
      my ($interval, $to, $msg) = @_;
  
      my $resized_interval = $interval->resize($to);
  
      die "Wrong interval size for $interval --($to)--> $resized_interval"
          unless $resized_interval->length == $to;
  
      say sprintf "Interval: %s -> %s, length %2d : %s",
          $interval,
          $resized_interval, $resized_interval->length,
          $msg;
  }
  
  for my $interval_spec ( [4, 8], [5, 8], [5, 9], [6, 9]) {
      my ($start, $end) = @$interval_spec;
      my $test_interval = Interval->new( -seq_id => 'chr11', -start => $start, -end => $end );
      say sprintf "Testing interval %s with length %d", $test_interval, $test_interval->length;
      say "-----";
      for(0..5) {
          my $base = $test_interval->length;
          my $to = $base + $_;
          _debug_resize $test_interval, $to, "$base -> $to (+ $_)";
      }
      say "";
  }
  
  }
  
  undef;

B<STREAM (STDOUT)>:

  Testing interval resizing:
  
  Testing interval chr11:4..8 with length 5
  -----
  Interval: chr11:4..8 -> chr11:4..8, length  5 : 5 -> 5 (+ 0)
  Interval: chr11:4..8 -> chr11:3..8, length  6 : 5 -> 6 (+ 1)
  Interval: chr11:4..8 -> chr11:3..9, length  7 : 5 -> 7 (+ 2)
  Interval: chr11:4..8 -> chr11:2..9, length  8 : 5 -> 8 (+ 3)
  Interval: chr11:4..8 -> chr11:2..10, length  9 : 5 -> 9 (+ 4)
  Interval: chr11:4..8 -> chr11:1..10, length 10 : 5 -> 10 (+ 5)
  
  Testing interval chr11:5..8 with length 4
  -----
  Interval: chr11:5..8 -> chr11:5..8, length  4 : 4 -> 4 (+ 0)
  Interval: chr11:5..8 -> chr11:5..9, length  5 : 4 -> 5 (+ 1)
  Interval: chr11:5..8 -> chr11:4..9, length  6 : 4 -> 6 (+ 2)
  Interval: chr11:5..8 -> chr11:4..10, length  7 : 4 -> 7 (+ 3)
  Interval: chr11:5..8 -> chr11:3..10, length  8 : 4 -> 8 (+ 4)
  Interval: chr11:5..8 -> chr11:3..11, length  9 : 4 -> 9 (+ 5)
  
  Testing interval chr11:5..9 with length 5
  -----
  Interval: chr11:5..9 -> chr11:5..9, length  5 : 5 -> 5 (+ 0)
  Interval: chr11:5..9 -> chr11:4..9, length  6 : 5 -> 6 (+ 1)
  Interval: chr11:5..9 -> chr11:4..10, length  7 : 5 -> 7 (+ 2)
  Interval: chr11:5..9 -> chr11:3..10, length  8 : 5 -> 8 (+ 3)
  Interval: chr11:5..9 -> chr11:3..11, length  9 : 5 -> 9 (+ 4)
  Interval: chr11:5..9 -> chr11:2..11, length 10 : 5 -> 10 (+ 5)
  
  Testing interval chr11:6..9 with length 4
  -----
  Interval: chr11:6..9 -> chr11:6..9, length  4 : 4 -> 4 (+ 0)
  Interval: chr11:6..9 -> chr11:6..10, length  5 : 4 -> 5 (+ 1)
  Interval: chr11:6..9 -> chr11:5..10, length  6 : 4 -> 6 (+ 2)
  Interval: chr11:6..9 -> chr11:5..11, length  7 : 4 -> 7 (+ 3)
  Interval: chr11:6..9 -> chr11:4..11, length  8 : 4 -> 8 (+ 4)
  Interval: chr11:6..9 -> chr11:4..12, length  9 : 4 -> 9 (+ 5)
  


lib/AI/TensorFlow/Libtensorflow/Manual/Notebook/InferenceUsingTFHubEnformerGeneExprPredModel.pod  view on Meta::CPAN

          sprintf "%s...%s (length %d)", uc substr($seq, 0, $n), uc substr($seq, -$n), length $seq;
      } else {
          sprintf "%s (length %d)", uc $seq, length $seq;
      }
  }
  
  ####
  
  {
  
  say "Testing sequence extraction:";
  
  say "1 base: ",   seq_info
      extract_sequence( $hg_db,
          Interval->new( -seq_id => 'chr11',
              -start => 35_082_742 + 1,
              -end   => 35_082_742 + 1 ) );
  
  say "3 bases: ",  seq_info
      extract_sequence( $hg_db,
          Interval->new( -seq_id => 'chr11',

lib/AI/TensorFlow/Libtensorflow/Manual/Notebook/InferenceUsingTFHubEnformerGeneExprPredModel.pod  view on Meta::CPAN

  say "chr11 is of length ", $hg_db->length('chr11');
  say "chr11 bases: ", seq_info
      extract_sequence( $hg_db,
          Interval->new( -seq_id => 'chr11',
              -start => 1,
              -end   => $hg_db->length('chr11') )->resize( $hg_db->length('chr11') ) );
  }

B<STREAM (STDOUT)>:

  Testing sequence extraction:
  1 base: G (length 1)
  3 bases: NNN (length 3)
  5 bases: NNNNN (length 5)
  chr11 is of length 135086622
  chr11 bases: NNNNNNNNNN...NNNNNNNNNN (length 135086622)

B<RESULT>:

  1

perlcritic.rc  view on Meta::CPAN

theme = ( core + pbp + security + maintenance ) * bugs
include = CodeLayout::ProhibitTrailingWhitespace CodeLayout::RequireConsistentNewlines

[-Subroutines::ProhibitSubroutinePrototypes]

# alternate that works better with dzil ::PkgVersion
[-TestingAndDebugging::RequireUseStrict]
[-TestingAndDebugging::RequireUseWarnings]
[Community::StrictWarnings]
extra_importers = Test2::V0

# vim: ft=dosini

t/01_hello_tf.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;

use lib 't/lib';

use TF_TestQuiet;
use AI::TensorFlow::Libtensorflow;

subtest "Get version of Tensorflow" => sub {
	my $version = AI::TensorFlow::Libtensorflow->Version;
	note $version;
	pass;
};

done_testing;

t/02_load_graph.t  view on Meta::CPAN

#!/usr/bin/env perl

use strict;
use warnings;

use Test::More tests => 1;
use lib 't/lib';

use TF_TestQuiet;
use AI::TensorFlow::Libtensorflow;
use Path::Tiny;

use lib 't/lib';

subtest "Load graph" => sub {
	my $model_file = path("t/models/graph.pb");
	my $ffi = FFI::Platypus->new( api => 1 );

	my $data = $model_file->slurp_raw;

t/03_create_tftensor.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test::More tests => 1;

use strict;
use warnings;

use lib 't/lib';
use TF_TestQuiet;
use TF_Utils;

use AI::TensorFlow::Libtensorflow;
use PDL;

subtest "Create a TFTensor" => sub {
	my $p_data = sequence(float, 1, 5, 12);
	my $t = TF_Utils::FloatPDLToTFTensor($p_data);

	is $t->NumDims, 3, '3D TFTensor';

t/04_allocate_tftensor.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test::More tests => 1;

use strict;
use warnings;
use lib 't/lib';

use TF_TestQuiet;
use AI::TensorFlow::Libtensorflow;
use AI::TensorFlow::Libtensorflow::DataType qw(FLOAT);
use List::Util qw(product);
use PDL;
use PDL::Core ':Internal';

use FFI::Platypus::Memory;
use FFI::Platypus::Buffer qw(scalar_to_pointer);

subtest "Allocate a TFTensor" => sub {

t/05_session_run.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0 ':DEFAULT', '!float';

use lib 't/lib';
use TF_TestQuiet;
use TF_Utils;
use PDL::Core;
use AI::TensorFlow::Libtensorflow;
use AI::TensorFlow::Libtensorflow::DataType qw(FLOAT);

use aliased 'AI::TensorFlow::Libtensorflow::Output';
use aliased 'AI::TensorFlow::Libtensorflow::Tensor';

use FFI::Platypus::Buffer qw(scalar_to_pointer);
use FFI::Platypus::Memory qw(memcpy);

t/AI/TensorFlow/Libtensorflow.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test::More tests => 1;
use strict;
use warnings;

use lib 't/lib';
use TF_TestQuiet;

use AI::TensorFlow::Libtensorflow;

pass;

done_testing;

t/lib/TF_TestQuiet.pm  view on Meta::CPAN

package TF_TestQuiet;

use strict;
use warnings;

sub import {
	if( $ENV{HARNESS_ACTIVE} && ! ( $ENV{AUTHOR_TESTING} || $ENV{RELEASE_TESTING} ) ) {
		$ENV{TF_CPP_MIN_LOG_LEVEL} = 3;
	}
}

t/lib/TF_Utils.pm  view on Meta::CPAN


use AI::TensorFlow::Libtensorflow;
use AI::TensorFlow::Libtensorflow::Lib;
use AI::TensorFlow::Libtensorflow::DataType qw(FLOAT INT32 INT8);
use Path::Tiny;
use List::Util qw(first);

use PDL::Core ':Internal';

use FFI::Platypus::Buffer;
use Test2::V0;

my $ffi = AI::TensorFlow::Libtensorflow::Lib->ffi;

sub ScalarStringTensor {
	my ($str, $status) = @_;
	#my $tensor = AI::TensorFlow::Libtensorflow::Tensor->_Allocate(
		#AI::TensorFlow::Libtensorflow::DType::STRING,
		#\@dims, $ndims,
		#$data_size_bytes,
	#);

t/lib/TF_Utils.pm  view on Meta::CPAN


sub MinWithDevice {
	my ($l, $r, $graph, $device, $s, $name) = @_;
	$name ||= 'min';

	return TF_Utils::BinaryOpHelper(
		'Min', $l, $r, $graph, $s, $name, $device, 1
	)
}

sub RunMinTest {
	my (%args) = @_;
	my $device  = delete $args{device} || "";
	my $use_XLA = delete $args{use_XLA} || 0;

	my $ctx = Test2::API::context();

	my $s = AI::TensorFlow::Libtensorflow::Status->New;
	my $graph = AI::TensorFlow::Libtensorflow::Graph->New;

	$ctx->note('Make a placeholder operation.');
	my $feed = TF_Utils::Placeholder($graph, $s);
	TF_Utils::AssertStatusOK($s);

	$ctx->note('Make a constant operation with the scalar "0", for axis.');
	my $one = TF_Utils::ScalarConst($graph, $s, 'scalar', INT32, 0);

t/upstream/CAPI/001_Version.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use aliased 'AI::TensorFlow::Libtensorflow';

subtest "(CAPI, Version)" => sub {
	note 'Version: ', Libtensorflow->Version;
	isnt Libtensorflow->Version, '';
};

done_testing;

t/upstream/CAPI/002_Status.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use aliased 'AI::TensorFlow::Libtensorflow';
use aliased 'AI::TensorFlow::Libtensorflow::Status';

subtest "(CAPI, Status)" => sub {
	my $s = Status->New;
	is $s->GetCode, AI::TensorFlow::Libtensorflow::Status::OK, 'OK code';
	is $s->Message, '', 'empty message';

	note 'Set status to CANCELLED';
	$s->SetStatus('CANCELLED', 'cancel');

t/upstream/CAPI/003_Tensor.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use aliased 'AI::TensorFlow::Libtensorflow';
use aliased 'AI::TensorFlow::Libtensorflow::Lib';
use aliased 'AI::TensorFlow::Libtensorflow::Tensor';
use AI::TensorFlow::Libtensorflow::DataType qw(FLOAT);
use FFI::Platypus::Buffer qw(window scalar_to_pointer);
use FFI::Platypus::Memory qw(memset free);
use AI::TensorFlow::Libtensorflow::Lib::_Alloc;

subtest "(CAPI, Tensor)" => sub {
	my $n = 6;

t/upstream/CAPI/004_MalformedTensor.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use aliased 'AI::TensorFlow::Libtensorflow';
use aliased 'AI::TensorFlow::Libtensorflow::Tensor';
use AI::TensorFlow::Libtensorflow::DataType qw(FLOAT);

subtest "(CAPI, MalformedTensor)" => sub {
	my $noop_dealloc = sub {};
	my $t = Tensor->New(FLOAT, [], \undef, $noop_dealloc);
	ok ! defined $t, 'No data passed in so no tensor created';
};

t/upstream/CAPI/005_AllocateTensor.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use aliased 'AI::TensorFlow::Libtensorflow';
use aliased 'AI::TensorFlow::Libtensorflow::Tensor';
use AI::TensorFlow::Libtensorflow::DataType qw(FLOAT);

subtest "(CAPI, AllocateTensor)" => sub {
	my $num_bytes = 6 * FLOAT->Size;
	my @dims = (2, 3);
	my $t = Tensor->Allocate(FLOAT, \@dims, $num_bytes);

	cmp_ok $t->Type, '==', FLOAT, 'a FLOAT TFTensor';

t/upstream/CAPI/006_MaybeMove.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use aliased 'AI::TensorFlow::Libtensorflow';
use aliased 'AI::TensorFlow::Libtensorflow::Tensor';
use AI::TensorFlow::Libtensorflow::DataType qw(FLOAT);
use FFI::Platypus::Buffer qw(window scalar_to_pointer);
use FFI::Platypus::Memory qw(memset free);
use AI::TensorFlow::Libtensorflow::Lib::_Alloc;

subtest "(CAPI, MaybeMove)" => sub {
	my $num_bytes = 6 * FLOAT->Size;
	window( my $values,

t/upstream/CAPI/007_LibraryLoadFunctions.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use aliased 'AI::TensorFlow::Libtensorflow';

subtest "(CAPI, LibraryLoadFunctions)" => sub {
	my $todo = todo 'Test not implemented at this time. No library built to load.';
	pass;
};

done_testing;

t/upstream/CAPI/008_TensorEncodeDecodeStrings.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use aliased 'AI::TensorFlow::Libtensorflow';

subtest "(CAPI, TensorEncodeDecodeStrings)" => sub {
	my $todo = todo 'Test not implemented at this time. Upstream test uses C++ tensorflow::Tensor.';
	pass;
};

done_testing;

t/upstream/CAPI/009_SessionOptions.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use aliased 'AI::TensorFlow::Libtensorflow';
use aliased 'AI::TensorFlow::Libtensorflow::SessionOptions';

subtest "(CAPI, SessionOptions)" => sub {
	my $opt = SessionOptions->New;
	ok $opt, 'created session options';
};

done_testing;

t/upstream/CAPI/010_DeprecatedSession.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use aliased 'AI::TensorFlow::Libtensorflow';

subtest "(CAPI, DeprecatedSession)" => sub {
	my $todo = todo 'DeprecatedSession not implemented.';
	pass;
};

done_testing;

t/upstream/CAPI/011_DataTypeEnum.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use aliased 'AI::TensorFlow::Libtensorflow';

subtest "(CAPI, DataTypeEnum)" => sub {
	my $todo = todo 'Test not implemented. Casting between C++ and C DataType enum is not needed.';
	pass;
};

done_testing;

t/upstream/CAPI/012_StatusEnum.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use aliased 'AI::TensorFlow::Libtensorflow';

subtest "(CAPI, StatusEnum)" => sub {
	my $todo = todo 'Test not implemented. Casting between C++ and C Status enum is not needed.';
	pass;
};

done_testing;

t/upstream/CAPI/013_GetAllOpList.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use aliased 'AI::TensorFlow::Libtensorflow';

subtest "(CAPI, GetAllOpList)" => sub {
	my $buf = AI::TensorFlow::Libtensorflow::TFLibrary->GetAllOpList();
	ok $buf;
};

done_testing;

t/upstream/CAPI/014_SetShape.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use TF_Utils;
use aliased 'AI::TensorFlow::Libtensorflow';
use aliased 'AI::TensorFlow::Libtensorflow::Graph';
use aliased 'AI::TensorFlow::Libtensorflow::Status';
use aliased 'AI::TensorFlow::Libtensorflow::Output';
use AI::TensorFlow::Libtensorflow::DataType qw(INT32);

subtest "(CAPI, SetShape)" => sub {
	my $s     = Status->New;
	my $graph = Graph->New;

t/upstream/CAPI/014_SetShape.t  view on Meta::CPAN

	is $returned_dims, [2,3], 'dims still [2 3]';

	note 'Try to fetch a shape with the wrong num_dims';
	pass 'This test not implemented for binding. Not possible to have invalid argument for num_dims.';

	note 'Try to set an invalid shape (cannot change 2x3 to a 2x5).';
	$dims->[1] = 5;
	$graph->SetTensorShape( $feed_out_0, $dims, $s);
	note TF_Utils::AssertStatusNotOK($s);

	note 'Test for a scalar.';
	my $three = TF_Utils::ScalarConst($graph, $s, 'scalar', INT32, 3);
	TF_Utils::AssertStatusOK($s);
	my $three_out_0 = Output->New({ oper => $three, index => 0 });

	$num_dims = $graph->GetTensorNumDims( $three_out_0, $s );
	TF_Utils::AssertStatusOK($s);
	is $num_dims, 0, 'zero dims';
	$returned_dims = $graph->GetTensorShape( $three_out_0, $s );
	is $returned_dims, [], 'dims is empty ArrayRef';
};

t/upstream/CAPI/015_Graph.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test2::V0;
use lib 't/lib';
use TF_TestQuiet;
use TF_Utils;
use aliased 'AI::TensorFlow::Libtensorflow';
use AI::TensorFlow::Libtensorflow::DataType qw(INT32);
use AI::TensorFlow::Libtensorflow::Lib::Types qw(
	TFOutput TFOutputFromTuple
	TFInput  TFInputFromTuple
);
use Types::Standard qw(HashRef);

my $TFOutput = TFOutput->plus_constructors(

t/upstream/CAPI/015_Graph.t  view on Meta::CPAN

		HashRef, 'New'
	)->plus_coercions(TFInputFromTuple);
subtest "(CAPI, Graph)" => sub {
	my $s = AI::TensorFlow::Libtensorflow::Status->New;
	my $graph = AI::TensorFlow::Libtensorflow::Graph->New;

	note 'Make a placeholder operation.';
	my $feed = TF_Utils::Placeholder($graph, $s);
	TF_Utils::AssertStatusOK($s);

	subtest 'Test TF_Operation*() query functions.' => sub {
		is $feed->Name, 'feed', 'name';
		is $feed->OpType, 'Placeholder', 'optype';
		is $feed->Device, '', 'device';
		is $feed->NumOutputs, 1, 'num outputs';
		cmp_ok $feed->OutputType(
			$TFOutput->coerce({oper => $feed, index => 0})
		), 'eq', INT32, 'output 0 type';

		is $feed->OutputListLength("output", $s), 1, 'output list length';
		TF_Utils::AssertStatusOK($s);

		is $feed->NumInputs, 0, 'num inputs';
		is $feed->OutputNumConsumers(
			$TFOutput->coerce({oper => $feed, index => 0})
		), 0, 'output 0 num consumers';
		is $feed->NumControlInputs, 0, 'num control inputs';
		is $feed->NumControlOutputs, 0, 'num control outputs';
	};

	subtest 'Test not found errors in TF_Operation*() query functions.' => sub {
		is $feed->OutputListLength('bogus', $s), -1, 'bogus output';
		note TF_Utils::AssertStatusNotOK($s);
	};

	note 'Make a constant oper with the scalar "3".';
	my $three = TF_Utils::ScalarConst($graph, $s, 'scalar', INT32, 3);
	TF_Utils::AssertStatusOK($s);

	note 'Add oper.';
	my $add = TF_Utils::Add($feed, $three, $graph, $s);
	TF_Utils::AssertStatusOK($s);

	subtest 'Test TF_Operation*() query functions.' => sub {
		is $add->Name, 'add', 'name';
		is $add->OpType, 'AddN', 'op type';
		is $add->Device, '', 'device';
		is $add->NumOutputs, 1, 'num outputs';
		cmp_ok $add->OutputType($TFOutput->coerce([$add => 0])),
			'eq', INT32, 'output type';
		is $add->OutputListLength('sum', $s), 1, 'output list length';
		TF_Utils::AssertStatusOK($s);
		is $add->NumInputs, 2, 'num inputs';
		is $add->InputListLength("inputs", $s), 2, 'InputListLength';

t/upstream/CAPI/015_Graph.t  view on Meta::CPAN

	note 'Add another oper to the graph.';
	my $neg = TF_Utils::Neg( $add, $graph, $s );
	TF_Utils::AssertStatusOK($s);
	is $neg->Name, 'neg', 'neg name';
	is $neg->OpType, 'Neg', 'neg op type';

	subtest 'Serialize to NodeDef.' => sub {
		skip_all 'Can not use C++ tensorflow::NodeDef* to check';
	};

	subtest 'Test iterating through the nodes of a graph.' => sub {
		my $pos = 0;
		my %oper_by_name;
		while( my $oper = $graph->NextOperation(\$pos) ) {
			$oper_by_name{$oper->Name} = $oper;
		}
		is \%oper_by_name, hash {
			field feed => D();
			field scalar => D();
			field add => D();
			field neg => D();



( run in 0.650 second using v1.01-cache-2.11-cpan-4d50c553e7e )