/usr/local/lib64/python3.6/site-packages/torch/include/caffe2/sgd
NameSizeModeActions
adadelta_op.h58520644editdlrm
adagrad_fused.h166320644editdlrm
adagrad_op.h179930644editdlrm
adam_op.h261650644editdlrm
clip_tensor_op.h18530644editdlrm
decay_adagrad_op.h32150644editdlrm
fp16_momentum_sgd_op.h22920644editdlrm
fp32_momentum_sgd_op.h20150644editdlrm
ftrl_op.h22190644editdlrm
gftrl_op.h10280644editdlrm
iter_op.h33790644editdlrm
lars_op.h24790644editdlrm
learning_rate_adaption_op.h19740644editdlrm
learning_rate_functors.h151350644editdlrm
learning_rate_op.h126960644editdlrm
math_lp.h6550644editdlrm
momentum_sgd_op.h60350644editdlrm
rmsprop_op.h19800644editdlrm
rowwise_adagrad_fused.h295950644editdlrm
rowwise_counter.h20830644editdlrm
storm_op.h59150644editdlrm
weight_scale_op.h25520644editdlrm
wngrad_op.h72720644editdlrm
yellowfin_op.h102840644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/caffe2/sgd/rowwise_counter.h (2083B)
#pragma once #include "caffe2/core/operator.h" namespace caffe2 { class RowWiseCounterOp final : public Operator { public: RowWiseCounterOp(const OperatorDef& operator_def, Workspace* ws) : Operator(operator_def, ws), counter_halflife_( this->template GetSingleArgument("counter_halflife", -1)), counter_neg_log_rho_(0.0) { if (counter_halflife_ > 0) { counter_neg_log_rho_ = std::log(2.0) / counter_halflife_; } } bool RunOnDevice() override { CAFFE_ENFORCE_EQ(Input(PREV_ITER).numel(), Input(COUNTER).numel()); CAFFE_ENFORCE_EQ(Input(ITER).numel(), 1); return DispatchHelper>::call( this, Input(INDICES)); } template bool DoRunWithType() { auto* prev_iter = Output(OUTPUT_PREV_ITER)->template mutable_data(); auto* counter = Output(OUTPUT_COUNTER)->template mutable_data(); const int64_t curr_iter = Input(ITER).template data()[0]; const auto* indices = Input(INDICES).template data(); auto n = Input(INDICES).numel(); if (n == 0) { return true; } if (counter_halflife_ <= 0) { return true; } for (auto i = 0; i < n; ++i) { const std::size_t idx = indices[i]; CAFFE_ENFORCE_GE( Input(COUNTER).numel(), idx, this->debug_def().input(COUNTER), ", out of bound, idx:", idx, " for input i:", i, " max size:", Input(COUNTER).numel()); const int64_t iter_delta = std::max(0, curr_iter - prev_iter[idx]); counter[idx] = 1.0 + std::exp(-iter_delta * counter_neg_log_rho_) * counter[idx]; prev_iter[idx] = std::max(curr_iter, prev_iter[idx]); } return true; } protected: int64_t counter_halflife_; double counter_neg_log_rho_; INPUT_TAGS(PREV_ITER, COUNTER, INDICES, ITER); OUTPUT_TAGS(OUTPUT_PREV_ITER, OUTPUT_COUNTER); }; } // namespace caffe2