Tensor Comprehensions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
caffe2::ReferenceImplementationRegistry Class Reference

#include <operator_meta.h>

Classes

class  Register
 

Static Public Member Functions

static void Append (NetDef *net, const OperatorDef &op)
 
static NetDef ConvertNet (const NetDef &net)
 

Private Member Functions

 ReferenceImplementationRegistry ()=delete
 

Static Private Member Functions

static CaffeMap< std::string,
ReferenceImplementation > & 
getMap ()
 

Detailed Description

This is a simple registry for "reference implementations" of operators. The idea is that when we test tc compiled kernels, it is useful to have a vanilla Caffe2 implementation which we can compare the result against.

Logically, the reference implementation registry is a mapping from a tc operator to a Caffe2 NetDef which implements that operator using plain Caffe2 operators. For implementation convenience, what we actually record is a function (ReferenceImplementation) which knows how to take a (tc) operator definition, and translate it into a sequence of caffe2 operator definitions, placing those operators into a pre-existing NetDef. You can see examples of how this works by grepping for TC_REFERENCE_IMPLEMENTATION. In pictorial form, if you have:

  input ---> tc op ---> output
               ^_____ OperatorDef&

then if you pass this OperatorDef& and a partially constructed NetDef of the form (note that this NetDef has equivalently named inputs):

  input --X

then ReferenceImplementation will add the reference implementation for tc to your NetDef.

  input ---> caffe2 op1 ---> caffe2 op2 ---> output

ConvertNet takes an entire NetDef of tc operators, and replaces all of them with reference implementations. ReferenceImplementationRegistry is a singleton for ease of defining implementations.

Constructor & Destructor Documentation

caffe2::ReferenceImplementationRegistry::ReferenceImplementationRegistry ( )
privatedelete

Member Function Documentation

static void caffe2::ReferenceImplementationRegistry::Append ( NetDef *  net,
const OperatorDef &  op 
)
static
static NetDef caffe2::ReferenceImplementationRegistry::ConvertNet ( const NetDef &  net)
static
static CaffeMap<std::string, ReferenceImplementation>& caffe2::ReferenceImplementationRegistry::getMap ( )
staticprivate

The documentation for this class was generated from the following file: