• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MINDSPORE_CORE_OPS_LSTM_H_
18 #define MINDSPORE_CORE_OPS_LSTM_H_
19 
20 #include <algorithm>
21 #include <map>
22 #include <memory>
23 #include <string>
24 
25 #include "mindapi/base/types.h"
26 #include "ops/base_operator.h"
27 
28 namespace mindspore {
29 namespace ops {
30 constexpr auto kNameLSTM = "LSTM";
31 /// \brief Performs the Long Short-Term Memory (LSTM) on the input.
32 /// Refer to Python API @ref mindspore.ops.LSTM for more details.
33 class MIND_API LSTM : public BaseOperator {
34  public:
35   MIND_API_BASE_MEMBER(LSTM);
36   /// \brief Constructor.
LSTM()37   LSTM() : BaseOperator(kNameLSTM) {}
38   /// \brief Init. Refer to the parameters of Python API @ref mindspore.ops.LSTM for the inputs.
39   void Init(const int64_t input_size, const int64_t hidden_size, const int64_t num_layers, const bool has_bias,
40             const float dropout, const bool bidirectional = false, const float zoneout_cell = 0.0f,
41             const float zoneout_hidden = 0.0f);
42   /// \brief Set input_size.
43   void set_input_size(const int64_t input_size);
44   /// \brief Get input_size.
45   ///
46   /// \return input_size.
47   int64_t get_input_size() const;
48   /// \brief Set hidden_size.
49   void set_hidden_size(const int64_t hidden_size);
50   /// \brief Get hidden_size.
51   ///
52   /// \return hidden_size.
53   int64_t get_hidden_size() const;
54   /// \brief Set proj_size.
55   void set_proj_size(const int64_t proj_size);
56   /// \brief Get proj_size.
57   ///
58   /// \return proj_size.
59   int64_t get_proj_size() const;
60   /// \brief Set num_layers.
61   void set_num_layers(const int64_t num_layers);
62   /// \brief Get num_layers.
63   ///
64   /// \return num_layers.
65   int64_t get_num_layers() const;
66   /// \brief Set has_bias.
67   void set_has_bias(const bool has_bias);
68   /// \brief Get has_bias.
69   ///
70   /// \return has_bias.
71   bool get_has_bias() const;
72   /// \brief Set dropout.
73   void set_dropout(const float dropout);
74   /// \brief Get dropout.
75   ///
76   /// \return dropout.
77   float get_dropout() const;
78   /// \brief Set bidirectional.
79   void set_bidirectional(const bool bidirectional);
80   /// \brief Get bidirectional.
81   ///
82   /// \return bidirectional.
83   bool get_bidirectional() const;
84   /// \brief Set num_directions.
85   void set_num_directions(const int64_t num_directions);
86   /// \brief Get num_directions.
87   ///
88   /// \return num_directions.
89   int64_t get_num_directions() const;
90   /// \brief Set zoneout_cell.
91   void set_zoneout_cell(float zoneout_cell);
92   /// \brief Get zoneout_cell.
93   ///
94   /// \return zoneout_cell.
95   float get_zoneout_cell() const;
96   /// \brief Set zoneout_hidden.
97   void set_zoneout_hidden(float zoneout_hidden);
98   /// \brief Get zoneout_hidden.
99   ///
100   /// \return zoneout_hidden.
101   float get_zoneout_hidden() const;
102   /// \brief Get good_ld.
103   ///
104   /// \return good_ld.
105   int64_t get_good_ld(const int64_t dim, const int64_t type_size);
106 };
107 }  // namespace ops
108 }  // namespace mindspore
109 
110 #endif  // MINDSPORE_CORE_OPS_LSTM_H_
111