shl_node.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (C) 2016-2022 T-Head Semiconductor Co., Ltd. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the License); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. /* CSI-NN2 version 2.0.x */
  19. #ifndef INCLUDE_SHL_NODE_H_
  20. #define INCLUDE_SHL_NODE_H_
  21. struct shl_node {
  22. int type;
  23. struct shl_node **in;
  24. struct shl_node **out;
  25. int subgraph_idx;
  26. int in_num;
  27. int out_num;
  28. char *name;
  29. void *data;
  30. int ref_count;
  31. int ref_count_init;
  32. int visited;
  33. int *restricted_map;
  34. int restricted_map_num;
  35. };
  36. /* node */
  37. struct shl_node *shl_node_alloc(int node_type, char *name, int in_num, int out_num, void *data);
  38. struct shl_node *shl_node_var_alloc(char *name, void *data);
  39. struct shl_node *shl_node_const_var_alloc(char *name, void *data);
  40. int shl_node_free(struct shl_node *node);
  41. int shl_node_add_in(struct shl_node *node, struct shl_node *in, int index);
  42. int shl_node_add_out(struct shl_node *node, struct shl_node *out, int index);
  43. int shl_node_get_in_number(struct shl_node *node);
  44. int shl_node_get_out_number(struct shl_node *node);
  45. int shl_node_get_non_const_in_number(struct shl_node *node);
  46. struct shl_node *shl_node_get_in(struct shl_node *node, int index);
  47. struct shl_node *shl_node_get_out(struct shl_node *node, int index);
  48. int shl_node_restrict_map_insert(int value, struct shl_node *node);
  49. int shl_node_find(struct shl_node **list, int len, struct shl_node *node);
  50. #endif // INCLUDE_SHL_NODE_H_