26 #ifndef MXNET_OP_ATTR_TYPES_H_    27 #define MXNET_OP_ATTR_TYPES_H_    29 #include <mshadow/tensor.h>    30 #include <nnvm/op_attr_types.h>    42 using nnvm::NodeAttrs;
    80   template<
typename xpu>
   126   template<
typename T, 
typename... Args>
   129     ret.ptr_ = std::make_shared<OpState>();
   131     ret.ptr_->state_.construct<T>(std::forward<Args>(args)...);
   142     return dmlc::get<T>(ptr_->state_);
   149   explicit operator bool()
 const {
   150     return ptr_ ? 
true : 
false;
   157     OpState(
const OpState& other) = 
delete;
   158     OpState& operator=(
const OpState& other) = 
delete;
   168   std::shared_ptr<OpState> ptr_;
   185                                                  const std::vector<TShape>& in_shape,
   186                                                  const std::vector<int>& in_type)>;
   190 using FExecType = std::function<ExecType (const NodeAttrs& attrs)>;
   200                                              const std::vector<TBlob>& inputs,
   201                                              const std::vector<OpReqType>& req,
   202                                              const std::vector<TBlob>& outputs)>;
   212                                                const std::vector<NDArray>& inputs,
   213                                                const std::vector<OpReqType>& req,
   214                                                const std::vector<NDArray>& outputs)>;
   221   std::vector<ResourceRequest> (
const NodeAttrs& n)>;
   228                                              const std::vector<NDArray>& inputs,
   229                                              std::vector<NDArray>* outputs)>;
   235 using FCompute = std::function<void (
const nnvm::NodeAttrs& attrs,
   237                                      const std::vector<TBlob>& inputs,
   238                                      const std::vector<OpReqType>& req,
   239                                      const std::vector<TBlob>& outputs)>;
   246 using FComputeEx = std::function<void (
const nnvm::NodeAttrs& attrs,
   248                                        const std::vector<NDArray>& inputs,
   249                                        const std::vector<OpReqType>& req,
   250                                        const std::vector<NDArray>& outputs)>;
   261                                               std::vector<int>* in_attrs,
   262                                               std::vector<int>* out_attrs)>;
   266 #endif  // MXNET_OP_ATTR_TYPES_H_ std::function< void(const OpStatePtr &state, const OpContext &ctx, const std::vector< TBlob > &inputs, const std::vector< OpReqType > &req, const std::vector< TBlob > &outputs)> FStatefulCompute
Resiger a compute function for stateful operator. OpStatePtr is a pointer type, it's content is mutab...
Definition: op_attr_types.h:202
 
void reset()
Definition: op_attr_types.h:145
 
Forward/Backward are synchronize calls. 
 
Engine that schedules all the operations according to dependency. 
 
no operation, do not write anything 
Definition: op_attr_types.h:47
 
write gradient to provided space 
Definition: op_attr_types.h:49
 
namespace of mxnet 
Definition: base.h:127
 
std::function< std::vector< ResourceRequest >(const NodeAttrs &n)> FResourceRequest
The resource request from the operator. 
Definition: op_attr_types.h:221
 
std::function< void(const OpStatePtr &state, const OpContext &ctx, const std::vector< NDArray > &inputs, const std::vector< OpReqType > &req, const std::vector< NDArray > &outputs)> FStatefulComputeEx
Resiger a compute function for stateful operator using NDArray interface. OpStatePtr is a pointer typ...
Definition: op_attr_types.h:214
 
mshadow::Stream< xpu > * get_stream() const 
get mshadow stream from Context 
Definition: base.h:266
 
Asynchronous function call. 
 
engine::VarHandle get_var() const 
Definition: op_attr_types.h:136
 
Cross device copy operation, this is a special operator That indicates copy across devices...
 
execution time context. The information needed in runtime for actual execution. 
Definition: base.h:253
 
DispatchMode
the dispatch mode of the operator 
Definition: op_attr_types.h:105
 
T & get_state() const 
Definition: op_attr_types.h:141
 
engine::CallbackOnComplete async_on_complete
the callback when operation completes, used by asynchronize ops 
Definition: op_attr_types.h:72
 
std::function< OpStatePtr(const NodeAttrs &attrs, Context ctx, const std::vector< TShape > &in_shape, const std::vector< int > &in_type)> FCreateOpState
Create a Layer style, forward/backward operator. This is easy to write code that contains state...
Definition: op_attr_types.h:186
 
All the possible information needed by Operator.Forward and Backward This is the superset of RunConte...
Definition: op_attr_types.h:66
 
int is_train
whether it is training phase 
Definition: op_attr_types.h:68
 
std::function< ExecType(const NodeAttrs &attrs)> FExecType
Execution mode of this operator. 
Definition: op_attr_types.h:190
 
virtual VarHandle NewVariable()=0
Allocate a new variable, the variable can then be used to schedule the operation concurrently via dep...
 
static OpStatePtr Create(Args &&...args)
Definition: op_attr_types.h:127
 
std::function< void(const nnvm::NodeAttrs &attrs, const std::vector< NDArray > &inputs, std::vector< NDArray > *outputs)> FNDArrayFunction
Register an operator called as a NDArray function. 
Definition: op_attr_types.h:229
 
Global resource allocation handling. 
 
virtual void DeleteVariable(SyncFn delete_fn, Context exec_ctx, VarHandle var)=0
Schedule the deletion of a variable. 
 
Var * VarHandle
Variable pointer type, usually hold by user used to specify dependencies. 
Definition: engine.h:47
 
perform an inplace write, Target shares memory with one of input arguments. This option only happen w...
Definition: op_attr_types.h:55
 
OpReqType
operation request type to Forward and Backward 
Definition: op_attr_types.h:45
 
std::function< void(const nnvm::NodeAttrs &attrs, const OpContext &ctx, const std::vector< NDArray > &inputs, const std::vector< OpReqType > &req, const std::vector< NDArray > &outputs)> FComputeEx
Resiger an NDArray compute function for simple stateless forward only operator. 
Definition: op_attr_types.h:250
 
std::vector< Resource > requested
Resources requested by the operator. 
Definition: op_attr_types.h:74
 
RunContext run_ctx
RunContext related resources. 
Definition: op_attr_types.h:70
 
static Context CPU(int32_t dev_id=0)
 
std::function< void(const nnvm::NodeAttrs &attrs, const OpContext &ctx, const std::vector< TBlob > &inputs, const std::vector< OpReqType > &req, const std::vector< TBlob > &outputs)> FCompute
Resiger a compute function for simple stateless forward only operator. 
Definition: op_attr_types.h:239
 
OnComplete Callback to the engine, called by AsyncFn when action completes. 
Definition: engine.h:56
 
std::function< bool(const NodeAttrs &attrs, const int dev_mask, DispatchMode *dispatch_mode, std::vector< int > *in_attrs, std::vector< int > *out_attrs)> FInferStorageType
Resiger a storage and dispatch mode inference function based on storage types of the inputs and outpu...
Definition: op_attr_types.h:262
 
add to the provided space 
Definition: op_attr_types.h:57
 
ExecType
the execution type of the operator 
Definition: op_attr_types.h:87
 
Context information about the execution environment. 
Definition: base.h:142
 
mshadow::Stream< xpu > * get_stream() const 
get mshadow stream from Context 
Definition: op_attr_types.h:81
 
Operator state. This is a pointer type, its content is mutable even if OpStatePtr is const...
Definition: op_attr_types.h:121