| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one |
|
2
|
|
|
|
|
|
|
# or more contributor license agreements. See the NOTICE file |
|
3
|
|
|
|
|
|
|
# distributed with this work for additional information |
|
4
|
|
|
|
|
|
|
# regarding copyright ownership. The ASF licenses this file |
|
5
|
|
|
|
|
|
|
# to you under the Apache License, Version 2.0 (the |
|
6
|
|
|
|
|
|
|
# "License"); you may not use this file except in compliance |
|
7
|
|
|
|
|
|
|
# with the License. You may obtain a copy of the License at |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, |
|
12
|
|
|
|
|
|
|
# software distributed under the License is distributed on an |
|
13
|
|
|
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|
14
|
|
|
|
|
|
|
# KIND, either express or implied. See the License for the |
|
15
|
|
|
|
|
|
|
# specific language governing permissions and limitations |
|
16
|
|
|
|
|
|
|
# under the License. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package AI::MXNet; |
|
19
|
26
|
|
|
26
|
|
1329868
|
use v5.14.0; |
|
|
26
|
|
|
|
|
374
|
|
|
20
|
26
|
|
|
26
|
|
201
|
use strict; |
|
|
26
|
|
|
|
|
70
|
|
|
|
26
|
|
|
|
|
818
|
|
|
21
|
26
|
|
|
26
|
|
178
|
use warnings; |
|
|
26
|
|
|
|
|
68
|
|
|
|
26
|
|
|
|
|
1130
|
|
|
22
|
26
|
|
|
26
|
|
12008
|
use AI::MXNet::Base; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use AI::MXNet::Callback; |
|
24
|
|
|
|
|
|
|
use AI::MXNet::NDArray; |
|
25
|
|
|
|
|
|
|
use AI::MXNet::Symbol; |
|
26
|
|
|
|
|
|
|
use AI::MXNet::Executor; |
|
27
|
|
|
|
|
|
|
use AI::MXNet::Executor::Group; |
|
28
|
|
|
|
|
|
|
use AI::MXNet::CudaModule; |
|
29
|
|
|
|
|
|
|
use AI::MXNet::Random; |
|
30
|
|
|
|
|
|
|
use AI::MXNet::Initializer; |
|
31
|
|
|
|
|
|
|
use AI::MXNet::Optimizer; |
|
32
|
|
|
|
|
|
|
use AI::MXNet::KVStore; |
|
33
|
|
|
|
|
|
|
use AI::MXNet::KVStoreServer; |
|
34
|
|
|
|
|
|
|
use AI::MXNet::IO; |
|
35
|
|
|
|
|
|
|
use AI::MXNet::Metric; |
|
36
|
|
|
|
|
|
|
use AI::MXNet::LRScheduler; |
|
37
|
|
|
|
|
|
|
use AI::MXNet::Monitor; |
|
38
|
|
|
|
|
|
|
use AI::MXNet::Profiler; |
|
39
|
|
|
|
|
|
|
use AI::MXNet::Module::Base; |
|
40
|
|
|
|
|
|
|
use AI::MXNet::Module; |
|
41
|
|
|
|
|
|
|
use AI::MXNet::Module::Bucketing; |
|
42
|
|
|
|
|
|
|
use AI::MXNet::RNN; |
|
43
|
|
|
|
|
|
|
use AI::MXNet::Visualization; |
|
44
|
|
|
|
|
|
|
use AI::MXNet::RecordIO; |
|
45
|
|
|
|
|
|
|
use AI::MXNet::Image; |
|
46
|
|
|
|
|
|
|
use AI::MXNet::Contrib; |
|
47
|
|
|
|
|
|
|
use AI::MXNet::CachedOp; |
|
48
|
|
|
|
|
|
|
use AI::MXNet::AutoGrad; |
|
49
|
|
|
|
|
|
|
use AI::MXNet::Gluon; |
|
50
|
|
|
|
|
|
|
our $VERSION = '1.1'; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub import |
|
53
|
|
|
|
|
|
|
{ |
|
54
|
|
|
|
|
|
|
my ($class, $short_name) = @_; |
|
55
|
|
|
|
|
|
|
if($short_name) |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
|
|
|
|
|
|
$short_name =~ s/[^\w:]//g; |
|
58
|
|
|
|
|
|
|
if(length $short_name) |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
|
|
|
|
|
|
my $short_name_package =<<"EOP"; |
|
61
|
|
|
|
|
|
|
package $short_name; |
|
62
|
|
|
|
|
|
|
no warnings 'redefine'; |
|
63
|
|
|
|
|
|
|
sub nd { 'AI::MXNet::NDArray' } |
|
64
|
|
|
|
|
|
|
sub sym { 'AI::MXNet::Symbol' } |
|
65
|
|
|
|
|
|
|
sub symbol { 'AI::MXNet::Symbol' } |
|
66
|
|
|
|
|
|
|
sub init { 'AI::MXNet::Initializer' } |
|
67
|
|
|
|
|
|
|
sub initializer { 'AI::MXNet::Initializer' } |
|
68
|
|
|
|
|
|
|
sub optimizer { 'AI::MXNet::Optimizer' } |
|
69
|
|
|
|
|
|
|
sub opt { 'AI::MXNet::Optimizer' } |
|
70
|
|
|
|
|
|
|
sub rnd { 'AI::MXNet::Random' } |
|
71
|
|
|
|
|
|
|
sub random { 'AI::MXNet::Random' } |
|
72
|
|
|
|
|
|
|
sub Context { shift; AI::MXNet::Context->new(\@_) } |
|
73
|
|
|
|
|
|
|
sub context { 'AI::MXNet::Context' } |
|
74
|
|
|
|
|
|
|
sub cpu { AI::MXNet::Context->cpu(\$_[1]//0) } |
|
75
|
|
|
|
|
|
|
sub gpu { AI::MXNet::Context->gpu(\$_[1]//0) } |
|
76
|
|
|
|
|
|
|
sub kv { 'AI::MXNet::KVStore' } |
|
77
|
|
|
|
|
|
|
sub recordio { 'AI::MXNet::RecordIO' } |
|
78
|
|
|
|
|
|
|
sub io { 'AI::MXNet::IO' } |
|
79
|
|
|
|
|
|
|
sub metric { 'AI::MXNet::Metric' } |
|
80
|
|
|
|
|
|
|
sub mod { 'AI::MXNet::Module' } |
|
81
|
|
|
|
|
|
|
sub mon { 'AI::MXNet::Monitor' } |
|
82
|
|
|
|
|
|
|
sub viz { 'AI::MXNet::Visualization' } |
|
83
|
|
|
|
|
|
|
sub rnn { 'AI::MXNet::RNN' } |
|
84
|
|
|
|
|
|
|
sub callback { 'AI::MXNet::Callback' } |
|
85
|
|
|
|
|
|
|
sub img { 'AI::MXNet::Image' } |
|
86
|
|
|
|
|
|
|
sub image { 'AI::MXNet::Image' } |
|
87
|
|
|
|
|
|
|
sub contrib { 'AI::MXNet::Contrib' } |
|
88
|
|
|
|
|
|
|
sub autograd { 'AI::MXNet::AutoGrad' } |
|
89
|
|
|
|
|
|
|
sub name { '$short_name' } |
|
90
|
|
|
|
|
|
|
sub rtc { '$short_name' } |
|
91
|
|
|
|
|
|
|
sub CudaModule { shift; AI::MXNet::CudaModule->new(\@_) } |
|
92
|
|
|
|
|
|
|
sub AttrScope { shift; AI::MXNet::Symbol::AttrScope->new(\@_) } |
|
93
|
|
|
|
|
|
|
*AI::MXNet::Symbol::AttrScope::current = sub { \$${short_name}::AttrScope; }; |
|
94
|
|
|
|
|
|
|
\$${short_name}::AttrScope = AI::MXNet::Symbol::AttrScope->new; |
|
95
|
|
|
|
|
|
|
sub Prefix { AI::MXNet::Symbol::Prefix->new(prefix => \$_[1]) } |
|
96
|
|
|
|
|
|
|
*AI::MXNet::Symbol::NameManager::current = sub { \$${short_name}::NameManager; }; |
|
97
|
|
|
|
|
|
|
*AI::MXNet::Symbol::NameManager::set_current = sub { \$${short_name}::NameManager = \$_[1]; }; |
|
98
|
|
|
|
|
|
|
\$${short_name}::NameManager = AI::MXNet::Symbol::NameManager->new; |
|
99
|
|
|
|
|
|
|
*AI::MXNet::Context::current_ctx = sub { \$${short_name}::Context; }; |
|
100
|
|
|
|
|
|
|
*AI::MXNet::Context::current_context = sub { \$${short_name}::Context; }; |
|
101
|
|
|
|
|
|
|
*AI::MXNet::Context::set_current = sub { \$${short_name}::Context = \$_[1]; }; |
|
102
|
|
|
|
|
|
|
\$${short_name}::Context = AI::MXNet::Context->new(device_type => 'cpu', device_id => 0); |
|
103
|
|
|
|
|
|
|
1; |
|
104
|
|
|
|
|
|
|
EOP |
|
105
|
|
|
|
|
|
|
eval $short_name_package; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
|
111
|
|
|
|
|
|
|
__END__ |