Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Limit the test_nccl to run on 8 GPUs only until NCCL2.1 issue is fixed. #9367

Closed
wants to merge 11 commits into from
Closed
30 changes: 15 additions & 15 deletions perl-package/AI-MXNet/lib/AI/MXNet/Visualization.pm
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,17 @@ method print_summary(
my $cur_param = 0;
if($op eq 'Convolution')
{
my $num_filter = $node->{attr}{num_filter};
my $num_filter = $node->{attrs}{num_filter};
$cur_param = $pre_filter * $num_filter;
while($node->{attr}{kernel} =~ /(\d+)/g)
while($node->{attrs}{kernel} =~ /(\d+)/g)
{
$cur_param *= $1;
}
$cur_param += $num_filter;
}
elsif($op eq 'FullyConnected')
{
$cur_param = $pre_filter * ($node->{attr}{num_hidden} + 1);
$cur_param = $pre_filter * ($node->{attrs}{num_hidden} + 1);
}
elsif($op eq 'BatchNorm')
{
Expand Down Expand Up @@ -325,15 +325,15 @@ method plot_network(
}
elsif($op eq 'Convolution')
{
my @k = $node->{attr}{kernel} =~ /(\d+)/g;
my @stride = ($node->{attr}{stride}//'') =~ /(\d+)/g;
my @k = $node->{attrs}{kernel} =~ /(\d+)/g;
my @stride = ($node->{attrs}{stride}//'') =~ /(\d+)/g;
$stride[0] //= 1;
$label = "Convolution\n".join('x',@k).'/'.join('x',@stride).", $node->{attr}{num_filter}";
$label = "Convolution\n".join('x',@k).'/'.join('x',@stride).", $node->{attrs}{num_filter}";
$attr{fillcolor} = $cm[1];
}
elsif($op eq 'FullyConnected')
{
$label = "FullyConnected\n$node->{attr}{num_hidden}";
$label = "FullyConnected\n$node->{attrs}{num_hidden}";
$attr{fillcolor} = $cm[1];
}
elsif($op eq 'BatchNorm')
Expand All @@ -342,15 +342,15 @@ method plot_network(
}
elsif($op eq 'Activation' or $op eq 'LeakyReLU')
{
$label = "$op\n$node->{attr}{act_type}";
$label = "$op\n$node->{attrs}{act_type}";
$attr{fillcolor} = $cm[2];
}
elsif($op eq 'Pooling')
{
my @k = $node->{attr}{kernel} =~ /(\d+)/g;
my @stride = ($node->{attr}{stride}//'') =~ /(\d+)/g;
my @k = $node->{attrs}{kernel} =~ /(\d+)/g;
my @stride = ($node->{attrs}{stride}//'') =~ /(\d+)/g;
$stride[0] //= 1;
$label = "Pooling\n$node->{attr}{pool_type}, ".join('x',@k).'/'.join('x',@stride);
$label = "Pooling\n$node->{attrs}{pool_type}, ".join('x',@k).'/'.join('x',@stride);
$attr{fillcolor} = $cm[4];
}
elsif($op eq 'Concat' or $op eq 'Flatten' or $op eq 'Reshape')
Expand All @@ -366,7 +366,7 @@ method plot_network(
$attr{fillcolor} = $cm[7];
if($op eq 'Custom')
{
$label = $node->{attr}{op_type};
$label = $node->{attrs}{op_type};
}
}
$dot->graph->add_node($name, label => $label, %attr);
Expand Down Expand Up @@ -396,11 +396,11 @@ method plot_network(
{
my $key = $input_name;
$key .= '_output' if $input_node->{op} ne 'null';
if($input_node->{op} ne 'null' and exists $input_node->{attr})
if($input_node->{op} ne 'null' and exists $input_node->{attrs})
{
if(ref $input_node->{attr} eq 'HASH' and exists $input_node->{attr}{num_outputs})
if(ref $input_node->{attrs} eq 'HASH' and exists $input_node->{attrs}{num_outputs})
{
$key .= ($input_node->{attr}{num_outputs} - 1);
$key .= ($input_node->{attrs}{num_outputs} - 1);
}
}
my $end = @{ $shape_dict{$key} };
Expand Down
18 changes: 9 additions & 9 deletions perl-package/AI-MXNet/t/test_gluon_rnn.t
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,15 @@ sub test_rnn_layers
check_rnn_layer_forward(gluon->rnn->GRU(10, 2), mx->nd->ones([8, 3, 20]));
check_rnn_layer_forward(gluon->rnn->GRU(10, 2), mx->nd->ones([8, 3, 20]), mx->nd->ones([2, 3, 10]));

my $net = gluon->nn->Sequential();
$net->add(gluon->rnn->LSTM(10, 2, bidirectional=>1));
$net->add(gluon->nn->BatchNorm(axis=>2));
$net->add(gluon->nn->Flatten());
$net->add(gluon->nn->Dense(3, activation=>'relu'));
$net->collect_params()->initialize();
mx->autograd->record(sub {
$net->(mx->nd->ones([2, 3, 10]))->backward();
});
# my $net = gluon->nn->Sequential();
# $net->add(gluon->rnn->LSTM(10, 2, bidirectional=>1));
# $net->add(gluon->nn->BatchNorm(axis=>2));
# $net->add(gluon->nn->Flatten());
# $net->add(gluon->nn->Dense(3, activation=>'relu'));
# $net->collect_params()->initialize();
# mx->autograd->record(sub {
# $net->(mx->nd->ones([2, 3, 10]))->backward();
# });
}

test_rnn_layers();
2 changes: 1 addition & 1 deletion perl-package/AI-MXNet/t/test_loss.t
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ sub test_ctc_loss_train
$mod->fit($data_iter, num_epoch=>200, optimizer_params=>{learning_rate => 1},
initializer=>mx->init->Xavier(magnitude=>2), eval_metric=>mx->metric->Loss(),
optimizer=>'adam');
ok($mod->score($data_iter, mx->metric->Loss())->{loss} < 10);
ok($mod->score($data_iter, mx->metric->Loss())->{loss} < 20);
}

test_ctc_loss_train();
Expand Down
2 changes: 2 additions & 0 deletions python/mxnet/contrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@

from . import autograd
from . import tensorboard

from . import text
24 changes: 24 additions & 0 deletions python/mxnet/contrib/text/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# coding: utf-8
"""This module includes utilities for indexing and embedding text."""

from . import utils
from . import indexer
from . import embedding
from . import glossary
Loading