| 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::Doc; | ||
| 19 | use strict; | ||
| 20 | use warnings; | ||
| 21 | use AI::MXNet::Base; | ||
| 22 | use AI::MXNet::Function::Parameters; | ||
| 23 | use Exporter; | ||
| 24 | use base qw(Exporter); | ||
| 25 | @AI::MXNet::Symbol::Doc::EXPORT = qw/build_doc/; | ||
| 26 | |||
| 27 | method get_output_shape(AI::MXNet::Symbol $sym, %input_shapes) | ||
| 28 | { | ||
| 29 | my $s_outputs = $sym->infer_shape(%input_shapes); | ||
| 30 | my %ret; | ||
| 31 | @ret{ @{ $sym->list_outputs() } } = @$s_outputs; | ||
| 32 | return bless \%ret, 'AI::MXNet::Util::Printable'; | ||
| 33 | } | ||
| 34 | |||
| 35 | func build_doc( | ||
| 36 | Str $func_name, | ||
| 37 | Str $desc, | ||
| 38 | ArrayRef[Str] $arg_names, | ||
| 39 | ArrayRef[Str] $arg_types, | ||
| 40 | ArrayRef[Str] $arg_desc, | ||
| 41 | Str $key_var_num_args=, | ||
| 42 | Str $ret_type= | ||
| 43 | ) | ||
| 44 | { | ||
| 45 | my $param_str = build_param_doc($arg_names, $arg_types, $arg_desc); | ||
| 46 | if($key_var_num_args) | ||
| 47 | { | ||
| 48 | $desc .= "\nThis function support variable length of positional input." | ||
| 49 | } | ||
| 50 | my $doc_str = sprintf("%s\n\n" . | ||
| 51 | "%s\n" . | ||
| 52 | "name : string, optional.\n" . | ||
| 53 | " Name of the resulting symbol.\n\n" . | ||
| 54 | "Returns\n" . | ||
| 55 | "-------\n" . | ||
| 56 | "symbol: Symbol\n" . | ||
| 57 | " The result symbol.", $desc, $param_str); | ||
| 58 | return $doc_str; | ||
| 59 | } | ||
| 60 | |||
| 61 | 1; |