Caffe2 - C++ API
A deep learning, cross platform ML framework
Public Member Functions | Protected Attributes
caffe2::IDEEPFallbackOp< CPUOp, SkipOutputCopy > Class Template Referencefinal

A templated class to allow one to wrap a CPU operator as an IDEEP operator. More...

#include <operator_fallback_ideep.h>

Inheritance diagram for caffe2::IDEEPFallbackOp< CPUOp, SkipOutputCopy >:
caffe2::IDEEPOperator caffe2::OperatorBase caffe2::Observable< OperatorBase >

Public Member Functions

 USE_IDEEP_DEF_ALIASES ()
 
 USE_IDEEP_OPERATOR_FUNCTIONS ()
 
 IDEEPFallbackOp (const OperatorDef &def, Workspace *ws)
 
bool RunOnDevice () override
 
- Public Member Functions inherited from caffe2::IDEEPOperator
 IDEEPOperator (const OperatorDef &operator_def, Workspace *ws)
 
const ideep::tensor & Input (int index)
 
ideep::tensor * Output (int index)
 
bool Run (int) final
 
void WaitEvent (const Event &ev, int) final
 
void WaitEvents (const std::vector< const Event * > &events, int) final
 
void RecordEvent (const char *err_msg=nullptr) final
 
- Public Member Functions inherited from caffe2::OperatorBase
 OperatorBase (const OperatorDef &operator_def, Workspace *ws)
 
 OperatorBase (const c10::FunctionSchema &schema, std::vector< c10::IValue > inputs, std::vector< at::Tensor > outputs)
 
bool isLegacyOperator () const
 Return true if the operator was instantiated with OperatorDef New operators should be instantiated with FunctionSchema.
 
const c10::FunctionSchemagetFunctionSchema () const
 
bool HasArgument (const string &name) const
 Checks if the operator has an argument of the given name.
 
template<typename T >
T GetSingleArgument (const string &name, const T &default_value) const
 
template<typename T >
bool HasSingleArgumentOfType (const string &name) const
 
template<typename T >
vector< TGetVectorFromIValueList (const c10::IValue &value) const
 
template<typename T >
vector< TGetRepeatedArgument (const string &name, const vector< T > &default_value={}) const
 
template<typename T >
const TInput (int idx)
 
template<typename T >
const TInput (int idx, DeviceType type)
 
template<typename T >
TOutput (int idx)
 
template<typename T >
TOutput (int idx, DeviceType type)
 
Tensor XOutputTensor (int idx, at::IntArrayRef dims, at::TensorOptions options)
 
void SetOutputTensor (int idx, Tensor tensor)
 
Tensor OutputTensorOrUndefined (int idx)
 
TensorOutputTensor (int idx, at::IntArrayRef dims, at::TensorOptions options)
 
TensorOutputTensorCopyFrom (int idx, at::TensorOptions options, const Tensor &src, bool async=false)
 
TensorOutputTensorAlias (int idx, const Tensor &src)
 
template<typename T >
TOutput (int idx, T *allocated)
 
const BlobInputBlob (int idx)
 
BlobOutputBlob (int idx)
 
bool IsInputOutputAlias (int i, int j)
 
template<typename T >
bool InputIsType (int idx)
 
bool InputIsTensorType (int idx, DeviceType device_type)
 
template<typename T >
bool OutputIsType (int idx)
 
bool OutputIsTensorType (int idx, DeviceType type)
 
int InputSize () const
 
int OutputSize () const
 
const vector< const Blob * > & Inputs () const
 
const vector< Blob * > & Outputs ()
 
vector< TensorShape > InputTensorShapes () const
 
void Wait (const OperatorBase &other, int stream_id=-1)
 
virtual void Finish ()
 
virtual bool HasAsyncPart () const
 
virtual bool SupportsAsyncScheduling () const
 
virtual bool RunAsync (int stream_id=0)
 
virtual void AddRelatedBlobInfo (EnforceNotMet *err)
 
const OperatorDef & debug_def () const
 
void set_debug_def (const std::shared_ptr< const OperatorDef > &operator_def)
 
bool has_debug_def () const
 
void RecordLastFailedOpNetPosition ()
 
int net_position () const
 
void set_net_position (int idx)
 
