Caffe
Network Configuration
TensorOp
TensorOp represents a BMNET IR, which is a bridge between front end and back end. it provides lots of member method to set information to or get from it. Below is the prototype:
TensorOp::input_shape_size
Return the number of inputs.
TensorOp::output_shape_size
Return the number of outputs.
TensorOp::input_shape
Return shape of input by index.
TensorOp::output_shape
Return shape of output by index.
TensorOp::add_output_shape
Return a mutable pointer to a new added TensorShape of outputs. The returned TensorShape could be modified latter.
TensorOp::global_input
Return offset of input tensor by index, while it was stored in device memory.
TensorOp::global_output
Return offset of output tensor by index, while it was stored in device memory.
TensorOp::mutable_tg_customized_param
Return a mutable pointer to parameters of customized BMNET IR.
TensorOp::tg_customized_param
Return reference of customized BMNET IR’s paramters.
CustomizedCaffeLayer
CustomizedCaffeLayer is abstract class, which is used to implement a Layer to convert CAFFE Layer into BMNet IR(please refer to Chapter 5 for details about BMNet IR). If you want to introduce a customized CAFFE layer into BMNet, please inherit this class and implement all pure virtual functions of it. The CustomizedCaffeLayer inherits from CaffeLayer/Layer class. Below are the prototypes of them:
CustomizedCaffeLayer::layer_name
Pure virtual function, return type of new added CAFFE layer.
CustomizedCaffeLayer::dump
CustomizedCaffeLayer:: setup
Option. It is used to set sub type of Customized Layer only. Implement by default. If child class will override it, this parent class setup function must be call first.
CustomizedCaffeLayer::codegen
Pure virtual function, is used to setup BMNET IR according to LayerParameter of CAFFE Layer. In this function, you should setup output shape and fill parameters to TensorOp.
CustomizedCaffeLayer::add_output_offset
Protected member method, should be called when setup output offset of Layer’s top.
CustomizedCaffeLayer::layer_
Protected member variable, which is reference of customized CAFFE layer’s LayerParameter.
CustomizedTensorFixedInst
CustomizedTensorFixedInst is abstract class, which is used to implement a Layer to convert BMNET IR into instructions by BMKernel APIs. Please inherit this class and implement all pure virtual functions of it. The CustomizedTensorFixedInst inherits from TensorFixedInst/ TensorInst class. Below are the prototypes of them:
CustomizedTensorFixedInst::inst_name
Pure virtual function, return type of customized BMNET IR.
CustomizedTensorFixedInst::dump
Pure virtual function, is used to print information of BMNET IR.
CustomizedTensorFixedInst::encode
Pure virtual function, is used to convert BMNET IR into instructions using BMKernel APIs.
CustomizedTensorFixedInst::get_global_neuron_base
Protected member method, return the base address, where the neurons are stored in device memory.
CustomizedTensorFixedInst::get_global_weight_base
Protected member method, return the base address, where weight is stored in device memory.
CustomizedTensorFixedInst::op_
Protected member variable, which is reference of BMNET IR.
TGCustomizedParamter
TGCustomizedParamter represents a customized BMNET IR’s parameters. It provides member methods to set parameters to or get from it. Below is the prototype:
TGCustomizedParamter::i32_param_size
Return the number of int parameters, which stored in TGCustomizedParamter.
TGCustomizedParamter::f32_param_size
Return the number of float parameters, which stored in TGCustomizedParamter.
TGCustomizeParamter::i32_param
Return int parameter by index.
TGCustomizeParamter::f32_param
Return int parameter by index.
TGCustomizeParamter::add_i32_param
Append a new int parameter to TGCustomizedParamter.
TGCustomizeParamter::add_f32_param
Append a new int parameter to TGCustomizedParamter.
TensorShape
TensorShape represents a shape of tensor. Below is the prototype:
TensorShape::dim_size
Return the number of dims.
TensorShape::dim
Return one dim by index.
TensorShape::add_dim
Append a dim to TensorShape.
TensorShape::CopyFrom
Copy from another TensorShape instance.
CaffeBuilder
CaffeBuilder is a class, which provides a uniform interface to combine front end/optimizer/back end core code into one, to compile CAFFE neuron network graph into bmodel file. The CaffeBuilder inherits from Builder class, which is a base compiler class. Below are the prototypes of them:
CaffeBuilder::CaffeBuilder
Constructor function of CaffeBuilder class.
modified_proto are optional parameters, that means you no need to fill all of this parameters. Below combination are valid: 1) caffemodel only; 2) caffemodel, as well as modified_protos
CaffeBuilder::Builder
Core member function of CaffeBuilder class, used to compile the network by specifying input shape and optimization level.
Below are the values for opt.
CaffeBuilder::store_prototxt
store the optimized network graph as a file.
CaffeBuilder::store_model
Store compiled instructions, weight and other information of the network as a bmodel file.
CaffeBuilder::addCustomizedLayer
Register a new added customized layer, which used to convert CAFFE layer into BMNet IR (Intermediate representation).
CaffeBuilder::addCustomizedTensorInst
Register a new added customized TensorInst (Tensor Instruction), which used to convert BMNet IR into instructions.
Last updated