AI-MXNet
view release on metacpan or search on metacpan
lib/AI/MXNet/Symbol.pm view on Meta::CPAN
package AI::MXNet::Symbol;
=head1 NAME
AI::MXNet::Symbol - Symbolic interface of MXNet.
=cut
use strict;
use warnings;
use AI::MXNet::Base;
use AI::MXNet::Symbol::Base;
use AI::MXNet::Types;
use Mouse;
use AI::MXNet::Function::Parameters;
use overload
'""' => \&stringify,
'+' => \&add,
'-' => \&subtract,
'*' => \&multiply,
'/' => \÷,
'/=' => \&idivide,
'**' => \&power,
'%' => \&mod,
'==' => \&equal,
'!=' => \¬_equal,
'>' => \&greater,
'>=' => \&greater_equal,
'<' => \&lesser,
'<=' => \&lesser_equal,
'&{}' => sub { my $self = shift; sub { $self->call(@_) } },
'@{}' => sub { my $self = shift; [map { $self->slice($_) } @{ $self->list_outputs }] };
extends 'AI::MXNet::Symbol::Base';
has 'handle' => (is => 'rw', isa => 'SymbolHandle', required => 1);
sub DEMOLISH
{
check_call(AI::NNVMCAPI::SymbolFree(shift->handle));
}
method STORABLE_freeze($cloning)
{
return $self->tojson();
}
method STORABLE_thaw($cloning, $json)
{
my $handle = check_call(
AI::MXNetCAPI::SymbolCreateFromJSON(
$json
)
);
$self->handle($handle);
}
method stringify($other=, $reverse=)
{
my $name = $self->name;
sprintf("<%s %s>", ref($self), $name ? $name : 'Grouped');
}
method add(AI::MXNet::Symbol|Num $other, $reverse=)
{
return _ufunc_helper(
$self,
$other,
qw/_Plus _PlusScalar/
);
}
method subtract(AI::MXNet::Symbol|Num $other, $reverse=)
{
return _ufunc_helper(
$self,
$other,
qw/_Minus _MinusScalar _RMinusScalar/,
$reverse
);
}
method multiply(AI::MXNet::Symbol|Num $other, $reverse=)
{
return _ufunc_helper(
$self,
$other,
qw/_Mul _MulScalar/
);
}
method divide(AI::MXNet::Symbol|Num $other, $reverse=)
{
return _ufunc_helper(
$self,
$other,
( run in 0.822 second using v1.01-cache-2.11-cpan-39bf76dae61 )