pytorch

Форк
0
/
predictor_verifier.cc 
57 строк · 1.9 Кб
1
/**
2
 * Copyright (c) 2016-present, Facebook, Inc.
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

17
#include "caffe2/core/flags.h"
18
#include "caffe2/core/init.h"
19
#include "caffe2/predictor/predictor.h"
20
#include "caffe2/utils/proto_utils.h"
21

22
C10_DEFINE_string(init_net, "", "The given path to the init protobuffer.");
23
C10_DEFINE_string(
24
    predict_net,
25
    "",
26
    "The given path to the predict protobuffer.");
27

28
namespace caffe2 {
29

30
void run() {
31
  if (FLAGS_init_net.empty()) {
32
    LOG(FATAL) << "No init net specified. Use --init_net=/path/to/net.";
33
  }
34
  if (FLAGS_predict_net.empty()) {
35
    LOG(FATAL) << "No predict net specified. Use --predict_net=/path/to/net.";
36
  }
37
  caffe2::NetDef init_net, predict_net;
38
  CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net, &init_net));
39
  CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net, &predict_net));
40
  // Can be large due to constant fills
41
  VLOG(1) << "Init net: " << ProtoDebugString(init_net);
42
  LOG(INFO) << "Predict net: " << ProtoDebugString(predict_net);
43
  auto predictor = std::make_unique<Predictor>(init_net, predict_net);
44
  LOG(INFO) << "Checking that a null forward-pass works";
45
  Predictor::TensorList inputVec, outputVec;
46
  (*predictor)(inputVec, &outputVec);
47
  CAFFE_ENFORCE_GT(outputVec.size(), 0);
48
}
49
}
50

51
int main(int argc, char** argv) {
52
  caffe2::GlobalInit(&argc, &argv);
53
  caffe2::run();
54
  // This is to allow us to use memory leak checks.
55
  caffe2::ShutdownProtobufLibrary();
56
  return 0;
57
}
58

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.