|
16 | 16 |
|
17 | 17 | #pragma once |
18 | 18 |
|
19 | | -#include <iostream> |
20 | 19 | #include <memory> |
21 | | -#include <vector> |
| 20 | +#include <string> |
22 | 21 |
|
| 22 | +#include "ngraph/descriptor/tensor.hpp" |
23 | 23 | #include "ngraph/shape.hpp" |
24 | 24 | #include "ngraph/type/element_type.hpp" |
25 | 25 |
|
26 | 26 | namespace ngraph |
27 | 27 | { |
28 | 28 | class Node; |
29 | 29 |
|
30 | | - namespace element |
31 | | - { |
32 | | - class Type; |
33 | | - } |
34 | | - |
35 | 30 | namespace descriptor |
36 | 31 | { |
37 | | - class TensorView; |
38 | | - class Tensor; |
39 | | - } |
40 | | -} |
| 32 | + namespace layout |
| 33 | + { |
| 34 | + class TensorViewLayout; |
| 35 | + } |
41 | 36 |
|
42 | | -class ngraph::descriptor::Tensor |
43 | | -{ |
44 | | - friend class TensorView; |
| 37 | + /// \brief Compile-time descriptor of a first-class value that is a view of a tensor. |
| 38 | + class Tensor |
| 39 | + { |
| 40 | + Tensor(const Tensor&) = delete; |
| 41 | + Tensor& operator=(const Tensor&) = delete; |
45 | 42 |
|
46 | | -private: |
47 | | - Tensor(const Tensor&) = delete; |
48 | | - Tensor& operator=(const Tensor&) = delete; |
| 43 | + public: |
| 44 | + Tensor(const element::Type& element_type, const Shape& shape, const std::string& name); |
49 | 45 |
|
50 | | - Tensor(const element::Type& element_type, TensorView* tensor_view, const std::string& name); |
51 | | - std::string get_next_view_name(); |
| 46 | + const std::string& get_name() const { return m_name; } |
| 47 | + void set_tensor_view_type(const element::Type& element_type, const Shape& shape); |
52 | 48 |
|
53 | | -public: |
54 | | - const std::string& get_name() const { return m_name; } |
55 | | - void set_pool_offset(size_t); |
56 | | - size_t size() const; |
57 | | - size_t get_pool_offset() const; |
58 | | - const element::Type& get_element_type() const { return m_element_type; } |
59 | | - void set_element_type(const element::Type& element_type); |
60 | | - static std::string make_tensor_name(const Node* node, size_t value_index); |
| 49 | + const element::Type& get_element_type() const { return m_element_type; } |
| 50 | + const Shape& get_shape() const { return m_shape; } |
| 51 | + const std::shared_ptr<layout::TensorViewLayout>& get_tensor_view_layout() const |
| 52 | + { |
| 53 | + return m_tensor_view_layout; |
| 54 | + } |
61 | 55 |
|
62 | | -protected: |
63 | | - element::Type m_element_type; |
64 | | - TensorView* m_tensor_view; |
65 | | - std::string m_name; |
66 | | - size_t m_next_view_id; |
67 | | - size_t m_pool_offset; |
68 | | -}; |
| 56 | + void set_tensor_view_layout( |
| 57 | + const std::shared_ptr<layout::TensorViewLayout>& tensor_view_layout) |
| 58 | + { |
| 59 | + m_tensor_view_layout = tensor_view_layout; |
| 60 | + } |
69 | 61 |
|
70 | | -std::ostream& operator<<(std::ostream&, const ngraph::descriptor::Tensor&); |
| 62 | + void set_pool_offset(size_t); |
| 63 | + size_t get_pool_offset() const; |
| 64 | + |
| 65 | + size_t size() const; |
| 66 | + |
| 67 | + const Tensor& get_tensor() const { return *this; } |
| 68 | + Tensor& get_tensor() { return *this; } |
| 69 | + const Tensor& get_tensor_view() const { return *this; } |
| 70 | + Tensor& get_tensor_view() { return *this; } |
| 71 | + protected: |
| 72 | + element::Type m_element_type; |
| 73 | + Shape m_shape; |
| 74 | + std::string m_name; |
| 75 | + std::shared_ptr<layout::TensorViewLayout> m_tensor_view_layout; |
| 76 | + size_t m_pool_offset; |
| 77 | + }; |
| 78 | + |
| 79 | + using TensorView = Tensor; |
| 80 | + |
| 81 | + using TensorViewPtrs = std::vector<std::shared_ptr<TensorView>>; |
| 82 | + std::ostream& operator<<(std::ostream&, const ngraph::descriptor::Tensor&); |
| 83 | + } |
| 84 | +} |
0 commit comments