lstm_op.h 1.6 KB
Newer Older
D
dangqingqing 已提交
1 2
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.

D
dangqingqing 已提交
3 4 5
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
D
dangqingqing 已提交
6

D
dangqingqing 已提交
7
http://www.apache.org/licenses/LICENSE-2.0
D
dangqingqing 已提交
8

D
dangqingqing 已提交
9 10 11 12 13
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
D
dangqingqing 已提交
14 15 16 17 18 19 20 21 22 23 24 25 26

#pragma once
#include "paddle/framework/op_registry.h"

namespace paddle {
namespace operators {

using framework::LoDTensor;
using framework::Tensor;

template <typename Place, typename T>
class LSTMKernel : public framework::OpKernel<T> {
 public:
D
dangqingqing 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
  void Compute(const framework::ExecutionContext& ctx) const override {
    auto* input_t = ctx.Input<framework::LoDTensor>("Input");
    auto* batch_t = ctx.Input<framework::LoDTensor>("Batch");
    auto* bias_t = ctx.Input<framework::LoDTensor>("Bias");
    bool is_reverse = ctx.Attr<bool>("is_reverse");
    LoDTensor2BatchFunctor<Place, T> to_batch(ctx.device_context(), input_t,
                                              batch_t, is_reverse);

    auto in_dims = input_t->dims();
    int frame_size = in_dims[1];

    if (bias_t) {
      auto b = EigenMatrix<T>::From(*bias);
    }
  }
D
dangqingqing 已提交
42 43 44 45 46 47 48 49 50 51
};

template <typename Place, typename T>
class LSTMGradKernel : public framework::OpKernel<T> {
 public:
  void Compute(const framework::ExecutionContext& ctx) const override {}
};

}  // namespace operators
}  // namespace paddle