| 174 | class RNNOpModel : public SingleOpModel { |
| 175 | public: |
| 176 | RNNOpModel(int batches, int units, int size, |
| 177 | const TensorType& weights = TensorType_FLOAT32, |
| 178 | const TensorType& recurrent_weights = TensorType_FLOAT32) |
| 179 | : batches_(batches), units_(units), input_size_(size) { |
| 180 | input_ = AddInput(TensorType_FLOAT32); |
| 181 | weights_ = AddInput(weights); |
| 182 | recurrent_weights_ = AddInput(recurrent_weights); |
| 183 | bias_ = AddInput(TensorType_FLOAT32); |
| 184 | hidden_state_ = AddInput(TensorType_FLOAT32, true); |
| 185 | output_ = AddOutput(TensorType_FLOAT32); |
| 186 | SetBuiltinOp( |
| 187 | BuiltinOperator_RNN, BuiltinOptions_RNNOptions, |
| 188 | CreateRNNOptions(builder_, ActivationFunctionType_RELU).Union()); |
| 189 | BuildInterpreter({{batches_, input_size_}, // input tensor |
| 190 | {units_, input_size_}, // weights tensor |
| 191 | {units_, units_}, // recurrent weights tensor |
| 192 | {units_}, // bias tensor |
| 193 | {batches_, units_}}); // hidden state tensor |
| 194 | } |
| 195 | |
| 196 | void SetBias(std::initializer_list<float> f) { PopulateTensor(bias_, f); } |
| 197 |
nothing calls this directly
no test coverage detected