AI-TensorFlow-Libtensorflow
view release on metacpan or search on metacpan
lib/AI/TensorFlow/Libtensorflow/Operation.pm view on Meta::CPAN
package AI::TensorFlow::Libtensorflow::Operation;
# ABSTRACT: An operation
$AI::TensorFlow::Libtensorflow::Operation::VERSION = '0.0.7';
use strict;
use warnings;
use namespace::autoclean;
use AI::TensorFlow::Libtensorflow::Lib qw(arg);
use AI::TensorFlow::Libtensorflow::Output;
use AI::TensorFlow::Libtensorflow::Input;
my $ffi = AI::TensorFlow::Libtensorflow::Lib->ffi;
$ffi->mangler(AI::TensorFlow::Libtensorflow::Lib->mangler_default);
use FFI::C::ArrayDef;
my $adef = FFI::C::ArrayDef->new(
$ffi,
name => 'TF_Operation_array',
members => [
FFI::C::StructDef->new(
$ffi,
members => [
p => 'opaque'
]
)
],
);
sub _adef { $adef; }
sub _as_array {
my $class = shift;
my $array = $class->_adef->create(0 + @_);
for my $idx (0..@_-1) {
next unless defined $_[$idx];
$array->[$idx]->p($ffi->cast('TF_Operation', 'opaque', $_[$idx]));
}
$array;
}
sub _from_array {
my ($class, $array) = @_;
[
map {
$ffi->cast('opaque', 'TF_Operation', $array->[$_]->p);
} 0..$array->count-1
]
}
$ffi->attach( [ 'OperationName' => 'Name' ], [
arg 'TF_Operation' => 'oper',
] => 'string');
$ffi->attach( [ 'OperationOpType' => 'OpType' ], [
arg 'TF_Operation' => 'oper',
] => 'string');
$ffi->attach( [ 'OperationDevice' => 'Device' ], [
arg 'TF_Operation' => 'oper',
] => 'string');
$ffi->attach( [ 'OperationNumOutputs' => 'NumOutputs' ], [
arg 'TF_Operation' => 'oper',
] => 'int');
$ffi->attach( [ 'OperationOutputType' => 'OutputType' ] => [
arg 'TF_Output' => 'oper_out',
] => 'TF_DataType' => sub {
my ($xs, $self, $output) = @_;
# TODO coerce from LibtfPartialOutput here
( run in 1.046 second using v1.01-cache-2.11-cpan-39bf76dae61 )