pytorch  1.8.2
About: PyTorch provides Tensor computation (like NumPy) with strong GPU acceleration and Deep Neural Networks (in Python) built on a tape-based autograd system. LTS (Long Term Support) release.
  Fossies Dox: pytorch-1.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

operator.h File Reference
#include <array>
#include <cfenv>
#include <climits>
#include <cstddef>
#include <exception>
#include <functional>
#include <set>
#include <sstream>
#include <string>
#include <typeinfo>
#include <vector>
#include <c10/macros/Macros.h>
#include <c10/util/Registry.h>
#include <c10/util/typeid.h>
#include "caffe2/core/blob.h"
#include "caffe2/core/common.h"
#include "caffe2/core/net.h"
#include "caffe2/core/observer.h"
#include "caffe2/core/operator_gradient.h"
#include "caffe2/core/operator_schema.h"
#include "caffe2/core/tensor.h"
#include "caffe2/core/tensor_int8.h"
#include "caffe2/core/types.h"
#include "caffe2/core/workspace.h"
#include "caffe2/proto/caffe2_pb.h"
#include "caffe2/utils/proto_utils.h"
#include <ATen/core/TensorBody.h>
#include <ATen/core/function_schema.h>
#include <ATen/core/ivalue.h>
Include dependency graph for operator.h:

Go to the source code of this file.

Classes

class  caffe2::OperatorBase
 
class  caffe2::Operator< Context >
 
struct  caffe2::FixedValues< Values >
 
struct  caffe2::TensorTypes< Types >
 
struct  caffe2::GenericTensorImplementation
 
struct  caffe2::TensorTypes2< Types >
 
struct  caffe2::DispatchHelper< FixedValues< FirstVal, Values... >, ExtraArgs... >
 
struct  caffe2::DispatchHelper< FixedValues<>, ExtraArgs... >
 
struct  caffe2::DispatchHelper< TensorTypes< FirstType, Types... >, ExtraArgs... >
 
struct  caffe2::DispatchHelper< TensorTypes<>, ExtraArgs... >
 
struct  caffe2::DispatchHelper< TensorTypes< GenericTensorImplementation >, ExtraArgs... >
 
struct  caffe2::DispatchHelper< TensorTypes2< FirstType, Types... >, ExtraArgs... >
 
struct  caffe2::DispatchHelper< TensorTypes2<>, ExtraArgs... >
 
struct  caffe2::DispatchHelper< TensorTypes2< GenericTensorImplementation >, ExtraArgs... >
 
struct  caffe2::DeviceTypeRegisterer
 
struct  caffe2::StaticLinkingProtector
 
class  caffe2::UnsupportedOperatorFeature
 
struct  caffe2::ExternalTensorDescriptor
 
class  caffe2::ExternalTensorFunctionsBase
 

Namespaces

namespace  c10
 This file contains functionality to take a C++ function and infer its c10::FunctionSchema.
 
namespace  caffe2
 Copyright (c) 2016-present, Facebook, Inc.
 

Macros

#define OP_SINGLE_ARG(type, name, variable, default)    variable(OperatorBase::GetSingleArgument<type>(name, (default)))
 
#define INPUT_TAGS(first_input, ...)    enum _InputTags { first_input = 0, __VA_ARGS__ }
 
#define OUTPUT_TAGS(first_input, ...)    enum _OutputTags { first_input = 0, __VA_ARGS__ }
 
#define USE_OPERATOR_BASE_FUNCTIONS
 
#define USE_OPERATOR_FUNCTIONS(context)
 
#define USE_OPERATOR_CONTEXT_FUNCTIONS   USE_OPERATOR_FUNCTIONS(Context)
 
#define USE_SIMPLE_CTOR_DTOR(name)
 
#define USE_DISPATCH_HELPER
 
#define C10_DEFINE_TENSOR_TYPES_DISPATCHER( TensorTypes, DoRunWithType, DoRunWithOtherType)
 
#define CAFFE_REGISTER_DEVICE_TYPE(type, registry_function)
 
#define REGISTER_CPU_OPERATOR_CREATOR(key, ...)    C10_REGISTER_CREATOR(CPUOperatorRegistry, key, __VA_ARGS__)
 
#define REGISTER_CPU_OPERATOR(name, ...)
 
#define REGISTER_CPU_OPERATOR_STR(str_name, ...)    C10_REGISTER_TYPED_CLASS(CPUOperatorRegistry, str_name, __VA_ARGS__)
 
