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.

fake_quant.h 1.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * \file dnn/test/common/fake_quant.h
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2021 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
  10. * implied.
  11. */
  12. #pragma once
  13. #include "megdnn/basic_types.h"
  14. #include "megdnn/opr_param_defs.h"
  15. namespace megdnn {
  16. namespace test {
  17. namespace fake_quant {
  18. struct TestArg {
  19. param::FakeQuant param;
  20. TensorShape ishape;
  21. TensorShape scale_shape;
  22. TensorShape zeropoint_shape;
  23. TestArg(param::FakeQuant param, TensorShape ishape, TensorShape scale_shape,
  24. TensorShape zeropoint_shape)
  25. : param(param),
  26. ishape(ishape),
  27. scale_shape(scale_shape),
  28. zeropoint_shape(zeropoint_shape) {}
  29. };
  30. inline std::vector<TestArg> get_args() {
  31. std::vector<TestArg> args;
  32. param::FakeQuant cur_param;
  33. cur_param.qmin = -128;
  34. cur_param.qmax = 128;
  35. for (size_t i = 10; i < 40; i += 2) {
  36. args.emplace_back(cur_param, TensorShape{10, 64, i, i}, TensorShape{1},
  37. TensorShape{1});
  38. }
  39. for (size_t m : {1, 10})
  40. for (size_t n : {1, 10})
  41. for (size_t j : {1, 10})
  42. for (size_t k : {1, 10}) {
  43. args.emplace_back(cur_param, TensorShape{10, 64, 10, 10},
  44. TensorShape{10, 64, m, n},
  45. TensorShape{10, 64, j, k});
  46. }
  47. return args;
  48. }
  49. } // namespace fake_quant
  50. } // namespace test
  51. } // namespace megdnn

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