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.

test_relu.cpp 1.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Tencent is pleased to support the open source community by making ncnn available.
  2. //
  3. // Copyright (C) 2019 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 "testutil.h"
  15. #include "layer/relu.h"
  16. static int test_relu(float slope, bool use_packing_layout)
  17. {
  18. ncnn::Mat a = RandomMat(6, 7, 8);
  19. ncnn::ParamDict pd;
  20. pd.set(0, slope);//slope
  21. std::vector<ncnn::Mat> weights(0);
  22. ncnn::ModelBinFromMatArray mb(weights.data());
  23. ncnn::Option opt;
  24. opt.num_threads = 1;
  25. opt.use_vulkan_compute = true;
  26. opt.use_fp16_packed = false;
  27. opt.use_fp16_storage = false;
  28. opt.use_fp16_arithmetic = false;
  29. opt.use_int8_storage = false;
  30. opt.use_int8_arithmetic = false;
  31. opt.use_packing_layout = use_packing_layout;
  32. int ret = test_layer<ncnn::ReLU>("ReLU", pd, mb, opt, a);
  33. if (ret != 0)
  34. {
  35. fprintf(stderr, "test_relu failed slope=%f use_packing_layout=%d\n", slope, use_packing_layout);
  36. }
  37. return ret;
  38. }
  39. static int test_relu_0()
  40. {
  41. return 0
  42. || test_relu(0.f, false)
  43. || test_relu(0.1f, false)
  44. || test_relu(0.f, true)
  45. || test_relu(0.1f, true)
  46. ;
  47. }
  48. int main()
  49. {
  50. SRAND(7767517);
  51. return test_relu_0();
  52. }