model.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Copyright 2019-2020 Canaan Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. #pragma once
  16. #include "../datatypes.h"
  17. #include "runtime_op.h"
  18. namespace nncase
  19. {
  20. namespace runtime
  21. {
  22. enum model_target : uint32_t
  23. {
  24. MODEL_TARGET_CPU = 0,
  25. MODEL_TARGET_K210 = 1
  26. };
  27. struct model_header
  28. {
  29. uint32_t identifier;
  30. uint32_t version;
  31. uint32_t flags;
  32. model_target target;
  33. uint32_t constants;
  34. uint32_t main_mem;
  35. uint32_t nodes;
  36. uint32_t inputs;
  37. uint32_t outputs;
  38. uint32_t reserved0;
  39. };
  40. constexpr uint32_t MODEL_IDENTIFIER = 'KMDL';
  41. constexpr uint32_t MODEL_VERSION = 4;
  42. struct node_header
  43. {
  44. runtime_opcode opcode;
  45. uint32_t body_size;
  46. };
  47. }
  48. }