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.

train_session.h 1.5 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #ifndef MINDSPORE_LITE_INCLUDE_TRAIN_SESSION_H_
  17. #define MINDSPORE_LITE_INCLUDE_TRAIN_SESSION_H_
  18. #include <vector>
  19. #include <string>
  20. #include <tuple>
  21. #include <unordered_map>
  22. #include "include/lite_session.h"
  23. #include "include/train_model.h"
  24. namespace mindspore {
  25. namespace session {
  26. class TrainSession : public session::LiteSession {
  27. public:
  28. virtual ~TrainSession() = default;
  29. static TrainSession *CreateSession(lite::Context *context);
  30. virtual int CompileTrainGraph(lite::TrainModel *model) = 0;
  31. virtual void *ExportToBuf(char *buf, size_t *len) const = 0;
  32. virtual void Train() = 0;
  33. bool IsTrain() { return train_mode_ == true; }
  34. virtual void Eval() = 0;
  35. bool IsEval() { return train_mode_ == false; }
  36. protected:
  37. bool train_mode_ = false;
  38. };
  39. } // namespace session
  40. } // namespace mindspore
  41. #endif // MINDSPORE_LITE_INCLUDE_TRAIN_SESSION_H_