Beispiel #1
0
void param_entry_append(param_entry *p, const char *buf, size_t len) {
  if (p->is_file) {
    fwrite(buf, sizeof(char), len, p->file);
  } else {
    char *data_chunk = copy_chunk_from_buffer(buf, len);
    p->val = str_concat(p->val, data_chunk);
    free(data_chunk);
  }
}
void *AugmentationNode::run()
{

	_runtimeStart = utils::get_time();


	while(true) {

		copy_chunk_from_buffer(_data_buffer, _labels_buffer);

		if( _data_buffer.size() >= _transferSize ) {

			augment_images(_data_buffer, _labels_buffer);

			// Clear buffers for next block of data
			_data_buffer.clear();
			_labels_buffer.clear();

		} else {

			// Check if all input nodes have already finished
			bool is_all_done = true;

			for(vector<int>::size_type i=0; i < _in_edges.size(); i++) {

				if( !_in_edges.at(i)->is_in_node_done() ) {
					is_all_done = false;
					break;
				}
			}			

			// All input nodes have finished
			if( is_all_done ) {

				if( _data_buffer.size() > 0 ) {
					augment_images(_data_buffer, _labels_buffer);
					_data_buffer.clear();
					_labels_buffer.clear();
				}

			
				cout << "******************" << endl 
					 << "AugmentationNode" << endl 
					 << "Run time: " << to_string(utils::get_time() - _runtimeStart) << endl 
					 << "# of elements: " << to_string(_counter) << endl 
					 << "******************" << endl;

				// Notify it has finished
				for(vector<int>::size_type i=0; i < _out_edges.size(); i++) {
					_out_edges.at(i)->set_in_node_done();
				}
				break;
			}
		}
	}
	return NULL;
}