MXNet/Symbol/AttrScope.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 45 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
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::Symbol::AttrScope;
19 use strict;
20 use warnings;
21 use Mouse;
22 use AI::MXNet::NS;
23 use AI::MXNet::Function::Parameters;
24 around BUILDARGS => sub {
25 my $orig = shift;
26 my $class = shift;
27 return $class->$orig(attr => {@_});
28 };
29  
30 =head1 NAME
31  
32 AI::MXNet::Symbol::AttrScope - Attribute manager for local scoping.
33  
34 =head1 DESCRIPTION
35  
36 Attribute manager for scoping.
37  
38 User can also inherit this object to change naming behavior.
39  
40 Parameters
41 ----------
42 kwargs
43 The attributes to set for all symbol creations in the scope.
44 =cut
45  
46 has 'attr' => (
47 is => 'ro',
48 isa => 'HashRef[Str]',
49 );
50  
51 =head2 current
52  
53 Get the attribute hash ref given the attribute set by the symbol.
54  
55 Returns
56 -------
57 $attr : current value of the class singleton object
58 =cut
59  
60 method current()
61 {
62 $AI::MXNet::AttrScope;
63 }
64  
65 method set_current(AI::MXNet::Symbol::AttrScope $new)
66 {
67 $AI::MXNet::AttrScope = $new;
68 }
69  
70 =head2 get
71  
72 Get the attribute hash ref given the attribute set by the symbol.
73  
74 Parameters
75 ----------
76 $attr : Maybe[HashRef[Str]]
77 The attribute passed in by user during symbol creation.
78  
79 Returns
80 -------
81 $attr : HashRef[Str]
82 The attributes updated to include another the scope related attributes.
83 =cut
84  
85 method get(Maybe[HashRef[Str]] $attr=)
86 {
87 return bless($attr//{}, 'AI::MXNet::Util::Printable') unless %{ $self->attr };
88 my %ret = (%{ $self->attr }, %{ $attr//{} });
89 return bless (\%ret, 'AI::MXNet::Util::Printable');
90 }
91  
92 __PACKAGE__->AI::MXNet::NS::register('AI::MXNet');
93  
94 1;