Feature/#155 add cuda inference example - #210
Open
a-vartenkov wants to merge 29 commits into
Open
Conversation
artiomn
requested changes
Jul 30, 2026
artiomn
requested changes
Jul 31, 2026
| network.data_.inference_internal_projection_.end()) | ||
| network.network_.add_projection(std::move(projection)); | ||
| } | ||
| replace_wta_with_projections(network); |
| { | ||
| throw std::runtime_error("Not supported neuron type."); | ||
| } | ||
|
|
Comment on lines
+56
to
+59
| if (model_desc.type_ == SupportedModelType::BLIFAT) | ||
| network.network_.upcast_populations<knp::neuron_traits::BLIFATNeuron>(); | ||
| else if (model_desc.type_ == SupportedModelType::AltAI) | ||
| network.network_.upcast_populations<knp::neuron_traits::AltAILIF>(); |
Contributor
There was a problem hiding this comment.
По-моему, всё-таки это код Давида, иначе как оно вообще работало?
Comment on lines
+64
to
+80
| if (!model_desc.model_saving_path_.empty()) | ||
| { | ||
| if (!model_desc.inference_only_) | ||
| { | ||
| save_network(model_desc, network); | ||
| } | ||
| knp::framework::Network new_network = knp::framework::sonata::load_network(model_desc.model_saving_path_); | ||
| if (new_network.populations_count() != network.network_.populations_count() | ||
| || new_network.projections_count() != network.network_.projections_count()) | ||
| { | ||
| std::cout << "Populations " << new_network.populations_count() << " vs. " | ||
| << network.network_.populations_count() << std::endl; | ||
| std::cout << "Projections: " << new_network.projections_count() << " vs. " | ||
| << network.network_.projections_count() << std::endl; | ||
| } | ||
| network.network_ = new_network; | ||
| } |
| */ | ||
| std::filesystem::path model_saving_path_; | ||
|
|
||
| /// A flag to not do the training. |
| }; | ||
|
|
||
|
|
||
| struct ValueIndex |
| gather_index_neuron_kernel<<<num_blocks, num_threads>>>(index.view(), inputs, buffer); | ||
| // in-place prefix sum, for each neuron the value is the number of synapses before this, starts with 0. | ||
| thrust::exclusive_scan(thrust::device, buffer, buffer + inputs.size_, buffer); | ||
| return CUDAVector<unsigned long long>{buffer, inputs.size_}; // The vector would take care of releasing |
|
|
||
|
|
||
| template <typename BaseSynapseType> | ||
| void Network::upcast_projections() |
Contributor
There was a problem hiding this comment.
Думаю, что в Network этого быть не должно.
| is_converted = true; | ||
| return core::AllProjectionsVariant{res}; | ||
| } | ||
| return core::AllProjectionsVariant{proj}; // TODO: Remove unnecessary copying. |
| }, population); | ||
| if (is_converted) | ||
| { | ||
| population = std::move(new_population); |
Contributor
There was a problem hiding this comment.
А если она не сконвертирована?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding CUDA inference example. Now CUDA backend works at least with a decent speed.