const DeviceOption & device_option () const
 
const Eventevent () const
 
Eventevent ()
 
void ResetEvent ()
 
void DisableEvent ()
 
bool IsEventDisabled () const
 
virtual void SyncDeviceBarrierForObservers ()
 
virtual bool IsStreamFree (int) const
 
const std::string & type () const
 
void annotate_engine (const std::string &engine)
 
const std::string & engine () const
 
void SetExecutorHelper (ExecutorHelper *helper)
 
ExecutorHelperGetExecutorHelper () const
 
std::vector< at::Tensormove_newstyle_outputs ()&&
 
template<>
NetDef GetSingleArgument (const std::string &name, const NetDef &default_value) const
 
template<>
vector< int > GetVectorFromIValueList (const c10::IValue &value) const
 
template<>
vector< float > GetVectorFromIValueList (const c10::IValue &value) const
 
template<>
vector< string > GetVectorFromIValueList (const c10::IValue &value) const
 
- Public Member Functions inherited from caffe2::Observable< OperatorBase >
 Observable (Observable &&)=default
 
Observableoperator= (Observable &&)=default
 
 C10_DISABLE_COPY_AND_ASSIGN (Observable)
 
const ObserverAttachObserver (std::unique_ptr< Observer > observer)
 
std::unique_ptr< ObserverDetachObserver (const Observer *observer_ptr)
 Returns a unique_ptr to the removed observer. More...
 
virtual size_t NumObservers ()
 
void StartAllObservers ()
 
void StopAllObservers ()
 

Protected Attributes

vector< Blob * > local_input_blobs_
 
vector< Blob * > local_output_blobs_
 
vector< bool > output_inplace_
 
vector< bool > input_share_
 
std::unique_ptr< CPUOp > base_op_
 
std::unique_ptr< Workspacelocal_ws_
 
OperatorDef base_def_
 
- Protected Attributes inherited from caffe2::IDEEPOperator
IDEEPContext context_
 
StorageOrder order_
 
- Protected Attributes inherited from caffe2::OperatorBase
std::unique_ptr< Eventevent_
 
- Protected Attributes inherited from caffe2::Observable< OperatorBase >
std::vector< std::unique_ptr< Observer > > observers_list_
 

Additional Inherited Members

- Public Types inherited from caffe2::Observable< OperatorBase >
using Observer = ObserverBase< OperatorBase >
 
- Static Public Attributes inherited from caffe2::OperatorBase
static const int kNoNetPositionSet = -1
 
- Protected Member Functions inherited from caffe2::IDEEPOperator
std::string getErrorMsg ()
 
- Protected Member Functions inherited from caffe2::OperatorBase
void SetEventFinished (const char *err_msg=nullptr)
 
void SetEventFinishedWithException (const char *err_msg=nullptr)
 
std::string getErrorMsg ()
 
 C10_DISABLE_COPY_AND_ASSIGN (OperatorBase)
 

Detailed Description

template<class CPUOp, typename SkipOutputCopy = SkipIndices<>>
class caffe2::IDEEPFallbackOp< CPUOp, SkipOutputCopy >

A templated class to allow one to wrap a CPU operator as an IDEEP operator.

This class can be used when one does not have the IDEEP implementation ready yet for an operator. Essentially, what this op does is to automatically deal with data copy for you. Plausibly, this causes a lot of overhead and is not optimal, so you should use this operator mostly for quick prototyping purpose.

All the input and output of the original operator should be TensorCPU.

Example usage: if you have a class MyMagicOp that is CPU based, and you use the registration code REGISTER_CPU_OPERATOR(MyMagic, MyMagicOp); to register the CPU side, you can create its corresponding IDEEP operator (with performance hits of course) via REGISTER_IDEEP_OPERATOR(MyMagic, IDEEPFallbackOp<MyMagicOp>);

Advanced usage: if you want to have some specific outputs never copied, you can use the SkipOutputCopy template argument to do that. For example, if MyMagic produces two outputs and the first output is always going to live on the CPU, you can do REGISTER_IDEEP_OPERATOR(MyMagic, IDEEPFallbackOp<MyMagicOp, SkipIndices<0>>);

Definition at line 39 of file operator_fallback_ideep.h.


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