Skip to content
Snippets Groups Projects
Commit f1d56167 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Clarified resize() behavior

parent 950d8673
No related branches found
No related tags found
1 merge request!57Add Convert operator (a.k.a. Transmitter)
Pipeline #35572 failed
......@@ -446,9 +446,15 @@ class Tensor : public Data,
constexpr std::size_t sizeM1() const { return mSizeM1; }
/**
* @brief Change the shape of the Tensor object according to the given argument.
* @tparam DIM new dimensions.
* @param dims
* @brief Change the dimensions of the Tensor object according to the given argument.
* If the overall size is not changed (meaning we actually only performed a
* reshape), data is garanteed to remain valid.
* Otherwise, no garantee is provided regarding the validy of previous data
* (unlike std::vector). If the new overall size is larger than the previous
* one, all previous data is invalided. Otherwise, previous data may or may
* not remain valid, depending on the backend implementation.
* @tparam DIM Number of dimensions.
* @param dims New dimensions
*/
template <std::array<DimSize_t, 1>::size_type DIM> // deducing std::array size_type and declaring DIM accordingly
void resize(const std::array<DimSize_t, DIM> &dims) {
......@@ -457,6 +463,16 @@ class Tensor : public Data,
computeSize();
}
/**
* @brief Change the dimensions of the Tensor object according to the given argument.
* If the overall size is not changed (meaning we actually only performed a
* reshape), data is garanteed to remain valid.
* Otherwise, no garantee is provided regarding the validy of previous data
* (unlike std::vector). If the new overall size is larger than the previous
* one, all previous data is invalided. Otherwise, previous data may or may
* not remain valid, depending on the backend implementation.
* @param dims New dimensions
*/
void resize(const std::vector<DimSize_t> &dims) {
mDims = dims;
computeSize();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment