This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new bc30e54  [Perl] bugfixes for distributed training using 
tools/launch.py (#7801)
bc30e54 is described below

commit bc30e54c162a7dd0b9828cdef7b74a1c09359264
Author: Robert Stone <[email protected]>
AuthorDate: Fri Sep 8 16:54:08 2017 -0700

    [Perl] bugfixes for distributed training using tools/launch.py (#7801)
---
 perl-package/AI-MXNet/lib/AI/MXNet/KVStore.pm     | 6 +++---
 perl-package/AI-MXNet/lib/AI/MXNet/Module/Base.pm | 2 +-
 perl-package/AI-MXNet/lib/AI/MXNet/Types.pm       | 5 +++++
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/KVStore.pm 
b/perl-package/AI-MXNet/lib/AI/MXNet/KVStore.pm
index eff57a3..fa74e4a 100644
--- a/perl-package/AI-MXNet/lib/AI/MXNet/KVStore.pm
+++ b/perl-package/AI-MXNet/lib/AI/MXNet/KVStore.pm
@@ -244,7 +244,7 @@ method pull(
 method set_optimizer(AI::MXNet::Optimizer $optimizer)
 {
     my $is_worker = check_call(AI::MXNetCAPI::KVStoreIsWorkerNode());
-    if($self->type eq 'dist' and $is_worker)
+    if($self->type =~ /dist/ and $is_worker)
     {
         my $optim_str = 
MIME::Base64::encode_base64(Storable::freeze($optimizer), "");
         $self->_send_command_to_servers(0, $optim_str);
@@ -252,7 +252,7 @@ method set_optimizer(AI::MXNet::Optimizer $optimizer)
     else
     {
         $self->_updater(AI::MXNet::Optimizer->get_updater($optimizer));
-        $self->_set_updater(sub { &{$self->_updater}(@_) });
+        $self->_set_updater($self->_updater);
     }
 }
 
@@ -371,7 +371,7 @@ method load_optimizer_states(Str $fname)
         [ 6.  6.  6.]]
 =cut
 
-method _set_updater(CodeRef $updater_func)
+method _set_updater(Updater $updater_func)
 {
     $self->_updater_func(
         sub {
diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Module/Base.pm 
b/perl-package/AI-MXNet/lib/AI/MXNet/Module/Base.pm
index 7a9e3de..8df52eb 100644
--- a/perl-package/AI-MXNet/lib/AI/MXNet/Module/Base.pm
+++ b/perl-package/AI-MXNet/lib/AI/MXNet/Module/Base.pm
@@ -484,7 +484,7 @@ method fit(
     EvalMetric                         :$eval_metric='acc',
     Maybe[Callback]|ArrayRef[Callback] :$epoch_end_callback=,
     Maybe[Callback]|ArrayRef[Callback] :$batch_end_callback=,
-    Str                                :$kvstore='local',
+    KVStore                            :$kvstore='local',
     Optimizer                          :$optimizer='sgd',
     HashRef                            :$optimizer_params={ learning_rate => 
0.01 },
     Maybe[Callback]|ArrayRef[Callback] :$eval_end_callback=,
diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Types.pm 
b/perl-package/AI-MXNet/lib/AI/MXNet/Types.pm
index b4ec7e9..27dd013 100644
--- a/perl-package/AI-MXNet/lib/AI/MXNet/Types.pm
+++ b/perl-package/AI-MXNet/lib/AI/MXNet/Types.pm
@@ -37,6 +37,8 @@ class_type 'AI::MXNet::Optimizer';
 class_type 'AI::MXNet::Initializer';
 class_type 'AI::MXNet::InitDesc';
 class_type 'AI::MXNet::IRHeader';
+class_type 'AI::MXNet::Updater';
+class_type 'AI::MXNet::KVStore';
 subtype "AcceptableInput" => as 
"Num|PDL|PDL::Matrix|AI::MXNet::NDArray|AI::MXNet::NDArray::Slice|ArrayRef";
 subtype "Index"           => as "Int";
 subtype "DimSize"         => as "Int" => where { $_ >= 0 };
@@ -48,6 +50,7 @@ subtype "Metric"          => as "Maybe[CodeRef|Str]";
 subtype "ProfilerMode"    => as enum([qw[symbolic all]]);
 subtype "ProfilerState"   => as enum([qw[stop run]]);
 subtype "GradReq"         => as enum([qw[add write null]]);
+subtype "KVStoreStr"      => as enum([qw[local device dist dist_sync 
dist_async]]);
 subtype "NameShape"       => as "ArrayRef" => where {
     find_type_constraint("Str")->check($_->[0])
         and
@@ -57,6 +60,8 @@ subtype "Callback"        => as 
"CodeRef|ArrayRef[Coderef]|AI::MXNet::Callback|A
 subtype "EvalMetric"      => as "AI::MXNet::EvalMetric|Str|CodeRef";
 subtype "Optimizer"       => as "AI::MXNet::Optimizer|Str";
 subtype "Initializer"     => as "AI::MXNet::Initializer|Str";
+subtype "Updater"         => as "AI::MXNet::Updater|CodeRef";
+subtype "KVStore"         => as "AI::MXNet::KVStore|KVStoreStr";
 subtype "Activation"      => as "AI::MXNet::Symbol|Str|CodeRef";
 subtype "SymbolOrArrayOfSymbols" => as 
"AI::MXNet::Symbol|ArrayRef[AI::MXNet::Symbol]";
 subtype "NameShapeOrDataDesc" => as "NameShape|AI::MXNet::DataDesc";

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to