#define REGISTER_CPU_OPERATOR_WITH_ENGINE(name, engine, ...)    C10_REGISTER_CLASS(CPUOperatorRegistry, name##_ENGINE_##engine, __VA_ARGS__)
 
#define REGISTER_CPU_GRADIENT_OPERATOR(...)    C10_MACRO_EXPAND(REGISTER_CPU_OPERATOR(__VA_ARGS__))
 
#define REGISTER_CPU_GRADIENT_OPERATOR_WITH_ENGINE(...)    C10_MACRO_EXPAND(REGISTER_CPU_OPERATOR_WITH_ENGINE(__VA_ARGS__))
 
#define REGISTER_CUDA_OPERATOR_CREATOR(key, ...)    C10_REGISTER_CREATOR(CUDAOperatorRegistry, key, __VA_ARGS__)
 
#define REGISTER_CUDA_OPERATOR(name, ...)
 
#define REGISTER_CUDA_OPERATOR_STR(str_name, ...)    C10_REGISTER_TYPED_CLASS(CUDAOperatorRegistry, str_name, __VA_ARGS__)
 
#define REGISTER_CUDA_OPERATOR_WITH_ENGINE(name, engine, ...)    C10_REGISTER_CLASS(CUDAOperatorRegistry, name##_ENGINE_##engine, __VA_ARGS__)
 
#define REGISTER_CUDNN_OPERATOR(name, ...)    REGISTER_CUDA_OPERATOR_WITH_ENGINE(name, CUDNN, __VA_ARGS__)
 
#define REGISTER_HIP_OPERATOR_CREATOR(key, ...)    C10_REGISTER_CREATOR(HIPOperatorRegistry, key, __VA_ARGS__)
 
#define REGISTER_HIP_OPERATOR(name, ...)
 
#define REGISTER_HIP_OPERATOR_STR(str_name, ...)    C10_REGISTER_TYPED_CLASS(HIPOperatorRegistry, str_name, __VA_ARGS__)
 
#define REGISTER_HIP_OPERATOR_WITH_ENGINE(name, engine, ...)    C10_REGISTER_CLASS(HIPOperatorRegistry, name##_ENGINE_##engine, __VA_ARGS__)
 
#define REGISTER_MIOPEN_OPERATOR(name, ...)
 
#define OPERATOR_NEEDS_FEATURE(condition, ...)
 
#define REGISTER_EXTERNAL_TENSOR_FUNCTIONS(id, ...)    C10_REGISTER_TYPED_CLASS(ExternalTensorFunctionsBaseRegistry, id, __VA_ARGS__)
 

Typedefs

typedef ObserverBase< OperatorBase > caffe2::OperatorObserver
 
typedef c10::Registry< std::string, std::unique_ptr< OperatorBase >, const OperatorDef &, Workspace * > caffe2::OperatorRegistry
 
typedef c10::Registry< std::string, std::unique_ptr< OperatorBase >, const OperatorDef &, Workspace * > *(* caffe2::RegistryFunction) ()
 
using caffe2::EnginePrefType = std::vector< std::string >
 
using caffe2::PerOpEnginePrefType = CaffeMap< DeviceType, CaffeMap< std::string, EnginePrefType > >
 
using caffe2::GlobalEnginePrefType = CaffeMap< DeviceType, EnginePrefType >
 

Functions

 C10_DECLARE_bool (caffe2_operator_throw_if_fp_exceptions)
 
 C10_DECLARE_bool (caffe2_operator_throw_if_fp_overflow_exceptions)
 
std::map< DeviceType, OperatorRegistry * > * caffe2::gDeviceTypeRegistry ()
 
 caffe2::C10_DECLARE_REGISTRY (CPUOperatorRegistry, OperatorBase, const OperatorDef &, Workspace *)
 
 caffe2::C10_DECLARE_REGISTRY (CUDAOperatorRegistry, OperatorBase, const OperatorDef &, Workspace *)
 
 caffe2::C10_DECLARE_REGISTRY (HIPOperatorRegistry, OperatorBase, const OperatorDef &, Workspace *)
 
unique_ptr< OperatorBase > caffe2::CreateOperator (const OperatorDef &operator_def, Workspace *ws, int net_position)
 
const std::string caffe2::OpRegistryKey (const std::string &op_type, const std::string &engine)
 
void caffe2::SetPerOpEnginePref (const PerOpEnginePrefType &per_op_engine_pref)
 
void caffe2::SetGlobalEnginePref (const GlobalEnginePrefType &global_engine_pref)
 
