FAST  3.2.0
Framework for Heterogeneous Medical Image Computing and Visualization
Tensor.hpp
Go to the documentation of this file.
1 #pragma once
2 
7 
8 namespace fast {
9 
10 class OpenCLBufferAccess;
11 
12 class FAST_EXPORT Tensor : public SpatialDataObject {
14  public:
20  virtual void create(std::unique_ptr<float[]> data, TensorShape shape);
26  virtual void create(const float* const data, TensorShape shape);
27 
32  virtual void create(TensorShape shape);
37  virtual void create(std::initializer_list<float> data);
42  virtual void expandDims(int position = 0);
43  virtual TensorShape getShape() const;
44  virtual TensorAccess::pointer getAccess(accessType type);
45  virtual std::unique_ptr<OpenCLBufferAccess> getOpenCLBufferAccess(accessType type, OpenCLDevice::pointer);
46  virtual void freeAll() override;
47  virtual void free(ExecutionDevice::pointer device) override;
48  virtual void setSpacing(VectorXf spacing);
49  virtual VectorXf getSpacing() const;
50  virtual void deleteDimension(int dimension);
51 
52  virtual DataBoundingBox getTransformedBoundingBox() const override;
53  virtual DataBoundingBox getBoundingBox() const override;
54  virtual ~Tensor();
55 
56  protected:
57  Tensor() = default;
58  virtual bool isInitialized();
59  virtual void transferCLBufferFromHost(OpenCLDevice::pointer device);
60  void transferCLBufferToHost(OpenCLDevice::pointer device);
61  void updateOpenCLBufferData(OpenCLDevice::pointer device);
62  void setAllDataToOutOfDate();
63  virtual bool hasAnyData();
64  void updateHostData();
65  virtual float* getHostDataPointer();
66 
67  std::unique_ptr<float[]> m_data;
68  std::unordered_map<std::shared_ptr<OpenCLDevice>, cl::Buffer*> mCLBuffers;
69  std::unordered_map<std::shared_ptr<OpenCLDevice>, bool> mCLBuffersIsUpToDate;
72 
73  VectorXf m_spacing;
74 
75  friend TensorAccess;
77 };
78 
79 }
fast::ExecutionDevice::pointer
std::shared_ptr< ExecutionDevice > pointer
Definition: ExecutionDevice.hpp:11
fast::Tensor::OpenCLBufferAccess
friend OpenCLBufferAccess
Definition: Tensor.hpp:76
fast::TensorShape
Definition: TensorShape.hpp:9
TensorShape.hpp
fast
Definition: AffineTransformation.hpp:7
fast::Tensor::m_data
std::unique_ptr< float[]> m_data
Definition: Tensor.hpp:67
fast::TensorAccess::pointer
std::unique_ptr< TensorAccess > pointer
Definition: TensorAccess.hpp:17
fast::Tensor::m_spacing
VectorXf m_spacing
Definition: Tensor.hpp:73
Access.hpp
FAST_OBJECT
#define FAST_OBJECT(className)
Definition: Object.hpp:9
SpatialDataObject.hpp
fast::Tensor::mCLBuffers
std::unordered_map< std::shared_ptr< OpenCLDevice >, cl::Buffer * > mCLBuffers
Definition: Tensor.hpp:68
fast::Tensor::mCLBuffersIsUpToDate
std::unordered_map< std::shared_ptr< OpenCLDevice >, bool > mCLBuffersIsUpToDate
Definition: Tensor.hpp:69
fast::Tensor
Definition: Tensor.hpp:12
fast::Tensor::m_shape
TensorShape m_shape
Definition: Tensor.hpp:70
accessType
accessType
Definition: Access.hpp:5
fast::Tensor::mHostDataIsUpToDate
bool mHostDataIsUpToDate
Definition: Tensor.hpp:71
TensorAccess.hpp
fast::Tensor::TensorAccess
friend TensorAccess
Definition: Tensor.hpp:75
fast::SpatialDataObject
Definition: SpatialDataObject.hpp:10
fast::DataBoundingBox
Definition: DataBoundingBox.hpp:13