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.

memorydata.cpp 1.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Tencent is pleased to support the open source community by making ncnn available.
  2. //
  3. // Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
  4. //
  5. // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
  6. // in compliance with the License. You may obtain a copy of the License at
  7. //
  8. // https://opensource.org/licenses/BSD-3-Clause
  9. //
  10. // Unless required by applicable law or agreed to in writing, software distributed
  11. // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  12. // CONDITIONS OF ANY KIND, either express or implied. See the License for the
  13. // specific language governing permissions and limitations under the License.
  14. #include "memorydata.h"
  15. namespace ncnn {
  16. DEFINE_LAYER_CREATOR(MemoryData)
  17. MemoryData::MemoryData()
  18. {
  19. one_blob_only = true;
  20. support_inplace = true;
  21. }
  22. #if NCNN_STDIO
  23. #if NCNN_STRING
  24. int MemoryData::load_param(FILE* paramfp)
  25. {
  26. int nscan = fscanf(paramfp, "%d %d %d",
  27. &channels, &width, &height);
  28. if (nscan != 3)
  29. {
  30. fprintf(stderr, "MemoryData load_param failed %d\n", nscan);
  31. return -1;
  32. }
  33. return 0;
  34. }
  35. #endif // NCNN_STRING
  36. int MemoryData::load_param_bin(FILE* paramfp)
  37. {
  38. fread(&channels, sizeof(int), 1, paramfp);
  39. fread(&width, sizeof(int), 1, paramfp);
  40. fread(&height, sizeof(int), 1, paramfp);
  41. return 0;
  42. }
  43. #endif // NCNN_STDIO
  44. int MemoryData::load_param(const unsigned char*& mem)
  45. {
  46. channels = *(int*)(mem);
  47. mem += 4;
  48. width = *(int*)(mem);
  49. mem += 4;
  50. height = *(int*)(mem);
  51. mem += 4;
  52. return 0;
  53. }
  54. int MemoryData::forward(const Mat& /*bottom_blob*/, Mat& /*top_blob*/) const
  55. {
  56. return 0;
  57. }
  58. int MemoryData::forward_inplace(Mat& /*bottom_top_blob*/) const
  59. {
  60. return 0;
  61. }
  62. } // namespace ncnn

No Description

Contributors (1)