void caffe2::SetEnginePref (const PerOpEnginePrefType &per_op_engine_pref, const GlobalEnginePrefType &global_engine_pref)
 
void caffe2::SetOpEnginePref (const std::string &op_type, const CaffeMap< DeviceType, EnginePrefType > &op_pref)
 
void caffe2::LoadInt8TensorInfoOfBlob (std::vector< float > *scale, std::vector< float > *offset, uint32_t *axis, const Blob *b)
 
TensorShape caffe2::GetTensorShapeOfBlob (const Blob *b)
 
TensorShapes caffe2::InferBlobShapesAndTypes (CaffeMap< string, TensorShape > &blob_desc, const vector< NetDef * > &nets)
 
TensorShapes caffe2::InferBlobShapesAndTypesFromWorkspace (Workspace *ws, const vector< NetDef * > &nets)
 
TensorShapes caffe2::InferBlobShapesAndTypesFromMap (const CaffeMap< std::string, std::vector< int64_t > > &blob_dimensions, const vector< NetDef * > &nets)
 
TensorShapes caffe2::InferBlobShapesAndTypesFromMap (const CaffeMap< std::string, std::vector< int64_t > > &blob_dimensions, const CaffeMap< std::string, TensorProto_DataType > &blob_types, const vector< NetDef * > &nets)
 
std::map< string, std::pair< DeviceOption, DeviceOption > > caffe2::ValidateTensorDevices (OperatorBase &op, const OperatorDef &op_def)
 
std::set< std::string > caffe2::GetRegisteredOperators ()
 
void caffe2::SetOperatorLogger (std::function< void(const OperatorDef &)> tracer)
 
std::function< void(const OperatorDef &)> caffe2::GetOperatorLogger ()
 
 caffe2::C10_DECLARE_TYPED_REGISTRY (ExternalTensorFunctionsBaseRegistry, TypeIdentifier, ExternalTensorFunctionsBase, std::unique_ptr)
 
unique_ptr< ExternalTensorFunctionsBase > caffe2::CreateExternalTensorFunctions (TypeIdentifier id)
 

Variables

class TORCH_API caffe2::OperatorBase
 

Macro Definition Documentation

◆ C10_DEFINE_TENSOR_TYPES_DISPATCHER

#define C10_DEFINE_TENSOR_TYPES_DISPATCHER (   TensorTypes,
  DoRunWithType,
  DoRunWithOtherType 
)

Definition at line 1244 of file operator.h.

◆ CAFFE_REGISTER_DEVICE_TYPE

#define CAFFE_REGISTER_DEVICE_TYPE (   type,
  registry_function 
)
Value:
namespace { \
static DeviceTypeRegisterer C10_ANONYMOUS_VARIABLE( \
DeviceType)(type, &registry_function); \
}
#define C10_ANONYMOUS_VARIABLE(str)
Definition: Macros.h:84
DeviceType
Definition: DeviceType.h:15
int32_t type

Definition at line 1343 of file operator.h.

◆ INPUT_TAGS

#define INPUT_TAGS (   first_input,
  ... 
)     enum _InputTags { first_input = 0, __VA_ARGS__ }

Definition at line 751 of file operator.h.

◆ OP_SINGLE_ARG

#define OP_SINGLE_ARG (   type,
  name,
  variable,
  default 
)     variable(OperatorBase::GetSingleArgument<type>(name, (default)))

Definition at line 737 of file operator.h.

◆ OPERATOR_NEEDS_FEATURE

#define OPERATOR_NEEDS_FEATURE (   condition,
  ... 
)
Value:
if (!(condition)) { \
throw UnsupportedOperatorFeature(::c10::str(__VA_ARGS__)); \
}
decltype(auto) str(const Args &... args)
Definition: StringUtil.h:88

Definition at line 1484 of file operator.h.

◆ OUTPUT_TAGS

#define OUTPUT_TAGS (   first_input,
  ... 
)     enum _OutputTags { first_input = 0, __VA_ARGS__ }

Definition at line 753 of file operator.h.

◆ REGISTER_CPU_GRADIENT_OPERATOR

#define REGISTER_CPU_GRADIENT_OPERATOR (   ...)     C10_MACRO_EXPAND(REGISTER_CPU_OPERATOR(__VA_ARGS__))

Definition at line 1380 of file operator.h.

◆ REGISTER_CPU_GRADIENT_OPERATOR_WITH_ENGINE

#define REGISTER_CPU_GRADIENT_OPERATOR_WITH_ENGINE (   ...)     C10_MACRO_EXPAND(REGISTER_CPU_OPERATOR_WITH_ENGINE(__VA_ARGS__))

