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.

benchmark_tests.cc 2.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * Copyright 2019 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <gtest/gtest.h>
  17. #include <cstdio>
  18. #include <fstream>
  19. #include <memory>
  20. #include <string>
  21. #include "test/test_context.h"
  22. #include "benchmark/benchmark.h"
  23. #define LENET_ARGS 2
  24. #define MS_ARGS 4
  25. namespace mindspore {
  26. namespace predict {
  27. class BenchmarkTest : public ::testing::Test {
  28. protected:
  29. void SetUp() {}
  30. void TearDown() {}
  31. std::string root;
  32. };
  33. TEST_F(BenchmarkTest, BenchmarkRun) {
  34. const char* args[LENET_ARGS];
  35. args[0] = "./benchmark";
  36. args[1] = "--modelPath=./data/lenet/lenet.ms";
  37. int errorcode = mindspore::predict::RunBenchmark(LENET_ARGS, args);
  38. EXPECT_EQ(0, errorcode);
  39. }
  40. TEST_F(BenchmarkTest, LenetRun) {
  41. const char* args[MS_ARGS];
  42. args[0] = "./benchmark";
  43. args[1] = "--modelPath=./data/ms/mindspore.ms";
  44. args[2] = "--inDataPath=./data/ms/mindspore.bin";
  45. args[3] = "--calibDataPath=./data/ms/mindspore.out";
  46. int errorcode = mindspore::predict::RunBenchmark(MS_ARGS, args);
  47. EXPECT_EQ(0, errorcode);
  48. }
  49. TEST_F(BenchmarkTest, MindSporeRun) {
  50. const char* args[4];
  51. args[0] = "./benchmark";
  52. args[1] = "--modelPath=./data/lenet/lenet.ms";
  53. args[2] = "--inDataPath=./data/lenet/lenet.bin";
  54. args[3] = "--calibDataPath=./data/lenet/lenet.out";
  55. int errorcode = mindspore::predict::RunBenchmark(4, args);
  56. EXPECT_EQ(0, errorcode);
  57. }
  58. } // namespace predict
  59. } // namespace mindspore