MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / CLArrayAccessor

Class CLArrayAccessor

tests/CL/CLArrayAccessor.h:37–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35/** Accessor implementation for @ref CLArray objects. */
36template <typename T>
37class CLArrayAccessor : public IArrayAccessor<T>
38{
39public:
40 /** Create an accessor for the given @p array.
41 *
42 * @param[in, out] array To be accessed array.
43 *
44 * @note The CL memory is mapped by the constructor.
45 *
46 */
47 CLArrayAccessor(CLArray<T> &array) : _array{array}
48 {
49 _array.map();
50 }
51
52 /** Prevent instances of this class from being copy constructed */
53 CLArrayAccessor(const CLArrayAccessor &) = delete;
54 /** Prevent instances of this class from being copied */
55 CLArrayAccessor &operator=(const CLArrayAccessor &) = delete;
56 /** Allow instances of this class to be move constructed */
57 CLArrayAccessor(CLArrayAccessor &&) = default;
58 /** Allow instances of this class to be moved */
59 CLArrayAccessor &operator=(CLArrayAccessor &&) = default;
60
61 /** Destructor that unmaps the CL memory. */
62 ~CLArrayAccessor()
63 {
64 _array.unmap();
65 }
66
67 size_t num_values() const override
68 {
69 return _array.num_values();
70 }
71
72 T *buffer() override
73 {
74 return _array.buffer();
75 }
76
77 void resize(size_t num) override
78 {
79 _array.resize(num);
80 }
81
82 T &at(size_t index) const override
83 {
84 ARM_COMPUTE_ERROR_ON(_array.buffer() == nullptr);
85 ARM_COMPUTE_ERROR_ON(index >= num_values());
86 return _array.buffer()[index];
87 }
88
89private:
90 CLArray<T> &_array;
91};
92} // namespace test
93} // namespace arm_compute
94#endif // ACL_TESTS_CL_CLARRAYACCESSOR_H

Callers

nothing calls this directly

Calls 1

bufferMethod · 0.45

Tested by

no test coverage detected