TensorRT/parsers/caffe/caffeWeightFactory/weightType.h源碼研讀

TensorRT/parsers/caffe/caffeWeightFactory/weightType.h源碼研讀

TensorRT/parsers/caffe/caffeWeightFactory/weightType.h

/*
 * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef TRT_CAFFE_PARSER_WEIGHT_TYPE_H
#define TRT_CAFFE_PARSER_WEIGHT_TYPE_H

namespace nvcaffeparser1 
{
enum class WeightType
{
//分三種情況

    // types for convolution, deconv, fully connected
    kGENERIC = 0, // typical weights for the layer: e.g. filter (for conv) or matrix weights (for innerproduct)
    kBIAS = 1,    // bias weights

    // These enums are for BVLCCaffe, which are incompatible with nvCaffe enums below.
    // See batch_norm_layer.cpp in BLVC source of Caffe
    kMEAN = 0,
    kVARIANCE = 1,
    kMOVING_AVERAGE = 2,

    // These enums are for nvCaffe, which are incompatible with BVLCCaffe enums above
    // See batch_norm_layer.cpp in NVidia fork of Caffe
    kNVMEAN = 0,
    kNVVARIANCE = 1,
    //為何跳過2?
    kNVSCALE = 3,
    kNVBIAS = 4
};
} //namespace nvcaffeparser1
#endif //TRT_CAFFE_PARSER_WEIGHT_TYPE_H

這個檔案裡只定義了nvcaffeparser1::WeightType這個enum class,內部共分三種情況,分別是:

  1. 給卷積,反卷積,全連接層提供的
  2. 給BVLCCaffe提供的
  3. 給nvCaffe提供的

由於這三種情況是互斥的,各自有各自的神經網路參數分類方式,所以每種情況的enum值都從0開始。

TensorRT/parsers/caffe/caffeParser/opParsers/parseConv.cpp中是如此使用WeightType的:

/**/ weightFactory(msg.name(), WeightType::kGENERIC)  /**/;
/**/ weightFactory(msg.name(), WeightType::kBIAS) /**/;

enum class

這個檔案中定義了一個enum class,關於enum class,詳見C++ enum class

參考連結

C++ enum class

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值