ONE - On-device Neural Engine
Loading...
Searching...
No Matches
mir_caffe2 Namespace Reference

Data Structures

class  Caffe2OpCreator
 

Typedefs

using RepArgument = const ::google::protobuf::RepeatedPtrField<::caffe2::Argument > &
 

Enumerations

enum class  SupportedCaffe2OpType {
  add , averagePool , clip , concat ,
  conv , constantFill , dropout , FC ,
  givenTensorFill , givenTensorInt64Fill , maxPool , mul ,
  relu , reshape , resizeNearest , sigmoid ,
  softmax , spatialBN , sum
}
 

Functions

std::unique_ptr< mir::GraphloadModel (std::string predict_net, std::string init_net, const std::vector< std::vector< int > > &input_shapes)
 
const ::caffe2::Argument & findArgumentByName (RepArgument args, const std::string &name)
 
bool hasArgument (RepArgument args, const std::string &name)
 
int getSingleArgument (const ::caffe2::OperatorDef &op, const std::string &argument_name, const int default_value)
 
float getSingleArgument (const ::caffe2::OperatorDef &op, const std::string &argument_name, const float default_value)
 
std::string getSingleArgument (const ::caffe2::OperatorDef &op, const std::string &argument_name, const std::string &default_value)
 

Typedef Documentation

◆ RepArgument

using mir_caffe2::RepArgument = typedef const ::google::protobuf::RepeatedPtrField<::caffe2::Argument> &

Definition at line 25 of file caffe2_proto_helper.h.

Enumeration Type Documentation

◆ SupportedCaffe2OpType

Enumerator
add 
averagePool 
clip 
concat 
conv 
constantFill 
dropout 
FC 
givenTensorFill 
givenTensorInt64Fill 
maxPool 
mul 
relu 
reshape 
resizeNearest 
sigmoid 
softmax 
spatialBN 
sum 

Definition at line 23 of file caffe2_op_types.h.

Function Documentation

◆ findArgumentByName()

const ::caffe2::Argument & mir_caffe2::findArgumentByName ( RepArgument  args,
const std::string &  name 
)

Definition at line 22 of file caffe2_proto_helper.cpp.

23{
24 for (auto &arg : args)
25 if (arg.name() == name)
26 return arg;
27 throw std::runtime_error("Can't find argument with name: " + name);
28}

Referenced by getSingleArgument(), getSingleArgument(), and getSingleArgument().

◆ getSingleArgument() [1/3]

float mir_caffe2::getSingleArgument ( const ::caffe2::OperatorDef &  op,
const std::string &  argument_name,
const float  default_value 
)

Definition at line 46 of file caffe2_proto_helper.cpp.

48{
49 if (hasArgument(op.arg(), argument_name))
50 return findArgumentByName(op.arg(), argument_name).f();
51 return default_value;
52}
const ::caffe2::Argument & findArgumentByName(RepArgument args, const std::string &name)
bool hasArgument(RepArgument args, const std::string &name)

References findArgumentByName(), and hasArgument().

◆ getSingleArgument() [2/3]

int mir_caffe2::getSingleArgument ( const ::caffe2::OperatorDef &  op,
const std::string &  argument_name,
const int  default_value 
)

◆ getSingleArgument() [3/3]

std::string mir_caffe2::getSingleArgument ( const ::caffe2::OperatorDef &  op,
const std::string &  argument_name,
const std::string &  default_value 
)

Definition at line 54 of file caffe2_proto_helper.cpp.

56{
57 if (hasArgument(op.arg(), argument_name))
58 return findArgumentByName(op.arg(), argument_name).s();
59 return default_value;
60}

References findArgumentByName(), and hasArgument().

◆ hasArgument()

bool mir_caffe2::hasArgument ( RepArgument  args,
const std::string &  name 
)

Definition at line 30 of file caffe2_proto_helper.cpp.

31{
32 for (auto &arg : args)
33 if (arg.name() == name)
34 return true;
35 return false;
36}

Referenced by mir_caffe2::Caffe2OpCreator::convertConstant(), mir_caffe2::Caffe2OpCreator::convertFC(), getSingleArgument(), getSingleArgument(), and getSingleArgument().

◆ loadModel()

std::unique_ptr< mir::Graph > mir_caffe2::loadModel ( std::string  predict_net,
std::string  init_net,
const std::vector< std::vector< int > > &  input_shapes 
)

Definition at line 336 of file caffe2_importer.cpp.

338{
339 Caffe2Importer importer(std::move(predict_net), std::move(init_net), input_shapes);
340 return importer.importModel();
341}

Referenced by main().