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.

conv_bias.h 3.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * \file dnn/test/common/conv_bias.h
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
  6. *
  7. * Unless required by applicable law or agreed to in writing,
  8. * software distributed under the License is distributed on an
  9. * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. */
  11. #pragma once
  12. #include "megdnn/basic_types.h"
  13. #include "megdnn/opr_param_defs.h"
  14. #include "test/common/checker.h"
  15. #include "src/fallback/conv_bias/opr_impl.h"
  16. #include <regex>
  17. namespace megdnn {
  18. namespace test {
  19. namespace conv_bias {
  20. struct TestArg {
  21. param::ConvBias param;
  22. TensorShape src, filter, bias;
  23. TestArg(param::ConvBias param, TensorShape src, TensorShape filter,
  24. TensorShape bias)
  25. : param(param), src(src), filter(filter), bias(bias) {}
  26. };
  27. std::vector<TestArg> get_args();
  28. std::vector<TestArg> get_args_1x1();
  29. std::vector<TestArg> get_chanwise_args();
  30. std::vector<TestArg> get_winograd_args(size_t kernel_size);
  31. std::vector<TestArg> get_winograd_mk_packed_args(size_t pack_size = 4);
  32. std::vector<TestArg> get_quantized_winograd_mk_packed_args(
  33. size_t pack_size = 4);
  34. std::vector<TestArg> get_quantized_args_with_nlmode(
  35. param::ConvBias::NonlineMode nlmode);
  36. std::vector<TestArg> get_quantized_args();
  37. std::vector<TestArg> get_int8_nchw4_args(size_t kernel_size);
  38. std::vector<TestArg> get_int8_nchw4_args_check_bounds(size_t kernel_size);
  39. std::vector<TestArg> get_int8_nchw4_small_channel_args(size_t kernel_size);
  40. std::vector<TestArg> get_int8_nchw4_small_channel_args_check_bounds(
  41. size_t kernel_size);
  42. std::vector<TestArg> get_int8_nchw4_args_small_batch(size_t kernel_size);
  43. std::vector<TestArg> get_int8_chwn4_args(size_t kernel_size);
  44. std::vector<TestArg> get_int8_chwn4_args_check_bounds(size_t kernel_size);
  45. std::vector<TestArg> get_int8_chwn4_small_channel_args(size_t kernel_size);
  46. std::vector<TestArg> get_int8_chwn4_small_channel_args_check_bounds(
  47. size_t kernel_size);
  48. std::vector<TestArg> get_int8_chwn4_args_small_batch(size_t kernel_size);
  49. std::vector<TestArg> get_int8_nchw4_tensorcore_args(size_t kernel_size);
  50. std::vector<TestArg> get_int8_chwn4_tensorcore_args(size_t kernel_size);
  51. template <typename Opr>
  52. using ConvBiasAlgoChecker = AlgoChecker<Opr>;
  53. void check_conv_bias(
  54. DType src_dtype, DType filter_dtype, DType bias_dtype, DType dst_dtype,
  55. Handle* handle, const char* algo = nullptr,
  56. param::ConvBias::Format format = param::ConvBias::Format::NCHW4,
  57. const std::vector<TestArg>& args = {});
  58. #if MEGDNN_WITH_BENCHMARK
  59. std::vector<conv_bias::TestArg> get_winograd_benchmark_args(
  60. size_t kernel, size_t pack_size = 1);
  61. void benchmark_winograd(const char* algo_name, megdnn::Handle* handle,
  62. size_t kernel, size_t pack_size = 1);
  63. #endif // MEGDNN_WITH_BENCHMARK
  64. std::vector<megdnn::test::conv_bias::TestArg> get_conv_bias_args(
  65. std::vector<size_t> kernel, size_t stride, bool no_pad, bool no_bias,
  66. bool no_nonlinemode, bool quantized_nlmod = false,
  67. bool only_broadcast_bias = false);
  68. void check_conv_bias(std::vector<megdnn::test::conv_bias::TestArg> args,
  69. megdnn::Handle* handle, const char* algo_name);
  70. void checker_conv_bias_int8x8x16(
  71. std::vector<megdnn::test::conv_bias::TestArg> args,
  72. megdnn::Handle* handle, const char* algo_name);
  73. void winograd_algo_extra_impl(const TensorNDArray& tensors, uint32_t m,
  74. param::ConvBias param, Handle* handle,
  75. param::MatrixMul::Format format);
  76. } // namespace conv_bias
  77. } // namespace test
  78. } // namespace megdnn
  79. // vim: syntax=cpp.doxygen

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台