template <typename T, class Context>
class AveragedLoss final : public SumElementsOp<T, Context> {
public:
- template <class... Args>
- explicit AveragedLoss(Args&&... args)
- : SumElementsOp<T, Context>(std::forward<Args>(args)...) {}
+ AveragedLoss(const OperatorDef& operator_def, Workspace* ws)
+ : SumElementsOp<T, Context>(operator_def, ws, true) {}
~AveragedLoss() {}
};
template <typename T, class Context>
class AveragedLossGradient final : public SumElementsGradientOp<T, Context> {
public:
- template <class... Args>
- explicit AveragedLossGradient(Args&&... args)
- : SumElementsGradientOp<T, Context>(std::forward<Args>(args)...) {}
+ AveragedLossGradient(const OperatorDef& operator_def, Workspace* ws)
+ : SumElementsGradientOp<T, Context>(operator_def, ws, true) {}
~AveragedLossGradient() {}
};
class LpNormOp : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit LpNormOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...),
+ LpNormOp(const OperatorDef& def, Workspace* ws)
+ : Operator<Context>(def, ws),
OP_SINGLE_ARG(int, "p", p_, 2),
OP_SINGLE_ARG(bool, "average", average_, false) {
CAFFE_ENFORCE(p_ == 1 || p_ == 2, "p should be either 1 or 2.");
class LpNormGradientOp : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit LpNormGradientOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...),
+ LpNormGradientOp(const OperatorDef& def, Workspace* ws)
+ : Operator<Context>(def, ws),
OP_SINGLE_ARG(int, "p", p_, 2),
OP_SINGLE_ARG(bool, "average", average_, false) {
CAFFE_ENFORCE(p_ == 1 || p_ == 2, "p should be either 1 or 2.");
template <typename Context>
class LSTMUnitOp : public Operator<Context> {
public:
- template <class... Args>
- explicit LSTMUnitOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...),
- forget_bias_(static_cast<float>(
- this->template GetSingleArgument<float>("forget_bias", 0.0))),
- sequence_lengths_(
- this->template GetSingleArgument<bool>("sequence_lengths", true)),
- drop_states_(
- this->template GetSingleArgument<bool>("drop_states", false)) {}
+ LSTMUnitOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws),
+ forget_bias_(
+ static_cast<float>(this->template GetSingleArgument<float>(
+ "forget_bias",
+ 0.0))),
+ sequence_lengths_(this->template GetSingleArgument<bool>(
+ "sequence_lengths",
+ true)),
+ drop_states_(this->template GetSingleArgument<bool>(
+ "drop_states",
+ false)) {}
USE_OPERATOR_CONTEXT_FUNCTIONS;
using Operator<Context>::Operator;
template <typename Context>
class LSTMUnitGradientOp : public Operator<Context> {
public:
- template <class... Args>
- explicit LSTMUnitGradientOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...),
- forget_bias_(static_cast<float>(
- this->template GetSingleArgument<float>("forget_bias", 0.0))),
- sequence_lengths_(
- this->template GetSingleArgument<bool>("sequence_lengths", true)),
- drop_states_(
- this->template GetSingleArgument<bool>("drop_states", false)) {}
+ LSTMUnitGradientOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws),
+ forget_bias_(
+ static_cast<float>(this->template GetSingleArgument<float>(
+ "forget_bias",
+ 0.0))),
+ sequence_lengths_(this->template GetSingleArgument<bool>(
+ "sequence_lengths",
+ true)),
+ drop_states_(this->template GetSingleArgument<bool>(
+ "drop_states",
+ false)) {}
USE_OPERATOR_CONTEXT_FUNCTIONS;
template <typename T>
class CreateMapOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit CreateMapOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...) {}
+ CreateMapOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws) {}
~CreateMapOp() {}
bool RunOnDevice() override {
class KeyValueToMapOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit KeyValueToMapOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...) {}
+ KeyValueToMapOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws) {}
~KeyValueToMapOp() {}
bool RunOnDevice() override {
class MapToKeyValueOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit MapToKeyValueOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...) {}
+ MapToKeyValueOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws) {}
~MapToKeyValueOp() {}
bool RunOnDevice() override {
template <class Context>
class MarginRankingCriterionOp final : public Operator<Context> {
public:
- template <class... Args>
- explicit MarginRankingCriterionOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...),
+ MarginRankingCriterionOp(const OperatorDef& def, Workspace* ws)
+ : Operator<Context>(def, ws),
OP_SINGLE_ARG(float, "margin", margin_, 1.0) {}
USE_OPERATOR_CONTEXT_FUNCTIONS;
template <class Context>
class MarginRankingCriterionGradientOp final : public Operator<Context> {
public:
- template <class... Args>
- explicit MarginRankingCriterionGradientOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...),
+ MarginRankingCriterionGradientOp(const OperatorDef& def, Workspace* ws)
+ : Operator<Context>(def, ws),
OP_SINGLE_ARG(float, "margin", margin_, 1.0) {}
USE_OPERATOR_CONTEXT_FUNCTIONS;
class MatMulOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit MatMulOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...),
+ MatMulOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws),
axis_a_(this->template GetSingleArgument<int>("axis_a", 1)),
axis_b_(this->template GetSingleArgument<int>("axis_b", 1)),
trans_a_(this->template GetSingleArgument<int>("trans_a", 0)),
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit MeanGradientOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...) {}
+ MeanGradientOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws) {}
template <typename T>
bool DoRunWithType() {
class GetGPUMemoryUsageOp final : public Operator<CUDAContext> {
public:
- template<class... Args> explicit GetGPUMemoryUsageOp(Args&&... args)
- : Operator<CUDAContext>(std::forward<Args>(args)...) {}
+ GetGPUMemoryUsageOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<CUDAContext>(operator_def, ws) {}
~GetGPUMemoryUsageOp() override {}
bool RunOnDevice() override {
template <typename T, class Context>
class MaxGradientOp final : public SelectGradientOpBase<T, Context> {
public:
- template <class... Args>
- explicit MaxGradientOp(Args&&... args)
- : SelectGradientOpBase<T, Context>(std::forward<Args>(args)...) {}
+ MaxGradientOp(const OperatorDef& operator_def, Workspace* ws)
+ : SelectGradientOpBase<T, Context>(operator_def, ws) {}
~MaxGradientOp() = default;
};
template <typename T, class Context>
class MinGradientOp final : public SelectGradientOpBase<T, Context> {
public:
- template <class... Args>
- explicit MinGradientOp(Args&&... args)
- : SelectGradientOpBase<T, Context>(std::forward<Args>(args)...) {}
+ MinGradientOp(const OperatorDef& operator_def, Workspace* ws)
+ : SelectGradientOpBase<T, Context>(operator_def, ws) {}
~MinGradientOp() = default;
};
class ModOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit ModOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...) {
+ ModOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws) {
divisor_ = this->template GetSingleArgument<int64_t>("divisor", 0);
CAFFE_ENFORCE_NE(divisor_, 0, "divisor must not be 0");
sign_follow_divisor_ =
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit MomentsOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...),
+ MomentsOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws),
axes_(this->template GetRepeatedArgument<int>("axes")),
OP_SINGLE_ARG(bool, "keepdims", keep_dims_, true) {}
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit MomentsGradientOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...),
+ MomentsGradientOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws),
axes_(this->template GetRepeatedArgument<int>("axes")) {}
bool RunOnDevice() override {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit NGramFromCategoricalOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...),
+ NGramFromCategoricalOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws),
col_ids_(this->template GetRepeatedArgument<int>("col_ids")),
categorical_limits_(
this->template GetRepeatedArgument<int>("categorical_limits")),
class NormalizeOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit NormalizeOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...) {}
+ NormalizeOp(const OperatorDef& def, Workspace* ws)
+ : Operator<Context>(def, ws) {}
bool RunOnDevice() override {
const auto& x = Input(0);
class NormalizeGradientOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit NormalizeGradientOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...) {}
+ NormalizeGradientOp(const OperatorDef& def, Workspace* ws)
+ : Operator<Context>(def, ws) {}
bool RunOnDevice() override {
const auto& x = Input(0);
class NumpyTileOp : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit NumpyTileOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...) {}
+ NumpyTileOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws) {}
~NumpyTileOp() {}
bool RunOnDevice() override {
class SegmentOneHotOp : public Operator<CPUContext> {
public:
- template <class... Args>
- explicit SegmentOneHotOp(Args&&... args)
- : Operator(std::forward<Args>(args)...) {}
+ SegmentOneHotOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator(operator_def, ws) {}
bool RunOnDevice() override {
auto& lengths = Input(0);
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit OneHotOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...) {}
+ OneHotOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws) {}
bool RunOnDevice() override {
auto& indices = Input(0);
class BatchOneHotOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit BatchOneHotOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...) {}
+ BatchOneHotOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws) {}
bool RunOnDevice() override {
return DispatchHelper<TensorTypes<int32_t, int64_t>>::call(this, Input(X));
class BatchBucketOneHotOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit BatchBucketOneHotOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...) {}
+ BatchBucketOneHotOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws) {}
bool RunOnDevice() override;
template <class Context>
class ONNXWhileOp final : public Operator<Context> {
public:
- explicit ONNXWhileOp(const OperatorDef& operator_def, Workspace* ws)
+ ONNXWhileOp(const OperatorDef& operator_def, Workspace* ws)
: Operator<Context>(operator_def, ws),
parent_ws_(ws),
has_trip_count_(
this->template GetSingleArgument<int64_t>("has_trip_count", 0)),
has_cond_(this->template GetSingleArgument<int64_t>("has_cond", 0)),
- save_scopes_(
- this->template GetSingleArgument<int64_t>("save_scopes", 0)),
- disable_scopes_(
- this->template GetSingleArgument<int64_t>("disable_scopes", 0)),
- num_loop_carried_deps_(this->template GetSingleArgument<int64_t>(
- "num_loop_carried_deps",
- -1)) {
+ save_scopes_(this->template GetSingleArgument<int64_t>("save_scopes", 0)),
+ disable_scopes_(this->template GetSingleArgument<int64_t>("disable_scopes", 0)),
+ num_loop_carried_deps_(this->template GetSingleArgument<int64_t>("num_loop_carried_deps", -1)) {
CAFFE_ENFORCE(
this->template HasSingleArgumentOfType<NetDef>("body"),
"body net must be specified in ONNXWhile operator");
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- explicit OnnxifiOp(const OperatorDef& operator_def, Workspace* ws)
+ OnnxifiOp(const OperatorDef& operator_def, Workspace* ws)
: Operator<Context>(operator_def, ws) {
lib_ = onnx::initOnnxifiLibrary();
backend_graph_map_ptr_ = onnx::getOnnxBackendGraphMap();
class GPUFallbackOpEx final : public Operator<CUDAContext> {
public:
USE_OPERATOR_FUNCTIONS(CUDAContext);
- explicit GPUFallbackOpEx(const OperatorDef& def, Workspace* ws)
+ GPUFallbackOpEx(const OperatorDef& def, Workspace* ws)
: Operator<CUDAContext>(def, ws) {
CAFFE_ENFORCE_EQ(def.device_option().device_type(), PROTO_CUDA);
OperatorDef base_def_(def);
class IncrementByOneOp final : public Operator<CPUContext> {
public:
- template <class... Args>
- explicit IncrementByOneOp(Args&&... args)
- : Operator<CPUContext>(std::forward<Args>(args)...) {}
+ IncrementByOneOp(const OperatorDef& def, Workspace* ws)
+ : Operator<CPUContext>(def, ws) {}
bool RunOnDevice() override {
const auto& in = Input(0);
public:
USE_OPERATOR_FUNCTIONS(CUDAContext);
- template <class... Args>
- explicit CuDNNOrderSwithOpBase(Args&&... args)
- : Operator<CUDAContext>(std::forward<Args>(args)...),
- cudnn_wrapper_(&context_) {
+ CuDNNOrderSwithOpBase(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<CUDAContext>(operator_def, ws), cudnn_wrapper_(&context_) {
CUDNN_ENFORCE(cudnnCreateTensorDescriptor(&X_desc_));
CUDNN_ENFORCE(cudnnCreateTensorDescriptor(&Y_desc_));
}
class CuDNNNHWC2NCHWOp final : public CuDNNOrderSwithOpBase {
public:
- template <class... Args>
- explicit CuDNNNHWC2NCHWOp(Args&&... args)
- : CuDNNOrderSwithOpBase(std::forward<Args>(args)...) {}
+ CuDNNNHWC2NCHWOp(const OperatorDef& operator_def, Workspace* ws)
+ : CuDNNOrderSwithOpBase(operator_def, ws) {}
bool RunOnDevice() override {
return DispatchHelper<TensorTypes<float, at::Half>>::call(this, Input(0));
class CuDNNNCHW2NHWCOp final : public CuDNNOrderSwithOpBase {
public:
- template <class... Args>
- explicit CuDNNNCHW2NHWCOp(Args&&... args)
- : CuDNNOrderSwithOpBase(std::forward<Args>(args)...) {}
+ CuDNNNCHW2NHWCOp(const OperatorDef& operator_def, Workspace* ws)
+ : CuDNNOrderSwithOpBase(operator_def, ws) {}
bool RunOnDevice() override {
return DispatchHelper<TensorTypes<float, at::Half>>::call(this, Input(0));
class PackRNNSequenceOpBase : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
- template <class... Args>
- explicit PackRNNSequenceOpBase(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...) {}
+ PackRNNSequenceOpBase(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws) {}
bool RunOnDevice() override {
return DispatchHelper<TensorTypes<int32_t, int64_t, float, double>>::call(
USE_OPERATOR_CONTEXT_FUNCTIONS;
USE_DISPATCH_HELPER;
- template <class... Args>
- explicit PackSegmentsOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...),
+ PackSegmentsOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws),
max_length_(this->template GetSingleArgument<int>("max_length", -1)),
pad_minf_(this->template GetSingleArgument<bool>("pad_minf", false)),
return_presence_mask_(this->template GetSingleArgument<bool>(
USE_OPERATOR_CONTEXT_FUNCTIONS;
USE_DISPATCH_HELPER;
- template <class... Args>
- explicit UnpackSegmentsOp(Args&&... args)
- : Operator<Context>(std::forward<Args>(args)...),
+ UnpackSegmentsOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<Context>(operator_def, ws),
max_length_(this->template GetSingleArgument<int>("max_length", -1)) {}
bool RunOnDevice() override {
class PadImageOp final : public ConvPoolOpBase<Context> {
public:
USE_CONV_POOL_BASE_FUNCTIONS(Context);
- template <class... Args>
- explicit PadImageOp(Args&&... args)
- : ConvPoolOpBase<Context>(std::forward<Args>(args)...),
+ PadImageOp(const OperatorDef& operator_def, Workspace* ws)
+ : ConvPoolOpBase<Context>(operator_def, ws),
mode_(StringToPadMode(
this->template GetSingleArgument<string>("mode", "constant"))),
value_(static_cast<T>(
class PadImageGradientOp final : public ConvPoolOpBase<Context> {
public:
USE_CONV_POOL_BASE_FUNCTIONS(Context);
- template <class... Args>
- explicit PadImageGradientOp(Args&&... args)
- : ConvPoolOpBase<Context>(std::forward<Args>(args)...),
+ PadImageGradientOp(const OperatorDef& operator_def, Workspace* ws)
+ : ConvPoolOpBase<Context>(operator_def, ws),
mode_(StringToPadMode(
this->template GetSingleArgument<string>("mode", "constant"))) {
CAFFE_ENFORCE(
public:
USE_DISPATCH_HELPER;
USE_OPERATOR_FUNCTIONS(CPUContext);
- template <class... Args>
- explicit GatherByKeyOp(Args&&... args)
- : Operator<CPUContext>(std::forward<Args>(args)...) {}
+ GatherByKeyOp(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<CPUContext>(operator_def, ws) {}
private:
bool RunOnDevice() override {
public:
USE_OPERATOR_FUNCTIONS(CPUContext);
- template <class... Args>
- explicit PartitionOpBase(Args&&... args)
- : Operator<CPUContext>(std::forward<Args>(args)...),
+ PartitionOpBase(const OperatorDef& operator_def, Workspace* ws)
+ : Operator<CPUContext>(operator_def, ws),
OP_SINGLE_ARG(int, "pack_first_input", pack_first_input_, 0) {}
protected:
public:
USE_DISPATCH_HELPER;
- template <class... Args>
- explicit PartitionOp(Args&&... args)
- : PartitionOpBase(std::forward<Args>(args)...) {}
+ PartitionOp(const OperatorDef& operator_def, Workspace* ws)
+ : PartitionOpBase(operator_def, ws) {}
bool RunOnDevice() override {
return DispatchHelper<TensorTypes<int32_t, int64_t>>::call(this, Input(0));
public:
USE_DISPATCH_HELPER;
- template <class... Args>
- explicit LengthsPartitionOp(Args&&... args)
- : PartitionOpBase(std::forward<Args>(args)...) {}
+ LengthsPartitionOp(const OperatorDef& operator_def, Workspace* ws)
+ : PartitionOpBase(operator_def, ws) {}
bool RunOnDevice() override {
return DispatchHelper<TensorTypes<int32_t, int64_t>>::call(this, Input(1));