<commit_before>//=======================================================================
// Copyright (c) 2014 <NAME>
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#ifndef DLL_RBM_TRAITS_HPP
#define DLL_RBM_TRAITS_HPP

#include "tmp.hpp"
#include "decay_type.hpp"
#include "sparsity_method.hpp"

namespace dll {

template<typename Desc>
struct dyn_rbm;

template<typename Desc>
struct conv_rbm;

template<typename Desc>
struct conv_rbm_mp;

/*!
 * \brief Type Traits to get information on RBM type
 */
template<typename RBM>
struct rbm_traits {
    using rbm_t = RBM;

    HAS_STATIC_FIELD(BatchSize, has_batch_size_field)
    HAS_STATIC_FIELD(Sparsity, has_sparsity_field)
    HAS_STATIC_FIELD(Decay, has_decay_field)
    HAS_STATIC_FIELD(Init, has_init_field)
    HAS_STATIC_FIELD(Momentum, has_momentum_field)
    HAS_STATIC_FIELD(Bias, has_bias_field)
    HAS_STATIC_FIELD(Shuffle, has_shuffle_field)

    /*!
     * \brief Indicates if the RBM is convolutional
     */
    static constexpr bool is_convolutional(){
        return cpp::is_specialization_of<conv_rbm, rbm_t>::value
            || cpp::is_specialization_of<conv_rbm_mp, rbm_t>::value;
    }

    /*!
     * \brief Indicates if the RBM is dynamic
     */
    static constexpr bool is_dynamic(){
        return cpp::is_specialization_of<dyn_rbm, rbm_t>::value;
    }

    /*!
     * \brief Indicates if the RBM is convolutional and has probabilistic max
     * pooling
     */
    static constexpr bool has_probabilistic_max_pooling(){
        return cpp::is_specialization_of<conv_rbm_mp, rbm_t>::value;
    }

    static constexpr std::size_t input_size(){
        return rbm_t::input_size();
    }

    static constexpr std::size_t output_size(){
        return rbm_t::output_size();
    }

    template<typename R = RBM, cpp::enable_if_u<has_batch_size_field<typename R::desc>::value> = cpp::detail::dummy>
    static constexpr std::size_t batch_size(){
        return rbm_t::desc::BatchSize;
    }

    template<typename R = RBM, cpp::disable_if_u<has_batch_size_field<typename R::desc>::value> = cpp::detail::dummy>
    static constexpr std::size_t batch_size(){
        return 1;
    }

    template<typename R = RBM, cpp::enable_if_u<has_momentum_field<typename R::desc>::value> = cpp::detail::dummy>
    static constexpr bool has_momentum(){
        return rbm_t::desc::Momentum;
    }

    template<typename R = RBM, cpp::disable_if_u<has_momentum_field<typename R::desc>::value> = cpp::detail::dummy>
    static constexpr bool has_momentum(){
        return false;
    }

    template<typename R = RBM, cpp::enable_if_u<has_shuffle_field<typename R::desc>::value> = cpp::detail::dummy>
    static constexpr bool has_shuffle(){
        return rbm_t::desc::Shuffle;
    }

    template<typename R = RBM, cpp::disable_if_u<has_shuffle_field<typename R::desc>::value> = cpp::detail::dummy>
    static constexpr bool has_shuffle(){
        return false;<commit_msg>Add is_parallel traits<commit_after>//=======================================================================
// Copyright (c) 2014 <NAME>
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#ifndef DLL_RBM_TRAITS_HPP
#define DLL_RBM_TRAITS_HPP

#include "tmp.hpp"
#include "decay_type.hpp"
#include "sparsity_method.hpp"

namespace dll {

template<typename Desc>
struct dyn_rbm;

template<typename Desc>
struct conv_rbm;

template<typename Desc>
struct conv_rbm_mp;

/*!
 * \brief Type Traits to get information on RBM type
 */
template<typename RBM>
struct rbm_traits {
    using rbm_t = RBM;

    HAS_STATIC_FIELD(BatchSize, has_batch_size_field)
    HAS_STATIC_FIELD(Sparsity, has_sparsity_field)
    HAS_STATIC_FIELD(Decay, has_decay_field)
    HAS_STATIC_FIELD(Init, has_init_field)
    HAS_STATIC_FIELD(Momentum, has_momentum_field)
    HAS_STATIC_FIELD(Parallel, has_parallel_field)
    HAS_STATIC_FIELD(Bias, has_bias_field)
    HAS_STATIC_FIELD(Shuffle, has_shuffle_field)

    /*!
     * \brief Indicates if the RBM is convolutional
     */
    static constexpr bool is_convolutional(){
        return cpp::is_specialization_of<conv_rbm, rbm_t>::value
            || cpp::is_specialization_of<conv_rbm_mp, rbm_t>::value;
    }

    /*!
     * \brief Indicates if the RBM is dynamic
     */
    static constexpr bool is_dynamic(){
        return cpp::is_specialization_of<dyn_rbm, rbm_t>::value;
    }

    /*!
     * \brief Indicates if the RBM is convolutional and has probabilistic max
     * pooling
     */
    static constexpr bool has_probabilistic_max_pooling(){
        return cpp::is_specialization_of<conv_rbm_mp, rbm_t>::value;
    }

    static constexpr std::size_t input_size(){
        return rbm_t::input_size();
    }

    static constexpr std::size_t output_size(){
        return rbm_t::output_size();
    }

    template<typename R = RBM, cpp::enable_if_u<has_batch_size_field<typename R::desc>::value> = cpp::detail::dummy>
    static constexpr std::size_t batch_size(){
        return rbm_t::desc::BatchSize;
    }

    template<typename R = RBM, cpp::disable_if_u<has_batch_size_field<typename R::desc>::value> = cpp::detail::dummy>
    static constexpr std::size_t batch_size(){
        return 1;
    }

    template<typename R = RBM, cpp::enable_if_u<has_momentum_field<typename R::desc>::value> = cpp::detail::dummy>
    static constexpr bool has_momentum(){
        return rbm_t::desc::Momentum;
    }

    template<typename R = RBM, cpp::disable_if_u<has_momentum_field<typename R::desc>::value> = cpp::detail::dummy>
    static constexpr bool has_momentum(){
        return false;
    }

    template<typename R = RBM, cpp::enable_if_u<has_parallel_field<typename R::desc>::value> = cpp::detail::dummy>
    static constexpr bool is_parallel(){
        return rbm_t::desc::Parallel;
    }

    template<typename R = RBM, cpp::disable_if_u<has_parallel_field<typename R::desc>::value> = cpp::detail::dummy>
    static constexpr bool is_parallel(){
        return false;
    }

    template<typename R = RBM, cpp::enable_if_u<has_shuffle_field<typename R::desc>::value> = cpp::detail::dummy>
    static constexpr bool has_shuffle(){
        return rbm_t::desc::Shuffle;
    }

    template<typename R = RBM, cpp::disable_if_u<has_shuffle_field<typename R::desc>::value> = cpp::detail::dummy>
    static constexpr bool has_shuffle(){
        return false;
{'fraction_non_alphanumeric': 0.15105967232827297, 'fraction_numerical': 0.0015030813166992333, 'mean_word_length': 4.251775848460931, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2613647', 'n_tokens_mistral': 2256, 'n_tokens_neox': 2124, 'n_words': 443}