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.

op.h 1.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Copyright 2019 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 PREDICT_SRC_OP_H_
  17. #define PREDICT_SRC_OP_H_
  18. #include <string>
  19. #include <vector>
  20. #include "include/context.h"
  21. #include "include/tensor.h"
  22. #include "include/errorcode.h"
  23. #include "schema/inner/ms_generated.h"
  24. #define MSPREDICT_API __attribute__((visibility("default")))
  25. namespace mindspore {
  26. namespace predict {
  27. enum OP_ARCH { X86_FP32, X86_INT8, ARM_FP32, ARM_FP16, ARM_INT8, GPU };
  28. struct MSPREDICT_API OpDesc {
  29. OP_ARCH arch;
  30. OpT type;
  31. bool operator<(const OpDesc &dst) const { return (arch < dst.arch) || (type < dst.type); }
  32. };
  33. class MSPREDICT_API OpBase {
  34. public:
  35. OpBase();
  36. virtual ~OpBase();
  37. virtual int Execute(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) = 0;
  38. virtual int Init(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) = 0;
  39. protected:
  40. const OpDesc *desc;
  41. std::string name;
  42. };
  43. typedef OpBase *(*OpCreator)(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs,
  44. const OpDef &opDef, const Context &ctx, const OpDesc &desc);
  45. } // namespace predict
  46. } // namespace mindspore
  47. #endif // PREDICT_SRC_OP_H_