You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

opr_impl.h 2.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * \file dnn/src/naive/lstm/opr_impl.h
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
  6. *
  7. * Unless required by applicable law or agreed to in writing, software
  8. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  9. * ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. */
  11. #pragma once
  12. #include "megdnn/oprs.h"
  13. namespace megdnn {
  14. namespace naive {
  15. class LSTMImpl : public LSTM {
  16. public:
  17. using LSTM::LSTM;
  18. void exec(
  19. _megdnn_tensor_in input, _megdnn_tensor_in hx, _megdnn_tensor_in cx,
  20. _megdnn_tensor_in flatten_weights, _megdnn_tensor_out output,
  21. _megdnn_tensor_out hy, _megdnn_tensor_out cy,
  22. _megdnn_tensor_out reserve_space, _megdnn_workspace workspace);
  23. size_t get_workspace_in_bytes(
  24. const TensorLayout& input, const TensorLayout& hx, const TensorLayout& cx,
  25. const TensorLayout& flatten_weights, const TensorLayout& output,
  26. const TensorLayout& hy, const TensorLayout& cy,
  27. const TensorLayout& reserve_space);
  28. size_t get_reserve_size_in_bytes(const TensorLayout& input);
  29. };
  30. class LSTMBackwardImpl : public LSTMBackward {
  31. public:
  32. using LSTMBackward::LSTMBackward;
  33. virtual void exec(
  34. _megdnn_tensor_in x, _megdnn_tensor_in y, _megdnn_tensor_in hx,
  35. _megdnn_tensor_in cx, _megdnn_tensor_in dy, _megdnn_tensor_in dhy,
  36. _megdnn_tensor_in dcy, _megdnn_tensor_in flatten_weights,
  37. _megdnn_tensor_in reserve_space, _megdnn_tensor_out dx,
  38. _megdnn_tensor_out dhx, _megdnn_tensor_out dcx, _megdnn_tensor_out dw,
  39. _megdnn_workspace workspace);
  40. virtual size_t get_workspace_in_bytes(
  41. const TensorLayout& x, const TensorLayout& y, const TensorLayout& hx,
  42. const TensorLayout& cx, const TensorLayout& dy, const TensorLayout& dhy,
  43. const TensorLayout& dcy, const TensorLayout& flatten_weights,
  44. const TensorLayout& reserve_space, const TensorLayout& dx,
  45. const TensorLayout& dhx, const TensorLayout& dcx, const TensorLayout& dw);
  46. };
  47. } // namespace naive
  48. } // namespace megdnn