repo
stringlengths
1
152
file
stringlengths
14
221
code
stringlengths
501
25k
file_length
int64
501
25k
avg_line_length
float64
20
99.5
max_line_length
int64
21
134
extension_type
stringclasses
2 values
null
pytorch-main/caffe2/quantization/server/activation_distribution_observer.h
#pragma once #include "caffe2/core/observer.h" #include "caffe2/core/operator.h" #include "caffe2/quantization/server/dnnlowp.h" #include "caffe2/quantization/server/dynamic_histogram.h" #include <memory> #include <set> #include <vector> namespace caffe2 { class OutputMinMaxObserver final : public ObserverBase<Oper...
6,736
27.306723
79
h
null
pytorch-main/caffe2/quantization/server/batch_matmul_dnnlowp_op.h
/** * Copyright (c) 2016-present, Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable ...
1,674
30.018519
76
h
null
pytorch-main/caffe2/quantization/server/batch_permutation_dnnlowp_op.h
#pragma once #include "caffe2/operators/copy_op.h" #include "caffe2/quantization/server/dnnlowp_op.h" namespace caffe2 { // FIXME using BatchPermutationFP32Op = CopyOp<CPUContext, CPUContext, CPUContext>; template <typename T> class BatchPermutationDNNLowPOp final : public DNNLowPOp<T, BatchPermutationFP32Op> {...
671
22.172414
75
h
null
pytorch-main/caffe2/quantization/server/caffe2_dnnlowp_utils.h
#pragma once #include "caffe2/core/operator.h" #include "caffe2/quantization/server/dnnlowp.h" #include "caffe2/utils/eigen_utils.h" namespace dnnlowp { /** * Let consumers of op know that qparams the quantization parameter used * for output_index'th output of op. */ void PropagateOutputTensorQuantizationParams( ...
3,209
27.918919
78
h
null
pytorch-main/caffe2/quantization/server/channel_shuffle_dnnlowp_op.h
#pragma once #include "caffe2/operators/channel_shuffle_op.h" #include "caffe2/operators/conv_pool_op_base.h" #include "caffe2/quantization/server/conv_pool_dnnlowp_op_base.h" #include "caffe2/quantization/server/dnnlowp.h" #include "caffe2/quantization/server/dnnlowp_op.h" namespace caffe2 { namespace { template <...
923
23.315789
75
h
null
pytorch-main/caffe2/quantization/server/compute_equalization_scale.h
// Copyright 2004-present Facebook. All Rights Reserved. #pragma once #include "caffe2/quantization/server/caffe2_dnnlowp_utils.h" #include "caffe2/quantization/server/dnnlowp.h" namespace caffe2 { class ComputeEqualizationScaleOp final : public Operator<CPUContext> { public: ComputeEqualizationScaleOp(const Oper...
503
25.526316
76
h
null
pytorch-main/caffe2/quantization/server/concat_dnnlowp_op.h
#pragma once #include "caffe2/operators/concat_split_op.h" #include "caffe2/quantization/server/dnnlowp_op.h" namespace caffe2 { template <typename T> class ConcatDNNLowPOp final : public DNNLowPOp<T, ConcatOp<CPUContext>> { public: ConcatDNNLowPOp(const OperatorDef& operator_def, Workspace* ws); bool RunOnDevi...
722
23.931034
73
h
null
pytorch-main/caffe2/quantization/server/conv_dnnlowp_acc16_op.h
#pragma once #include "caffe2/quantization/server/conv_dnnlowp_op.h" #include "fbgemm/Fbgemm.h" namespace caffe2 { /** * Quantized Conv operator with 16-bit accumulation. * We'll encounter saturation but this will be faster in Intel CPUs */ template <bool ReluFused = false> class ConvDNNLowPAcc16Op final : public...
2,332
30.106667
80
h
null
pytorch-main/caffe2/quantization/server/conv_dnnlowp_op.h
#pragma once #include <fbgemm/Fbgemm.h> #include "caffe2/operators/conv_op.h" #include "caffe2/operators/conv_pool_op_base.h" #include "caffe2/quantization/server/caffe2_dnnlowp_utils.h" #include "caffe2/quantization/server/conv_pool_dnnlowp_op_base.h" #include "caffe2/quantization/server/dnnlowp.h" #include "caffe2/q...
4,060
28.427536
79
h
null
pytorch-main/caffe2/quantization/server/conv_pool_dnnlowp_op_base.h
#pragma once #ifdef _OPENMP #include <omp.h> #endif #include "caffe2/core/tensor_int8.h" #include "caffe2/operators/conv_op_shared.h" #include "caffe2/operators/conv_pool_op_base.h" #include "caffe2/quantization/server/fbgemm_pack_blob.h" #include "caffe2/quantization/server/op_wrapper.h" #ifdef _OPENMP C10_DECLARE_...
8,443
34.037344
86
h
null
pytorch-main/caffe2/quantization/server/conv_relu_op.h
#pragma once #include "caffe2/operators/conv_op.h" #include "caffe2/operators/conv_pool_op_base.h" namespace caffe2 { template <typename T, class Context> class ConvReluOp final : public ConvPoolOpBase<Context> { public: ConvReluOp(const OperatorDef& operator_def, Workspace* ws) : ConvPoolOpBase<Context>(op...
1,080
29.027778
70
h
null
pytorch-main/caffe2/quantization/server/dnnlowp.h
#pragma once #include <algorithm> #include <cassert> #include <cmath> #include <cstdint> #include <limits> #ifdef __x86_64__ #include <immintrin.h> #endif #include <fbgemm/QuantUtils.h> #include "caffe2/quantization/server/dynamic_histogram.h" #include "caffe2/utils/cpuid.h" namespace dnnlowp { using fbgemm::Requ...
6,678
31.580488
80
h
null
pytorch-main/caffe2/quantization/server/dnnlowp_op.h
#pragma once #ifdef _OPENMP #include <omp.h> #endif #include "caffe2/core/operator.h" #include "caffe2/core/tensor_int8.h" #include "caffe2/quantization/server/caffe2_dnnlowp_utils.h" #include "caffe2/quantization/server/dnnlowp.h" #include "caffe2/quantization/server/fbgemm_pack_blob.h" #include "caffe2/quantization...
11,769
35.896552
80
h
null
pytorch-main/caffe2/quantization/server/dnnlowp_partition.h
#pragma once #include <algorithm> #include <cstddef> #include <utility> namespace caffe2 { std::pair<size_t, size_t> Get1DPartition(size_t work, int nthreads, int tid, int work_align = 1); /** * 1D-partition m x n 2D work. * First try partitioning m if m >= nthreads. * Otherwise, each row is partitioned by multi...
690
20.59375
74
h
null
pytorch-main/caffe2/quantization/server/dynamic_histogram.h
#pragma once #include <memory> #include <vector> namespace dnnlowp { /** * bin_width = (max - min)/nbins * ith bin (zero-based indexing) contains [i*bin_width, (i+1)*bin_width) * with an exception that (nbins - 1)th bin contains * [(nbins-1)*bin_width, nbins*bin_width] * */ class Histogram { public: Histogr...
1,901
25.054795
77
h
null
pytorch-main/caffe2/quantization/server/elementwise_dnnlowp_op.h
#pragma once #include "caffe2/core/tensor_int8.h" #include "caffe2/operators/elementwise_ops.h" #include "caffe2/quantization/server/caffe2_dnnlowp_utils.h" #include "caffe2/quantization/server/dnnlowp_op.h" #include "caffe2/quantization/server/sigmoid.h" namespace caffe2 { template <typename T, class Functor> class...
6,252
44.311594
86
h
null
pytorch-main/caffe2/quantization/server/elementwise_linear_dnnlowp_op.h
/** * Copyright (c) 2016-present, Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable ...
1,339
27.510638
77
h
null
pytorch-main/caffe2/quantization/server/fb_fc_packed_op.h
/** * Copyright (c) 2016-present, Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable ...
6,518
27.845133
80
h
null
pytorch-main/caffe2/quantization/server/fbgemm_fp16_pack_op.h
/** * Copyright (c) 2016-present, Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable ...
2,695
29.636364
80
h
null
pytorch-main/caffe2/quantization/server/fbgemm_pack_blob.h
#pragma once #include <memory> #include <fbgemm/Fbgemm.h> #include <caffe2/core/tensor.h> #include "caffe2/quantization/server/dnnlowp.h" namespace caffe2 { /** * Packed weight matrix for DNNLOWP Int8FC operator */ struct Int8FCDNNLowPPackedWeightBlob { std::vector<dnnlowp::TensorQuantizationParams> qparams; ...
1,352
27.1875
79
h
null
pytorch-main/caffe2/quantization/server/fbgemm_pack_matrix_cache.h
#pragma once #include "fbgemm/Fbgemm.h" namespace caffe2 { /** * If there's an existing packed matrix for the same matrix, reuse it. * Create a new one otherwise. This can save memory usage if many threads are * sharing the same weight. */ template <typename ACC_T> std::shared_ptr<fbgemm::PackBMatrix<int8_t, ACC...
537
22.391304
77
h
null
pytorch-main/caffe2/quantization/server/fbgemm_pack_op.h
#pragma once #include "caffe2/core/operator.h" #include "caffe2/operators/conv_op.h" #include "caffe2/quantization/server/conv_pool_dnnlowp_op_base.h" #include "caffe2/quantization/server/fbgemm_pack_blob.h" #include "caffe2/quantization/server/fully_connected_dnnlowp_op.h" namespace caffe2 { using FCFp32Op = FullyC...
5,763
30.67033
90
h
null
pytorch-main/caffe2/quantization/server/fully_connected_dnnlowp_acc16_op.h
#pragma once #include "caffe2/quantization/server/fully_connected_dnnlowp_op.h" namespace caffe2 { /** * Quantized FC operator with 16-bit accumulation. * We'll encounter saturation but this will be faster in Intel CPUs */ class FullyConnectedDNNLowPAcc16Op final : public FullyConnectedDNNLowPOp<std::uint8_t>...
1,065
27.052632
79
h
null
pytorch-main/caffe2/quantization/server/fully_connected_dnnlowp_op.h
#pragma once #include <fbgemm/Fbgemm.h> #include "caffe2/operators/fully_connected_op.h" #include "caffe2/quantization/server/dnnlowp_op.h" namespace caffe2 { template <typename T, bool ReluFused = false> class FullyConnectedDNNLowPOp : public DNNLowPOp<T, FullyConnectedOp<CPUContext>> { public: FullyConnecte...
2,160
30.779412
79
h
null
pytorch-main/caffe2/quantization/server/fully_connected_fake_lowp_op.h
/** * Copyright (c) 2016-present, Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable ...
4,101
28.3
80
h
null
pytorch-main/caffe2/quantization/server/group_norm_dnnlowp_op.h
#pragma once #include <vector> #include "caffe2/operators/group_norm_op.h" #include "caffe2/quantization/server/dnnlowp_op.h" namespace caffe2 { using GroupNormFP32Op = GroupNormOp<float, CPUContext>; template <typename T> class GroupNormDNNLowPOp final : public DNNLowPOp<T, GroupNormFP32Op> { public: USE_OPERA...
4,610
20.546729
80
h
null
pytorch-main/caffe2/quantization/server/im2col_dnnlowp.h
#pragma once #ifdef _OPENMP #include <omp.h> #endif #include "caffe2/core/operator.h" #include "caffe2/utils/math.h" #include "caffe2/utils/math/utils.h" namespace caffe2 { namespace math { template <typename T> static void Im2ColNCHW( const int channels, const int height, const int width, const in...
11,848
33.344928
80
h
null
pytorch-main/caffe2/quantization/server/int8_gen_quant_params.h
// Copyright 2004-present Facebook. All Rights Reserved. #pragma once #include "caffe2/quantization/server/caffe2_dnnlowp_utils.h" #include "caffe2/quantization/server/dnnlowp.h" namespace caffe2 { using namespace std; using dnnlowp::TensorQuantizationParams; struct Int8QuantSchemeBlob { public: Int8QuantSchemeBl...
2,113
33.096774
80
h
null
pytorch-main/caffe2/quantization/server/int8_gen_quant_params_min_max.h
// Copyright 2004-present Facebook. All Rights Reserved. #pragma once #include "caffe2/quantization/server/caffe2_dnnlowp_utils.h" #include "caffe2/quantization/server/dnnlowp.h" #include "caffe2/quantization/server/int8_gen_quant_params.h" #include <glog/logging.h> namespace caffe2 { using namespace std; using dnnl...
1,827
34.843137
94
h
null
pytorch-main/caffe2/quantization/server/int8_quant_scheme_blob_fill.h
// Copyright 2004-present Facebook. All Rights Reserved. #pragma once #include "caffe2/quantization/server/caffe2_dnnlowp_utils.h" #include "caffe2/quantization/server/dnnlowp.h" #include "caffe2/quantization/server/int8_gen_quant_params.h" namespace caffe2 { using namespace std; template <class Context, class Engin...
1,135
32.411765
75
h
null
pytorch-main/caffe2/quantization/server/lstm_unit_dnnlowp_op.h
#pragma once #include "caffe2/operators/lstm_unit_op.h" #include "caffe2/quantization/server/caffe2_dnnlowp_utils.h" #include "caffe2/quantization/server/dnnlowp.h" #include "caffe2/quantization/server/op_wrapper.h" #include "caffe2/quantization/server/sigmoid.h" namespace caffe2 { template <typename T> class LSTMUn...
1,357
29.177778
80
h
null
pytorch-main/caffe2/quantization/server/mmio.h
#pragma once #include <cstdio> #include <set> #include <string> #include <type_traits> namespace caffe2 { template <typename T> void StoreMatrixInMatrixMarketFormat( int m, int n, const T* a, const std::string& matrix_name) { using namespace std; static set<string> dumped_matrix_names; string ...
1,335
23.290909
69
h
null
pytorch-main/caffe2/quantization/server/op_wrapper.h
#pragma once #include "caffe2/core/operator.h" #include "caffe2/core/tensor_int8.h" #include "caffe2/quantization/server/caffe2_dnnlowp_utils.h" #include "caffe2/quantization/server/dnnlowp.h" namespace caffe2 { /** * Wrap a floating-point operator with quantized inputs with type T. * This class is to measure quan...
2,959
32.258427
79
h
null
pytorch-main/caffe2/quantization/server/quantization_error_minimization.h
#pragma once #include "caffe2/quantization/server/dnnlowp.h" namespace dnnlowp { class QuantizationErrorMinimization { public: virtual TensorQuantizationParams ChooseQuantizationParams( const Histogram& hist, bool preserve_sparsity = false, int precision = 8) = 0; virtual ~QuantizationErrorMin...
1,356
22.396552
64
h
null
pytorch-main/caffe2/quantization/server/quantize_dnnlowp_op.h
#pragma once #include "caffe2/core/operator.h" #include "caffe2/quantization/server/caffe2_dnnlowp_utils.h" namespace caffe2 { template <typename T> class QuantizeDNNLowPOp final : public Operator<CPUContext> { public: USE_OPERATOR_FUNCTIONS(CPUContext); QuantizeDNNLowPOp(const OperatorDef& operator_def, Worksp...
518
22.590909
68
h
null
pytorch-main/caffe2/quantization/server/relu_dnnlowp_op.h
#pragma once #include "caffe2/operators/relu_op.h" #include "caffe2/core/tensor_int8.h" #include "caffe2/quantization/server/caffe2_dnnlowp_utils.h" namespace caffe2 { template <typename T> class ReluDNNLowPOp final : public Operator<CPUContext> { public: USE_OPERATOR_FUNCTIONS(CPUContext); ReluDNNLowPOp(const...
739
22.125
67
h
null
pytorch-main/caffe2/quantization/server/resize_nearest_3d_dnnlowp_op.h
#pragma once #include "caffe2/operators/resize_3d_op.h" #include "caffe2/quantization/server/dnnlowp_op.h" namespace caffe2 { using ResizeNearest3DFP32Op = ResizeNearest3DOp<float, CPUContext>; template <typename T> class ResizeNearest3DDNNLowPOp final : public DNNLowPOp<T, ResizeNearest3DFP32Op> { public: U...
1,243
28.619048
80
h
null
pytorch-main/caffe2/quantization/server/resize_nearest_dnnlowp_op.h
#pragma once #include "caffe2/operators/resize_op.h" #include "caffe2/quantization/server/dnnlowp_op.h" namespace caffe2 { using ResizeNearestFP32Op = ResizeNearestOp<float, CPUContext>; template <typename T> class ResizeNearestDNNLowPOp final : public DNNLowPOp<T, ResizeNearestFP32Op> { public: USE_OPERATOR_FUN...
1,057
27.594595
80
h
null
pytorch-main/caffe2/quantization/server/sigmoid.h
#pragma once #include "caffe2/quantization/server/tanh.h" namespace dnnlowp { /** * sigmoid(x) = (tanh(x/2) + 1)/2 * Quantized sigmoid is computed as tanh under the hood, we just use different * input/output quantization parameters. */ template <typename T> class Sigmoid { public: Sigmoid(double max_abs_err_ ...
807
22.764706
78
h
null
pytorch-main/caffe2/quantization/server/spatial_batch_norm_dnnlowp_op.h
#pragma once #include "caffe2/operators/spatial_batch_norm_op.h" #include "caffe2/quantization/server/dnnlowp_op.h" namespace caffe2 { /** * Note this implementation assumes SCALE, BIAS, EST_MEAN, and EST_VAR inputs * are still in fp32, so is epsilon argument */ template <typename T, bool ReluFused = false> class...
1,340
21.35
79
h
null
pytorch-main/caffe2/quantization/server/tanh.h
#pragma once #include "caffe2/quantization/server/dnnlowp.h" #include <cmath> #include <vector> namespace dnnlowp { /** * We use the 3-region approach described in "Efficient VLSI Implementation of * Neural Networks with Hyperbolic Tangent Activation Function", IEEE * Transactions on Very Large Scale Integration...
1,751
26.375
78
h
null
pytorch-main/caffe2/quantization/server/utility_dnnlowp_ops.h
#pragma once #include "caffe2/operators/utility_ops.h" #include "caffe2/quantization/server/caffe2_dnnlowp_utils.h" #include "caffe2/quantization/server/dnnlowp.h" #include "caffe2/quantization/server/dnnlowp_op.h" namespace caffe2 { template <typename T, bool ReluFused = false> class SumDNNLowPOp final : public DNN...
3,310
28.828829
80
h
null
pytorch-main/caffe2/queue/blobs_queue.h
#pragma once #include <atomic> #include <condition_variable> #include <memory> #include <mutex> #include <queue> #include "caffe2/core/blob_stats.h" #include "caffe2/core/logging.h" #include "caffe2/core/stats.h" #include "caffe2/core/tensor.h" #include "caffe2/core/workspace.h" namespace caffe2 { // A thread-safe,...
1,779
24.070423
78
h
null
pytorch-main/caffe2/queue/blobs_queue_db.h
#pragma once #include <chrono> #include <string> #include "caffe2/core/db.h" #include "caffe2/core/logging.h" #include "caffe2/core/stats.h" #include "caffe2/queue/blobs_queue.h" namespace caffe2 { namespace db { namespace { const std::string& GetStringFromBlob(Blob* blob) { if (blob->template IsType<string>()) ...
3,304
21.636986
72
h
null
pytorch-main/caffe2/queue/queue_ops.h
#pragma once #include <memory> #include "blobs_queue.h" #include "caffe2/core/operator.h" #include "caffe2/utils/math.h" #include <c10/util/irange.h> namespace caffe2 { template <typename Context> class CreateBlobsQueueOp final : public Operator<Context> { public: USE_OPERATOR_CONTEXT_FUNCTIONS; CreateBlobsQu...
8,735
30.2
80
h
null
pytorch-main/caffe2/queue/rebatching_queue_ops.h
#pragma once #include "rebatching_queue.h" #include "c10/util/irange.h" namespace caffe2 { using RebatchingQueuePtr = std::unique_ptr<RebatchingQueue>; class CreateRebatchingQueueOp : public Operator<CPUContext> { public: CreateRebatchingQueueOp(const OperatorDef& operator_def, Workspace* ws) : Operator(o...
2,549
28.651163
80
h
null
pytorch-main/caffe2/serialize/file_adapter.h
#pragma once #include <fstream> #include <memory> #include <c10/macros/Macros.h> #include "caffe2/serialize/istream_adapter.h" #include "caffe2/serialize/read_adapter_interface.h" namespace caffe2 { namespace serialize { class TORCH_API FileAdapter final : public ReadAdapterInterface { public: C10_DISABLE_COPY_A...
866
22.432432
71
h
null
pytorch-main/caffe2/serialize/inline_container.h
#pragma once #include <cerrno> #include <cstdio> #include <cstring> #include <fstream> #include <istream> #include <mutex> #include <ostream> #include <unordered_set> #include <c10/core/Allocator.h> #include <c10/core/Backend.h> #include "caffe2/serialize/istream_adapter.h" #include "caffe2/serialize/read_adapter_in...
7,501
32.945701
83
h
null
pytorch-main/caffe2/serialize/istream_adapter.h
#pragma once #include <istream> #include "c10/macros/Macros.h" #include "caffe2/serialize/read_adapter_interface.h" namespace caffe2 { namespace serialize { // this is a reader implemented by std::istream class TORCH_API IStreamAdapter final : public ReadAdapterInterface { public: C10_DISABLE_COPY_AND_ASSIGN(ISt...
669
22.928571
71
h
null
pytorch-main/caffe2/serialize/read_adapter_interface.h
#pragma once #include <cstddef> #include <cstdint> #include "c10/macros/Macros.h" namespace caffe2 { namespace serialize { // this is the interface for the (file/stream/memory) reader in // PyTorchStreamReader. with this interface, we can extend the support // besides standard istream class TORCH_API ReadAdapterInt...
556
22.208333
79
h
null
pytorch-main/caffe2/serialize/versions.h
#pragma once #include <cstdint> namespace caffe2 { namespace serialize { constexpr uint64_t kMinSupportedFileFormatVersion = 0x1L; constexpr uint64_t kMaxSupportedFileFormatVersion = 0xAL; // Versions (i.e. why was the version number bumped?) // Note [Dynamic Versions and torch.jit.save vs. torch.save] // // Our v...
6,648
48.619403
80
h
null
pytorch-main/caffe2/sgd/adadelta_op.h
#include "caffe2/core/operator.h" #include "c10/util/irange.h" namespace caffe2 { namespace { template <typename Context> void AdadeltaUpdate( int N, const float* w, const float* g, const float* h, const float* d, const float epsilon, const float decay, const float* lr, float* nw,...
5,897
31.054348
78
h
null
pytorch-main/caffe2/sgd/adagrad_fused.h
#pragma once #include "caffe2/sgd/adagrad_op.h" #include "caffe2/sgd/math_lp.h" namespace caffe2 { namespace { template < typename Tdata, // embedding and momentum types typename T, // everything else typename TLengths, typename adagradT, bool is_mean = false> class SparseAdagradFusedWithSparseL...
16,586
32.374245
82
h
null
pytorch-main/caffe2/sgd/adagrad_op.h
#pragma once #include "caffe2/core/operator.h" #include "caffe2/perfkernels/adagrad.h" #if defined(USE_FBGEMM) && !defined(__NVCC__) #include "fbgemm/FbgemmEmbedding.h" #endif namespace caffe2 { template <typename Context> void adagrad_update( int N, const float* w, const float* g, const float* h, ...
18,035
30.366957
80
h
null
pytorch-main/caffe2/sgd/clip_tensor_op.h
#ifndef CAFFE2_OPERATORS_CLIP_TENSOR_OP_H_ #define CAFFE2_OPERATORS_CLIP_TENSOR_OP_H_ #include <vector> #include "caffe2/core/context.h" #include "caffe2/core/operator.h" #include "caffe2/core/tensor.h" #include "caffe2/utils/math.h" namespace caffe2 { template <typename Context> class ClipTensorByScalingOp final : ...
1,853
26.671642
75
h
null
pytorch-main/caffe2/sgd/decay_adagrad_op.h
#pragma once #include "caffe2/core/operator.h" #include "caffe2/utils/eigen_utils.h" namespace caffe2 { template <typename Context> void decay_adagrad_compute( int N, const float* w, const float* g, const float* m, const float* v, float* nw, float* nm, float* nv, float beta1, ...
3,215
32.5
104
h
null
pytorch-main/caffe2/sgd/fp16_momentum_sgd_op.h
#pragma once #include "caffe2/core/operator.h" #include "caffe2/core/timer.h" namespace caffe2 { template <class Context> void fp16_momentum_sgd_update( int N, const at::Half* g, const at::Half* m, at::Half* ng, at::Half* nm, const float* lr, float momentum, bool nesterov, float w...
2,292
30.410959
80
h
null
pytorch-main/caffe2/sgd/fp32_momentum_sgd_op.h
#pragma once #include "caffe2/core/operator.h" #include "caffe2/core/timer.h" namespace caffe2 { template <class Context> void fp32_momentum_sgd_update( int N, const float* g, const float* m, float* ng, float* nm, const float* lr, float momentum, bool nesterov, float weight_decay,...
2,015
29.089552
76
h
null
pytorch-main/caffe2/sgd/ftrl_op.h
#pragma once #include "caffe2/core/operator.h" namespace caffe2 { template <typename T> struct FtrlParams { explicit FtrlParams(OperatorBase* op) : alphaInv(1.0 / op->GetSingleArgument<float>("alpha", 0.005f)), beta(op->GetSingleArgument<float>("beta", 1.0f)), lambda1(op->GetSingleArgument<fl...
2,219
27.101266
79
h
null
pytorch-main/caffe2/sgd/gftrl_op.h
#pragma once #include "caffe2/core/operator.h" namespace caffe2 { template <typename T> struct GFtrlParams { explicit GFtrlParams(OperatorBase* op) : alphaInv(1.0 / op->GetSingleArgument<float>("alpha", 0.005f)), beta(op->GetSingleArgument<float>("beta", 1.0f)), lambda1(op->GetSingleArgument<...
1,028
25.384615
70
h
null
pytorch-main/caffe2/sgd/iter_op.h
#ifndef CAFFE2_SGD_ITER_OP_H_ #define CAFFE2_SGD_ITER_OP_H_ #include <limits> #include <mutex> #include "caffe2/core/blob_serialization.h" #include "caffe2/core/context.h" #include "caffe2/core/operator.h" #include "caffe2/core/stats.h" namespace caffe2 { inline void IncrementIter(TensorCPU* output) { CAFFE_ENFOR...
3,379
30.886792
78
h
null
pytorch-main/caffe2/sgd/lars_op.h
#ifndef CAFFE2_OPERATORS_LARS_OP_H_ #define CAFFE2_OPERATORS_LARS_OP_H_ #include "caffe2/core/context.h" #include "caffe2/core/logging.h" #include "caffe2/core/operator.h" #include "caffe2/utils/math.h" namespace caffe2 { template <typename T, class Context> class LarsOp final : public Operator<Context> { public: ...
2,479
25.382979
95
h
null
pytorch-main/caffe2/sgd/learning_rate_adaption_op.h
#pragma once #include <cfloat> #include <cmath> #include "caffe2/core/context.h" #include "caffe2/core/operator.h" #include "caffe2/utils/math.h" namespace caffe2 { template <typename Context> void lr_update( int n, const float* grad, const float* effgrad, const float* lr, float* nlr, float l...
1,981
25.426667
78
h
null
pytorch-main/caffe2/sgd/learning_rate_functors.h
#ifndef CAFFE2_SGD_LEARNING_RATE_FUNCTORS_H_ #define CAFFE2_SGD_LEARNING_RATE_FUNCTORS_H_ #include <cmath> #include <list> #include <map> #ifdef _MSC_VER #ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES #endif #include <math.h> #endif // _MSC_VER #include "caffe2/core/context.h" #include "caffe2/core/operator.h" ...
15,158
29.873727
108
h
null
pytorch-main/caffe2/sgd/learning_rate_op.h
#ifndef CAFFE2_SGD_LEARNING_RATE_OP_H_ #define CAFFE2_SGD_LEARNING_RATE_OP_H_ #include <cfloat> #include <cmath> #include "caffe2/core/context.h" #include "caffe2/core/export_caffe2_op_to_c10.h" #include <c10/util/irange.h> #include "caffe2/core/operator.h" #include "caffe2/sgd/learning_rate_functors.h" C10_DECLARE_E...
12,880
44.355634
89
h
null
pytorch-main/caffe2/sgd/momentum_sgd_op.h
#pragma once #include "caffe2/core/operator.h" namespace caffe2 { template <typename Context> void momentum_sgd_update( const int N, const float* g, const float* m, float* ng, float* nm, const float* lr, const float momentum, const bool nesterov, float* param, Context* /*conte...
6,049
31.352941
79
h
null
pytorch-main/caffe2/sgd/rmsprop_op.h
#pragma once #include "caffe2/core/common_omp.h" #include "caffe2/core/operator.h" namespace caffe2 { template <typename Context> void rmsprop_update( int N, const float* g, const float* ms, const float* mom, float* ng, float* nms, float* nmom, float decay, float momentum, flo...
1,980
29.953125
78
h
null
pytorch-main/caffe2/sgd/rowwise_counter.h
#pragma once #include "caffe2/core/operator.h" namespace caffe2 { class RowWiseCounterOp final : public Operator<CPUContext> { public: RowWiseCounterOp(const OperatorDef& operator_def, Workspace* ws) : Operator<CPUContext>(operator_def, ws), counter_halflife_( this->template GetSingleArg...
2,090
27.643836
79
h
null
pytorch-main/caffe2/sgd/storm_op.h
#pragma once #include "caffe2/core/operator.h" namespace caffe2 { template <typename Context> void storm_update( const int N, const float* paramIn, const float* momentIn, const float* gradSqSumIn, const float* gradIn, const float* lr, float* paramOut, float* momentOut, float* grad...
5,950
31.167568
76
h
null
pytorch-main/caffe2/sgd/weight_scale_op.h
/** * Copyright (c) 2016-present, Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable ...
2,552
27.366667
79
h
null
pytorch-main/caffe2/sgd/wngrad_op.h
#pragma once #include "caffe2/core/operator.h" namespace caffe2 { template <typename Context> void wngrad_update( int N, const float* w, const float* g, const float* h, float* nw, float* nh, float epsilon, const float* lr, Context* /*context*/) { for (const auto i : c10::irange(...
7,335
28.461847
78
h
null
pytorch-main/caffe2/sgd/yellowfin_op.h
// YellowFin: An automatic tuner for momentum SGD // (https://arxiv.org/abs/1706.03471) // The YellowFinOp tunes learning rate and momentum and performs momentum SGD // steps. The learning rate and momentum are separate for any matrix of // parameters. #pragma once #include <cmath> #include <cstring> #include "caffe2...
10,292
30.965839
98
h
null
pytorch-main/caffe2/share/contrib/zstd/quant_decomp_zstd_op.h
#ifndef QUANT_DECOMP_OP_H_ #define QUANT_DECOMP_OP_H_ #include "caffe2/core/context.h" #include "caffe2/core/operator.h" namespace caffe2 { // Decompress a set of tensors compressed using zstd, // see quant_decomp_op_test.py for how to compress class QuantDecompZstdOp final : public Operator<CPUContext> { public: ...
589
23.583333
67
h
null
pytorch-main/caffe2/transforms/common_subexpression_elimination.h
#pragma once #include "caffe2/core/common.h" #include "caffe2/core/transform.h" #include "caffe2/proto/caffe2_pb.h" #include "caffe2/utils/proto_utils.h" namespace caffe2 { /** * Common Subexpression Elimination * * This transforms looks for specific operators (denoted by allowed_ops_), * and removes unnecessar...
1,584
28.90566
80
h
null
pytorch-main/caffe2/transforms/conv_to_nnpack_transform.h
#pragma once #include "caffe2/core/common.h" #include "caffe2/proto/caffe2_pb.h" #include "caffe2/transforms/single_op_transform.h" #include "caffe2/utils/proto_utils.h" namespace caffe2 { class TORCH_API ConvToNNPackTransform : public SingleOpTransform { protected: // Specify what the op needs to be to match the...
678
25.115385
79
h
null
pytorch-main/caffe2/transforms/pattern_net_transform.h
#pragma once #include "caffe2/core/common.h" #include "caffe2/core/transform.h" #include "caffe2/proto/caffe2_pb.h" #include "caffe2/utils/proto_utils.h" namespace caffe2 { /** * PatternNetTransform allows you to create transforms using a simple * interface. * * Simply provide a Pattern NetDef and a Replace NetD...
4,399
31.835821
79
h
null
pytorch-main/caffe2/transforms/single_op_transform.h
#pragma once #include "caffe2/core/common.h" #include "caffe2/core/transform.h" #include "caffe2/proto/caffe2_pb.h" #include "caffe2/utils/proto_utils.h" namespace caffe2 { /** * Single Op Transform Base class * * A transform which is applied to a single node, in place. * * Transforms which derive from SingleOp...
1,021
25.894737
77
h
null
pytorch-main/caffe2/utils/bench_utils.h
/** * Copyright (c) 2016-present, Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable ...
854
26.580645
75
h
null
pytorch-main/caffe2/utils/cast.h
#pragma once #include <caffe2/utils/proto_utils.h> namespace caffe2 { namespace cast { inline TensorProto_DataType GetCastDataType(const ArgumentHelper& helper, std::string arg) { TensorProto_DataType to; if (helper.HasSingleArgumentOfType<string>(arg)) { string s = helper.GetSingleArgument<string>(arg, "fl...
1,110
21.22
92
h
null
pytorch-main/caffe2/utils/cpu_neon.h
#ifndef CAFFE2_UTILS_CPU_NEON_H_ #define CAFFE2_UTILS_CPU_NEON_H_ // Provides a variety of ARM NEON-specific utility functions #if defined(__ARM_NEON__) || defined(__ARM_NEON) #include <arm_neon.h> namespace caffe2 { template <typename T> inline bool isPointerAligned(T* p, size_t align) { return (reinterpret_cast<...
1,578
28.240741
74
h
null
pytorch-main/caffe2/utils/eigen_utils.h
// Copyright 2004-present Facebook. All Rights Reserved. #ifndef CAFFE2_OPERATORS_UTILS_EIGEN_H_ #define CAFFE2_OPERATORS_UTILS_EIGEN_H_ #include "Eigen/Core" #include "Eigen/Dense" #include <c10/util/Logging.h> #include <c10/util/irange.h> namespace caffe2 { // Common Eigen types that we will often use template <...
6,718
31.616505
80
h
null
pytorch-main/caffe2/utils/filler.h
#ifndef CAFFE2_FILLER_H_ #define CAFFE2_FILLER_H_ #include <sstream> #include "caffe2/core/logging.h" #include "caffe2/core/tensor.h" #include "caffe2/utils/math.h" namespace caffe2 { // TODO: replace filler distribution enum with a better abstraction enum FillerDistribution { FD_UNIFORM, FD_FIXEDSUM, FD_SYNTHETIC ...
3,927
26.858156
75
h
null
pytorch-main/caffe2/utils/fixed_divisor.h
#ifndef CAFFE2_UTILS_FIXED_DIVISOR_H_ #define CAFFE2_UTILS_FIXED_DIVISOR_H_ #include <cstdint> #include <cstdio> #include <cstdlib> // See Note [hip-clang differences to hcc] #if defined(__CUDA_ARCH__) || defined(__HIP_ARCH__) || defined(__HIP__) || \ (defined(__clang__) && defined(__CUDA__)) #define FIXED_DIVIS...
3,532
25.56391
80
h
null
pytorch-main/caffe2/utils/knob_patcher.h
#pragma once #include <memory> #include <c10/util/string_view.h> namespace caffe2 { /** * Patch the value of a knob during a unit test. * * This forces the knob to the specified value for as long as the KnobPatcher * object exists. When the KnobPatcher object is destroyed the knob will revert * to its previou...
715
20.69697
80
h
null
pytorch-main/caffe2/utils/map_utils.h
#pragma once namespace caffe2 { // Get value from map given key. Return supplied default value if not found // This is a stripped down version from folly: // https://github.com/facebook/folly/blob/5a07e203d79324b68d69f294fa38e43b9671e9b1/folly/MapUtil.h#L35-L45 template < class Map, typename Key = typename Ma...
635
30.8
106
h
null
pytorch-main/caffe2/utils/math-detail.h
#ifndef CAFFE2_UTILS_MATH_DETAIL_H_ #define CAFFE2_UTILS_MATH_DETAIL_H_ namespace caffe2 { class CPUContext; namespace math { namespace detail { // proxy to a class because of partial specialization limitations for functions template<typename T, class Context, int FixedSize> struct ScaleImpl { inline void operato...
1,928
20.197802
79
h
null
pytorch-main/caffe2/utils/math.h
#ifndef CAFFE2_UTILS_MATH_H_ #define CAFFE2_UTILS_MATH_H_ // This is a simple translation from the old Caffe math interfaces. We aim to // still keep it simple, so all platforms would be able to support it fairly // easily. // We include the cblas header here so that we can obtain the macros from cblas. extern "C" { #...
15,251
31.589744
80
h
null
pytorch-main/caffe2/utils/murmur_hash3.h
//----------------------------------------------------------------------------- // MurmurHash3 was written by Austin Appleby, and is placed in the public // domain. The author hereby disclaims copyright to this source code. #pragma once //----------------------------------------------------------------------------- /...
909
25
79
h
null
pytorch-main/caffe2/utils/proto_utils.h
#ifndef CAFFE2_UTILS_PROTO_UTILS_H_ #define CAFFE2_UTILS_PROTO_UTILS_H_ #ifdef CAFFE2_USE_LITE_PROTO #include <google/protobuf/message_lite.h> #else // CAFFE2_USE_LITE_PROTO #include <google/protobuf/message.h> #endif // !CAFFE2_USE_LITE_PROTO #include <c10/util/Logging.h> #include <c10/util/string_view.h> #include ...
13,283
33.59375
106
h
null
pytorch-main/caffe2/utils/signal_handler.h
#pragma once #include <c10/util/signal_handler.h> namespace caffe2 { #if defined(C10_SUPPORTS_FATAL_SIGNAL_HANDLERS) class TORCH_API C2FatalSignalHandler : public c10::FatalSignalHandler { public: void fatalSignalHandlerPostProcess() override; static C2FatalSignalHandler& getInstance(); private: explicit C2...
698
26.96
75
h
null
pytorch-main/caffe2/utils/simple_queue.h
#ifndef CAFFE2_UTILS_SIMPLE_QUEUE_H_ #define CAFFE2_UTILS_SIMPLE_QUEUE_H_ #include <condition_variable> // NOLINT #include <mutex> // NOLINT #include <queue> #include <c10/util/Logging.h> namespace caffe2 { // This is a very simple queue that Yangqing wrote when bottlefeeding the baby, // so don't take it serious...
2,602
31.5375
80
h
null
pytorch-main/caffe2/utils/smart_tensor_printer.h
#pragma once #include "caffe2/core/tensor.h" namespace caffe2 { // This is a wrapper around the TensorPrinter that doesn't require the user to // explicit specify the type of the tensor while calling the Print() method. // It also supports a convenience function with a default constructed printer as // a static meth...
1,402
26.509804
80
h
null
pytorch-main/caffe2/utils/string_utils.h
#pragma once #include <algorithm> #include <memory> #include <string> #include <vector> #include <c10/macros/Export.h> namespace caffe2 { TORCH_API std::vector<std::string> split(char separator, const std::string& string, bool ignore_empty = false); TORCH_API std::string trim(const std::string& str); TORCH_API si...
1,206
22.211538
80
h
null
pytorch-main/caffe2/utils/zmq_helper.h
#ifndef CAFFE2_UTILS_ZMQ_HELPER_H_ #define CAFFE2_UTILS_ZMQ_HELPER_H_ #include <zmq.h> #include "caffe2/core/logging.h" namespace caffe2 { class ZmqContext { public: explicit ZmqContext(int io_threads) : ptr_(zmq_ctx_new()) { CAFFE_ENFORCE(ptr_ != nullptr, "Failed to create zmq context."); int rc = zmq_c...
3,020
20.891304
68
h
null
pytorch-main/caffe2/utils/math/elementwise.h
#ifndef CAFFE2_UTILS_MATH_ELEMENTWISE_H_ #define CAFFE2_UTILS_MATH_ELEMENTWISE_H_ #include "caffe2/core/common.h" #include "caffe2/core/types.h" namespace caffe2 { namespace math { template <typename T, class Context> TORCH_API void Exp(int N, const T* X, T* Y, Context* context); template <typename T, class Context>...
6,455
39.099379
80
h
null
pytorch-main/caffe2/utils/math/half_utils.h
#ifndef CAFFE2_UTILS_MATH_HALF_UTILS_H_ #define CAFFE2_UTILS_MATH_HALF_UTILS_H_ #include "caffe2/core/common.h" #include "caffe2/core/types.h" #include "caffe2/utils/conversions.h" #include "caffe2/utils/math/utils.h" namespace caffe2 { namespace math { namespace utils { struct HalfAddFunctor { MATH_UTILS_DECL at:...
1,329
25.6
75
h
null
pytorch-main/caffe2/utils/math/reduce.h
#ifndef CAFFE2_UTILS_MATH_REDUCE_H_ #define CAFFE2_UTILS_MATH_REDUCE_H_ #include "caffe2/core/common.h" #include "caffe2/core/types.h" namespace caffe2 { class Tensor; namespace math { template <typename T, class Context> TORCH_API void ReduceMin(const int N, const T* X, T* y, Tensor* scratch_ptr, Context* context...
2,672
22.243478
80
h
null
pytorch-main/caffe2/utils/math/transpose.h
#ifndef CAFFE2_UTILS_MATH_TRANSPOSE_H_ #define CAFFE2_UTILS_MATH_TRANSPOSE_H_ #include "caffe2/core/common.h" #include "caffe2/core/types.h" namespace caffe2 { namespace math { // Transpose tensor X with dims by axes and write the result to tensor Y. template <typename TIndex, typename TData, class Context> TORCH_AP...
785
23.5625
73
h
null
pytorch-main/caffe2/utils/math/utils.h
#ifndef CAFFE2_UTILS_MATH_UTILS_H_ #define CAFFE2_UTILS_MATH_UTILS_H_ #include <vector> #include "caffe2/core/common.h" #if defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__) || \ defined(__HIP__) || (defined(__clang__) && defined(__CUDA__)) #define MATH_UTILS_DECL inline __host__ __device__ #else #define...
4,643
23.834225
76
h
null
pytorch-main/caffe2/utils/threadpool/ThreadPool.h
#ifndef CAFFE2_UTILS_THREADPOOL_H_ #define CAFFE2_UTILS_THREADPOOL_H_ #include "ThreadPoolCommon.h" #include <atomic> #include <functional> #include <memory> #include <mutex> #include <vector> #include "caffe2/core/common.h" // // A work-stealing threadpool loosely based off of pthreadpool // namespace caffe2 { s...
2,014
28.202899
81
h