MXNet/NS.pm

filter: Statementstmt 50.0% 18 / 36 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 55.5% 5 / 9 Podpod 0.0% 0 / 1 totaltotal 37.7% 23 / 61 CC 7 SCAR 25.6
CC
7
Cov
38%
__ANON__
30.0
register
12.0
__ANON__
2.0
CRAP 13.0
« MXNet/CachedOp.pm ↑ Summary MXNet/Executor.pm »
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::NS;
19 # this class is similar to Exporter, in that it will add an "import"
20 # method to the calling package. It is to allow a package to emulate
21 # the python "import mxnet as mx" style aliasing as "use AI::MXNet 'mx'"
22 31 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 31 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 31 ▶sub _sym : lvalue
Subroutine _sym: called CC=1 SCAR=0.0
26 {
27 31 my ($pkg, $name) = @_;
28 31 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
29 31 *{"$pkg\::$name"};
30 }
31  
32 sub import
33 31 ▶{
Subroutine import: called CC=1 SCAR=4.0
34 31 my (undef, $opt) = @_;
35 31 my $class = caller();
36 0 ▶ my $func = sub { $class };
Subroutine __ANON__: not called CC=1 SCAR=1.2
37 0 ▶ _sym($class, 'import') = sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
38 0 my (undef, @names) = @_;
39 0 @names = map { s/[^\w:]//sgr } @names;
40 0 my $target = caller();
41  
42 0 ▶ _sym($names[0], '') = _sym($class, '') if
Branch: 1 branch
BranchTrueFalseTotal
if @names == 1 and $opt and $opt eq "global" 0 0 0
Condition0%0/6
@names == 1 and $opt and $opt eq "global"
!ll&&!rl&&r
000
@names == 1 and $opt
!ll&&!rl&&r
000
MC/DC0%0/3
@names == 1 and $opt and $opt eq "global"
@names == 1 $opt $opt eq "global"
Truth table0%0/4
A and B and C
A= @names == 1B= $optC= $opt eq "global"
ABCresult
0XX0
10X0
1100
1111
43 @names == 1 and $opt and $opt eq 'global';
44  
45 0 _sym($target, $_) = $func for @names;
46 31 };
47 }
48  
49 31 my $autoload_template = q(
50 sub AUTOLOAD
51 {
52 our ($AUTOLOAD, %AUTOLOAD);
53 my $name = $AUTOLOAD =~ s/.*:://sr;
54 my $func = $AUTOLOAD{$name};
55 Carp::carp(qq(Can't locate object method "$name" via package "${\ __PACKAGE__ }"))
56 unless $func;
57 goto $func;
58 }
59 );
60  
61 # using AUTOLOAD here allows for the addition of an AI::MXNet::SomeClass
62 # class to coexist with an AI::MXNet->SomeClass() shorthand constructor.
63 sub register
64 0 ▶{
Subroutine register: not called CC=3 SCAR=24.8
Pod undocumented
65 0 my ($class, $target) = @_;
66 0 my $name = $class =~ s/.*:://sr;
67 0 my $dest = $class->can('new');
68 0 ▶ ${_sym($target, 'AUTOLOAD')}{$name} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
69 0 splice @_, 0, 1, $class;
70 0 goto $dest;
71 0 };
72 0 ▶ return if $target->can('AUTOLOAD');
Branch: 1 branch
BranchTrueFalseTotal
if $target->can("AUTOLOAD") 0 0 0
73 0 eval sprintf 'package %s { %s }', $target, $autoload_template;
74 0 ▶ die if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
75 0 return;
76 }
77  
78 31 1;
« MXNet/CachedOp.pm ↑ Summary MXNet/Executor.pm »