Definition at line 1387 of file operator.h.

◆ REGISTER_CPU_OPERATOR

#define REGISTER_CPU_OPERATOR (   name,
  ... 
)
Value:
C10_IMPORT void CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
static void CAFFE2_UNUSED CAFFE_ANONYMOUS_VARIABLE_CPU##name() { \
CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
} \
C10_REGISTER_CLASS(CPUOperatorRegistry, name, __VA_ARGS__)
#define C10_IMPORT
Definition: Export.h:64
#define CAFFE2_UNUSED
Definition: common.h:61
std::string name

Definition at line 1363 of file operator.h.

◆ REGISTER_CPU_OPERATOR_CREATOR

#define REGISTER_CPU_OPERATOR_CREATOR (   key,
  ... 
)     C10_REGISTER_CREATOR(CPUOperatorRegistry, key, __VA_ARGS__)

Definition at line 1361 of file operator.h.

◆ REGISTER_CPU_OPERATOR_STR

#define REGISTER_CPU_OPERATOR_STR (   str_name,
  ... 
)     C10_REGISTER_TYPED_CLASS(CPUOperatorRegistry, str_name, __VA_ARGS__)

Definition at line 1369 of file operator.h.

◆ REGISTER_CPU_OPERATOR_WITH_ENGINE

#define REGISTER_CPU_OPERATOR_WITH_ENGINE (   name,
  engine,
  ... 
)     C10_REGISTER_CLASS(CPUOperatorRegistry, name##_ENGINE_##engine, __VA_ARGS__)

Definition at line 1372 of file operator.h.

◆ REGISTER_CUDA_OPERATOR

#define REGISTER_CUDA_OPERATOR (   name,
  ... 
)
Value:
C10_IMPORT void CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
static void CAFFE2_UNUSED CAFFE_ANONYMOUS_VARIABLE_CUDA##name() { \
CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
} \
C10_REGISTER_CLASS(CUDAOperatorRegistry, name, __VA_ARGS__)

Definition at line 1398 of file operator.h.

◆ REGISTER_CUDA_OPERATOR_CREATOR

#define REGISTER_CUDA_OPERATOR_CREATOR (   key,
  ... 
)     C10_REGISTER_CREATOR(CUDAOperatorRegistry, key, __VA_ARGS__)

Definition at line 1396 of file operator.h.

◆ REGISTER_CUDA_OPERATOR_STR

#define REGISTER_CUDA_OPERATOR_STR (   str_name,
  ... 
)     C10_REGISTER_TYPED_CLASS(CUDAOperatorRegistry, str_name, __VA_ARGS__)

Definition at line 1404 of file operator.h.

◆ REGISTER_CUDA_OPERATOR_WITH_ENGINE

#define REGISTER_CUDA_OPERATOR_WITH_ENGINE (   name,
  engine,
  ... 
)     C10_REGISTER_CLASS(CUDAOperatorRegistry, name##_ENGINE_##engine, __VA_ARGS__)

Definition at line 1407 of file operator.h.

◆ REGISTER_CUDNN_OPERATOR

#define REGISTER_CUDNN_OPERATOR (   name,
  ... 
)     REGISTER_CUDA_OPERATOR_WITH_ENGINE(name, CUDNN, __VA_ARGS__)

Definition at line 1411 of file operator.h.

◆ REGISTER_EXTERNAL_TENSOR_FUNCTIONS

#define REGISTER_EXTERNAL_TENSOR_FUNCTIONS (   id,
  ... 
)     C10_REGISTER_TYPED_CLASS(ExternalTensorFunctionsBaseRegistry, id, __VA_ARGS__)

Definition at line 1600 of file operator.h.

◆ REGISTER_HIP_OPERATOR

#define REGISTER_HIP_OPERATOR (   name,
  ... 
)
Value:
C10_IMPORT void CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
static void CAFFE2_UNUSED CAFFE_ANONYMOUS_VARIABLE_HIP##name() { \
CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
} \
C10_REGISTER_CLASS(HIPOperatorRegistry, name, __VA_ARGS__)

Definition at line 1422 of file operator.h.

◆ REGISTER_HIP_OPERATOR_CREATOR

#define REGISTER_HIP_OPERATOR_CREATOR (   key,
  ... 
)     C10_REGISTER_CREATOR(HIPOperatorRegistry, key, __VA_ARGS__)

Definition at line 1420 of file operator.h.

