Caffe2 - C++ API
A deep learning, cross platform ML framework
Tensor.h
1 #pragma once
2 
3 #include <c10/core/TensorImpl.h>
4 #include <c10/core/UndefinedTensorImpl.h>
5 #include <c10/macros/Macros.h>
6 
7 namespace c10 {
8 
18 class C10Tensor final {
19 private:
21 public:
22  explicit C10Tensor(TensorImplPtr impl) noexcept;
23 
24  C10Tensor(const C10Tensor&) = default;
25  C10Tensor(C10Tensor&&) noexcept = default;
26  C10Tensor& operator=(const C10Tensor&) = default;
27  C10Tensor& operator=(C10Tensor&&) noexcept = default;
28 
29  const TensorImplPtr &impl() const & noexcept;
30  TensorImplPtr&& impl() && noexcept;
31 
32  TensorTypeId type_id() const;
33 
34 private:
35  TensorImplPtr impl_;
36 };
37 
38 inline C10Tensor::C10Tensor(TensorImplPtr impl) noexcept
39 : impl_(std::move(impl)) {}
40 
41 inline const C10Tensor::TensorImplPtr &C10Tensor::impl() const & noexcept {
42  return impl_;
43 }
44 
45 inline C10Tensor::TensorImplPtr&& C10Tensor::impl() && noexcept {
46  return std::move(impl_);
47 }
48 
49 inline TensorTypeId C10Tensor::type_id() const {
50  return impl_->type_id();
51 }
52 
53 } // namespace c10
This is a minimal Tensor class for use in c10 code.
Definition: Tensor.h:18
TensorTypeId type_id() const
Return the TensorTypeId corresponding to this Tensor.
Definition: TensorImpl.h:274
Dynamic type ID of a Tensor argument.
Definition: TensorTypeId.h:19
To register your own kernel for an operator, do in one (!) cpp file: C10_REGISTER_KERNEL(OperatorHand...
Definition: alias_info.h:7