<commit_before>/*
 * Ensemble - Data
 *
 * Authors:
 *   - <NAME> <<EMAIL>>
 *   - <NAME>
 * 
 * Copyright:
 *   - Advanced Processor Technologies, School of Computer Science,
 *      University of Manchester
 *   - Computational Neuroscience Research Group, Centre for
 *      Theoretical Neuroscience, University of Waterloo
 * 
 */

#include "ensemble.h"

bool data_system( address_t addr ) {
  initialise_ensemble(
    (region_system_t *) addr
  );
  return true;
}

bool data_get_bias(
  address_t addr,
  uint n_neurons
){
  spin1_memcpy( g_ensemble.i_bias, addr,
    n_neurons * sizeof( current_t ) );
  return true;
}

bool data_get_encoders(
  address_t addr,
  uint n_neurons,
  uint n_input_dimensions
){
  spin1_memcpy( g_ensemble.encoders, addr,
    n_neurons * n_input_dimensions * sizeof( value_t ) );
  return true;
}

bool data_get_decoders(
  address_t addr,
  uint n_neurons,
  uint n_output_dimensions
){
  spin1_memcpy( g_ensemble.decoders, addr,
    n_neurons * n_output_dimensions * sizeof( value_t ) );

  for( uint n = 0; n < n_neurons; n++ ){
    io_printf( IO_BUF, "Decoder[%d] = ", n );
    for( uint d = 0; d < n_output_dimensions; d++ ){
      io_printf( IO_BUF, "%k, ", neuron_decoder( n, d ) );
    }
    io_printf( IO_BUF, "\n" );
  }

  return true;
}

bool data_get_keys(
  address_t addr,
  uint n_output_dimensions
){
  spin1_memcpy( gp_output_keys, addr,
    n_output_dimensions * sizeof( uint ) );
  return true;
}

bool data_get_filters( address_t addr, region_system_t *pars ) {
  // TODO: Be less hacky
  for( uint f = 0; f < pars->n_filters; f++ ){
    g_input.filters[f]->filter = addr[3*f + 0];
    g_input.filters[f]->n_filter = addr[3*f + 1];
    g_input.filters[f]->mask = addr[3*f + 2];
    g_input.filters[f]->mask_ = ~(addr[3*f + 2]);

    io_printf(IO_BUF, "Filter[%d] = %k, %k\n", f,
      g_input.filters[f]->filter,
      g_input.filters[f]->n_filter
    );
  }
  return true;
}

bool data_get_filter_keys( address_t addr, region_system_t *pars ) {<commit_msg>Fixed filter value<commit_after>/*
 * Ensemble - Data
 *
 * Authors:
 *   - <NAME> <<EMAIL>>
 *   - <NAME>
 * 
 * Copyright:
 *   - Advanced Processor Technologies, School of Computer Science,
 *      University of Manchester
 *   - Computational Neuroscience Research Group, Centre for
 *      Theoretical Neuroscience, University of Waterloo
 * 
 */

#include "ensemble.h"

bool data_system( address_t addr ) {
  initialise_ensemble(
    (region_system_t *) addr
  );
  return true;
}

bool data_get_bias(
  address_t addr,
  uint n_neurons
){
  spin1_memcpy( g_ensemble.i_bias, addr,
    n_neurons * sizeof( current_t ) );
  return true;
}

bool data_get_encoders(
  address_t addr,
  uint n_neurons,
  uint n_input_dimensions
){
  spin1_memcpy( g_ensemble.encoders, addr,
    n_neurons * n_input_dimensions * sizeof( value_t ) );
  return true;
}

bool data_get_decoders(
  address_t addr,
  uint n_neurons,
  uint n_output_dimensions
){
  spin1_memcpy( g_ensemble.decoders, addr,
    n_neurons * n_output_dimensions * sizeof( value_t ) );

  for( uint n = 0; n < n_neurons; n++ ){
    io_printf( IO_BUF, "Decoder[%d] = ", n );
    for( uint d = 0; d < n_output_dimensions; d++ ){
      io_printf( IO_BUF, "%k, ", neuron_decoder( n, d ) );
    }
    io_printf( IO_BUF, "\n" );
  }

  return true;
}

bool data_get_keys(
  address_t addr,
  uint n_output_dimensions
){
  spin1_memcpy( gp_output_keys, addr,
    n_output_dimensions * sizeof( uint ) );
  return true;
}

bool data_get_filters( address_t addr, region_system_t *pars ) {
  // TODO: Be less hacky
  for( uint f = 0; f < pars->n_filters; f++ ){
    g_input.filters[f]->filter = kbits(addr[3*f + 0]);
    g_input.filters[f]->n_filter = kbits(addr[3*f + 1]);
    g_input.filters[f]->mask = addr[3*f + 2];
    g_input.filters[f]->mask_ = ~(addr[3*f + 2]);

    io_printf(IO_BUF, "Filter[%d] = %k, %k\n", f,
      g_input.filters[f]->filter,
      g_input.filters[f]->n_filter
    );
  }
  return true;
}

bool data_get_filter_keys( address_t addr, region_system_t *pars ) {
{'fraction_non_alphanumeric': 0.13287231415164238, 'fraction_numerical': 0.007409236848604593, 'mean_word_length': 3.4262295081967213, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, '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': '405166', 'n_tokens_mistral': 1597, 'n_tokens_neox': 1554, 'n_words': 348}