Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 0 additions & 142 deletions include/tensorwrapper/buffer/buffer_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,6 @@ class BufferBase : public detail_::PolymorphicBase<BufferBase> {
/// Type of a pointer to the layout
using layout_pointer = typename layout_type::layout_pointer;

/// Type of labels for making a labeled buffer
using label_type = std::string;

/// Type of a labeled buffer
using labeled_buffer_type = dsl::Labeled<buffer_base_type, label_type>;

/// Type of a labeled read-only buffer (n.b. labels are mutable)
using labeled_const_buffer_type = dsl::Labeled<const buffer_base_type>;

/// Type of a read-only reference to a labeled_buffer_type object
using const_labeled_buffer_reference = const labeled_const_buffer_type&;

// -------------------------------------------------------------------------
// -- Accessors
// -------------------------------------------------------------------------
Expand Down Expand Up @@ -102,128 +90,10 @@ class BufferBase : public detail_::PolymorphicBase<BufferBase> {
return *m_layout_;
}

// -------------------------------------------------------------------------
// -- BLAS Operations
// -------------------------------------------------------------------------

/** @brief Set this to the result of *this + rhs.
*
* This method will overwrite the state of *this with the result of
* adding the original state of *this to that of @p rhs. Depending on the
* value @p this_labels compared to the labels associated with @p rhs,
* it may be a permutation of @p rhs that is added to *this.
*
* @param[in] this_labels The labels to associate with the modes of *this.
* @param[in] rhs The buffer to add into *this.
*
* @throws ??? Throws if the derived class's implementation throws. Same
* throw guarantee.
*/
buffer_base_reference addition_assignment(
label_type this_labels, const_labeled_buffer_reference rhs) {
return addition_assignment_(std::move(this_labels), rhs);
}

/** @brief Returns the result of *this + rhs.
*
* This method is the same as addition_assignment except that the result
* is returned in a newly allocated buffer instead of overwriting *this.
*
* @param[in] this_labels the labels for the modes of *this.
* @param[in] rhs The buffer to add to *this.
*
* @return The buffer resulting from adding *this to @p rhs.
*
* @throw std::bad_alloc if there is a problem copying *this. Strong throw
* guarantee.
* @throw ??? If addition_assignment throws when adding @p rhs to the
* copy of *this. Same throw guarantee.
*/
buffer_base_pointer addition(label_type this_labels,
const_labeled_buffer_reference rhs) const {
auto pthis = clone();
pthis->addition_assignment(std::move(this_labels), rhs);
return pthis;
}

/** @brief Sets *this to a permutation of @p rhs.
*
* `rhs.rhs()` are the dummy indices associated with the modes of the
* buffer in @p rhs and @p this_labels are the dummy indices associated
* with the buffer in *this. This method will permute @p rhs so that the
* resulting buffer's modes are ordered consistently with @p this_labels,
* i.e. the permutation is FROM the `rhs.rhs()` order TO the
* @p this_labels order. This is seemingly backwards when described out,
* but consistent with the intent of a DSL expression like
* `t("i,j") = x("j,i");` where the intent is to set `t` equal to the
* transpose of `x`.
*
* @param[in] this_labels the dummy indices for the modes of *this.
* @param[in] rhs The tensor to permute.
*
* @return *this after setting it equal to a permutation of @p rhs.
*
* @throw ??? If the derived class's implementation of permute_assignment_
* throws. Same throw guarantee.
*/
buffer_base_reference permute_assignment(
label_type this_labels, const_labeled_buffer_reference rhs) {
return permute_assignment_(std::move(this_labels), rhs);
}

/** @brief Returns a copy of *this obtained by permuting *this.
*
* This method simply calls permute_assignment on a copy of *this. See the
* description of permute_assignment for more details.
*
* @param[in] this_labels dummy indices representing the modes of *this in
* its current state.
* @param[in] out_labels how the user wants the modes of *this to be
* ordered.
*
* @throw std::bad_alloc if there is a problem allocating the copy. Strong
* throw guarantee.
* @throw ??? If the derived class's implementation of permute_assignment_
* throws. Same throw guarantee.
*/
buffer_base_pointer permute(label_type this_labels,
label_type out_labels) const {
auto pthis = clone();
pthis->permute_assignment(std::move(out_labels), (*this)(this_labels));
return pthis;
}

// -------------------------------------------------------------------------
// -- Utility methods
// -------------------------------------------------------------------------

/** @brief Associates labels with the modes of *this.
*
* This method is used to create a labeled buffer object by pairing *this
* with the provided labels. The resulting object is capable of being
* composed via the DSL.
*
* @param[in] labels The indices to associate with the modes of *this.
*
* @return A DSL term pairing *this with @p labels.
*
* @throw None No throw guarantee.
*/
labeled_buffer_type operator()(label_type labels);

/** @brief Associates labels with the modes of *this.
*
* This method is the same as the non-const version except that the result
* contains a read-only reference to *this.
*
* @param[in] labels The labels to associate with *this.
*
* @return A DSL term pairing *this with @p labels.
*
* @throw None No throw guarantee.
*/
labeled_const_buffer_type operator()(label_type labels) const;

/** @brief Is *this value equal to @p rhs?
*
* Two BufferBase objects are value equal if the layouts they contain are
Expand Down Expand Up @@ -321,18 +191,6 @@ class BufferBase : public detail_::PolymorphicBase<BufferBase> {
return *this;
}

/// Derived class should overwrite to implement addition_assignment
virtual buffer_base_reference addition_assignment_(
label_type this_labels, const_labeled_buffer_reference rhs) {
throw std::runtime_error("Addition assignment NYI");
}

/// Derived class should overwrite to implement permute_assignment
virtual buffer_base_reference permute_assignment_(
label_type this_labels, const_labeled_buffer_reference rhs) {
throw std::runtime_error("Permute assignment NYI");
}

private:
/// Throws std::runtime_error when there is no layout
void assert_layout_() const {
Expand Down
10 changes: 0 additions & 10 deletions include/tensorwrapper/buffer/eigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ class Eigen : public Replicated {
/// Pull in base class's types
using typename my_base_type::buffer_base_pointer;
using typename my_base_type::const_buffer_base_reference;
using typename my_base_type::const_labeled_buffer_reference;
using typename my_base_type::const_layout_reference;
using typename my_base_type::label_type;

/// Type of a rank @p Rank tensor using floats of type @p FloatType
using data_type = eigen::data_type<FloatType, Rank>;
Expand Down Expand Up @@ -182,14 +180,6 @@ class Eigen : public Replicated {
return my_base_type::are_equal_impl_<my_type>(rhs);
}

/// Implements addition_assignment by rebinding rhs to an Eigen buffer
buffer_base_reference addition_assignment_(
label_type this_labels, const_labeled_buffer_reference rhs) override;

/// Implements permute assignment by deferring to Eigen's shuffle command.
buffer_base_reference permute_assignment_(
label_type this_labels, const_labeled_buffer_reference rhs) override;

/// Implements to_string
typename my_base_type::string_type to_string_() const override;

Expand Down
Loading
Loading