◆ REGISTER_HIP_OPERATOR_STR

#define REGISTER_HIP_OPERATOR_STR (   str_name,
  ... 
)     C10_REGISTER_TYPED_CLASS(HIPOperatorRegistry, str_name, __VA_ARGS__)

Definition at line 1428 of file operator.h.

◆ REGISTER_HIP_OPERATOR_WITH_ENGINE

#define REGISTER_HIP_OPERATOR_WITH_ENGINE (   name,
  engine,
  ... 
)     C10_REGISTER_CLASS(HIPOperatorRegistry, name##_ENGINE_##engine, __VA_ARGS__)

Definition at line 1431 of file operator.h.

◆ REGISTER_MIOPEN_OPERATOR

#define REGISTER_MIOPEN_OPERATOR (   name,
  ... 
)
Value:
REGISTER_HIP_OPERATOR_WITH_ENGINE(name, MIOPEN, __VA_ARGS__) \
REGISTER_HIP_OPERATOR_WITH_ENGINE( \
name, CUDNN, __VA_ARGS__)
#define REGISTER_HIP_OPERATOR_WITH_ENGINE(name, engine,...)
Definition: operator.h:1431

Definition at line 1434 of file operator.h.

◆ USE_DISPATCH_HELPER

#define USE_DISPATCH_HELPER
Value:
template <typename FirstArg, typename... ExtraArgs> \
friend struct DispatchHelper

Definition at line 1201 of file operator.h.

◆ USE_OPERATOR_BASE_FUNCTIONS

#define USE_OPERATOR_BASE_FUNCTIONS
Value:
/* using override */ using OperatorBase::HasArgument; \
/* using override */ using OperatorBase::GetSingleArgument; \
/* using override */ using OperatorBase::HasSingleArgumentOfType; \
/* using override */ using OperatorBase::GetRepeatedArgument; \
/* using override */ using OperatorBase::InputIsType; \
/* using override */ using OperatorBase::InputSize; \
/* using override */ using OperatorBase::Output; \
/* using override */ using OperatorBase::Input; \
/* using override */ using OperatorBase::OutputSize; \
/* using override */ using OperatorBase::IsInputOutputAlias; \
/* using override */ using OperatorBase::OutputTensorAlias
SparseLengths8BitsRowwiseOp< CPUContext, 0, 1 >::LENGTHS uint8 tensor obtained with Vector with the same sum of elements as the first dimension of DATA Input(3, "scale_bias", "Matrix of floats, each row r_i of which stores a pair " "s_i, b_i -- scale and bias for i-th row") .Output(0
SparseLengths8BitsRowwiseOp< CPUContext, 1, 1 >::LENGTHS uint8 tensor obtained with Integer vector containing indices of the first dimension of DATA for the slices that are being aggregated Matrix of each row r_i of which stores a pair b_i scale and bias for i th row Output(0, "output", "output")

Definition at line 1141 of file operator.h.

◆ USE_OPERATOR_CONTEXT_FUNCTIONS

#define USE_OPERATOR_CONTEXT_FUNCTIONS   USE_OPERATOR_FUNCTIONS(Context)

Definition at line 1163 of file operator.h.

◆ USE_OPERATOR_FUNCTIONS

#define USE_OPERATOR_FUNCTIONS (   context)
Value:
/* using override */ using Operator<context>::context_; \
/* using override */ using Operator<context>::Input; \
/* using override */ using Operator<context>::InputBlob; \
/* using override */ using Operator<context>::Output; \
/* using override */ using Operator<context>::OutputBlob; \
/* using override */ using Operator<context>::OutputTensorCopyFrom
#define USE_OPERATOR_BASE_FUNCTIONS
Definition: operator.h:1141
CPUContext * context_

Definition at line 1154 of file operator.h.

◆ USE_SIMPLE_CTOR_DTOR

#define USE_SIMPLE_CTOR_DTOR (   name)
Value:
template <class... Args> \
explicit name(Args&&... args) \
: Operator<Context>(std::forward<Args>(args)...) {} \
virtual ~name() noexcept {}
Args({2<< 5}) -> Args({2<< 8}) ->Args({2<< 12}) ->Args({2<< 14})

Definition at line 1165 of file operator.h.

Function Documentation

◆ C10_DECLARE_bool() [1/2]

C10_DECLARE_bool ( caffe2_operator_throw_if_fp_exceptions  )

◆ C10_DECLARE_bool() [2/2]

C10_DECLARE_bool ( caffe2_operator_throw_if_fp_overflow_exceptions  )