Skip to content

Feature/#155 add cuda inference example - #210

Open
a-vartenkov wants to merge 29 commits into
KasperskyLab:masterfrom
a-vartenkov:feature/#155-add-cuda-inference-example
Open

Feature/#155 add cuda inference example#210
a-vartenkov wants to merge 29 commits into
KasperskyLab:masterfrom
a-vartenkov:feature/#155-add-cuda-inference-example

Conversation

@a-vartenkov

Copy link
Copy Markdown
Collaborator

Adding CUDA inference example. Now CUDA backend works at least with a decent speed.

Comment thread examples/mnist-client/inference.cpp
network.data_.inference_internal_projection_.end())
network.network_.add_projection(std::move(projection));
}
replace_wta_with_projections(network);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А это что?

{
throw std::runtime_error("Not supported neuron type.");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 строки.

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>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

По-моему, всё-таки это код Давида, иначе как оно вообще работало?

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;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что это такое?

*/
std::filesystem::path model_saving_path_;

/// A flag to not do the training.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может, лучше в тэги?

};


struct ValueIndex

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Несколько комментов бы.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше коммент наверх.



template <typename BaseSynapseType>
void Network::upcast_projections()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Думаю, что в Network этого быть не должно.

is_converted = true;
return core::AllProjectionsVariant{res};
}
return core::AllProjectionsVariant{proj}; // TODO: Remove unnecessary copying.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Коммент наверх.

}, population);
if (is_converted)
{
population = std::move(new_population);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А если она не сконвертирована?

@artiomn artiomn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

См. комменты.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants