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.
![]() ![]() |
Virtual interface for the Context class in Caffe2. More...
#include <context_base.h>
Public Member Functions | |
virtual | ~BaseContext () noexcept |
virtual Device | device () const =0 |
virtual DeviceType | device_type () const =0 |
virtual void | SwitchToDevice (int)=0 |
void | SwitchToDevice () |
virtual void | WaitEvent (const caffe2::Event &ev)=0 |
virtual void | Record (caffe2::Event *ev, const char *err_msg=nullptr) const =0 |
virtual void | FinishDeviceComputation ()=0 |
virtual void | CopyBytesSameDevice (size_t nbytes, const void *src, void *dst)=0 |
virtual void | CopyBytesFromCPU (size_t nbytes, const void *src, void *dst)=0 |
virtual void | CopyBytesToCPU (size_t nbytes, const void *src, void *dst)=0 |
template<typename T > | |
void | CopySameDevice (size_t n, const T *src, T *dst) |
template<typename T > | |
void | CopyFromCPU (size_t n, const T *src, T *dst) |
template<typename T > | |
void | CopyToCPU (size_t n, const T *src, T *dst) |
virtual bool | SupportsNonFundamentalTypes () const |
void | EnforceMetaCopyOK () |
void | CopyItemsSameDevice (const caffe2::TypeMeta meta, size_t n, const void *src, void *dst) |
void | CopyItemsFromCPU (const caffe2::TypeMeta meta, size_t n, const void *src, void *dst) |
void | CopyItemsToCPU (const caffe2::TypeMeta meta, size_t n, const void *src, void *dst) |
Virtual interface for the Context class in Caffe2.
A Context defines all the necessities to run an operator on a specific device. Specific Context classes needs to implement all the pure virtual functions in the BaseContext class. TODO: add docs after this is finalized.
Definition at line 36 of file context_base.h.
|
inlinevirtualnoexcept |
Definition at line 38 of file context_base.h.
|
pure virtual |
Implemented in caffe2::CPUContext, caffe2::CUDAContext, and caffe2::IDEEPContext.
|
pure virtual |
Implemented in caffe2::CPUContext, caffe2::CUDAContext, and caffe2::IDEEPContext.
|
pure virtual |
Implemented in caffe2::CPUContext, caffe2::CUDAContext, and caffe2::IDEEPContext.
|
inline |
Definition at line 81 of file context_base.h.
References caffe2::dst, and caffe2::src.
Referenced by caffe2::HSoftmaxGradientOp< T, Context >::RunBackwardSingle(), caffe2::DropoutOp< T, Context >::RunOnDevice(), caffe2::DropoutGradientOp< T, Context >::RunOnDevice(), caffe2::LRNOp< T, Context >::RunOnDeviceWithOrderNCHW(), and caffe2::LRNGradientOp< T, Context >::RunOnDeviceWithOrderNCHW().
|
inline |
Definition at line 119 of file context_base.h.
References caffe2::TypeMeta::copy(), caffe2::dst, caffe2::TypeMeta::itemsize(), and caffe2::src.
|
inline |
Definition at line 106 of file context_base.h.
References caffe2::TypeMeta::copy(), caffe2::dst, caffe2::TypeMeta::itemsize(), and caffe2::src.
Referenced by caffe2::SparseToDenseMaskOp< Context >::DoRunWithType(), caffe2::TileOp< Context >::DoRunWithType(), caffe2::PackSegmentsOp< Context >::DoRunWithType2(), caffe2::UnpackSegmentsOp< Context >::DoRunWithType2(), caffe2::TensorProtosDBInput< Context >::Prefetch(), caffe2::BooleanMaskOp< Context >::RunOnDevice(), caffe2::ConditionalOp< Context >::RunOnDevice(), and caffe2::PadEmptySamplesOp< Context >::RunOnDevice().
|
inline |
Definition at line 132 of file context_base.h.
References caffe2::TypeMeta::copy(), caffe2::dst, caffe2::TypeMeta::itemsize(), and caffe2::src.
|
inline |
Definition at line 72 of file context_base.h.
References caffe2::dst, and caffe2::src.
Referenced by caffe2::SoftmaxGradientOp< T, Context >::RunOnDevice().
|
inline |
Definition at line 90 of file context_base.h.
References caffe2::dst, and caffe2::src.
|
pure virtual |
Implemented in caffe2::CPUContext, caffe2::CUDAContext, and caffe2::IDEEPContext.
Referenced by torch.tensor.Tensor::__deepcopy__(), torch.jit.cuda.device::__enter__(), caffe2.python.core.RemapEntry::__eq__(), caffe2.python.core.RemapEntry::__hash__(), torch.cuda.streams.Stream::__hash__(), torch.cuda.streams.Stream::__repr__(), torch.tensor.Tensor::__rpow__(), torch.nn.parallel.distributed.DistributedDataParallel::_check_global_requires_backward_grad_sync(), torch.nn.parallel.distributed.DistributedDataParallel::_find_common_rank(), torch.tensor.Tensor::_reduce_ex_internal(), torch.nn.parallel.distributed.DistributedDataParallel::_schedule_shadow_all_reduce_for_fwd_pass(), tools.codegen.model.TensorOptionsArguments::all(), benchmark.TorchvisionBenchmark::create_model(), benchmark.Benchmark::desc(), torch.jit.cuda.device::device, torch.nn.parallel.distributed.DistributedDataParallel::forward(), benchmark.TorchvisionBenchmark::generate_inputs(), benchmark.TorchvisionBenchmark::generate_target(), elementwise.DynamicSimpleElementBench::instantiate_input(), and benchmark.Benchmark::run_impl().
|
pure virtual |
Implemented in caffe2::CPUContext, caffe2::CUDAContext, and caffe2::IDEEPContext.
Referenced by torch.autograd.profiler.FunctionEventAvg::__init__(), torch.autograd.profiler.FunctionEvent::__init__(), torch.autograd.profiler.FunctionEvent::__repr__(), torch.nn.parallel.distributed.DistributedDataParallel::_passing_sync_batchnorm_handle(), torch.autograd.profiler.FunctionEvent::append_cpu_child(), torch.autograd.profiler.FunctionEvent::cpu_time_total(), torch.autograd.profiler.FunctionEvent::cuda_time_total(), torch.autograd.profiler.FunctionEvent::self_cpu_memory_usage(), torch.autograd.profiler.FunctionEvent::self_cpu_time_total(), torch.autograd.profiler.FunctionEvent::self_cuda_memory_usage(), torch.autograd.profiler.FunctionEvent::self_cuda_time_total(), and torch.autograd.profiler.FunctionEvent::set_cpu_parent().
|
inline |
Definition at line 101 of file context_base.h.
References AT_ASSERTM.
|
pure virtual |
Implemented in caffe2::IDEEPContext, caffe2::CPUContext, and caffe2::CUDAContext.
|
pure virtual |
Implemented in caffe2::IDEEPContext, caffe2::CPUContext, and caffe2::CUDAContext.
|
inlinevirtual |
Reimplemented in caffe2::CPUContext, and caffe2::IDEEPContext.
Definition at line 97 of file context_base.h.
|
inline |
Definition at line 47 of file context_base.h.
|
pure virtual |
Implemented in caffe2::IDEEPContext, caffe2::CPUContext, caffe2::CPUContext, caffe2::CUDAContext, and caffe2::IDEEPContext.
|
pure virtual |
Implemented in caffe2::IDEEPContext, caffe2::CPUContext, and caffe2::CUDAContext.