Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added interface to register loss from outside library #375

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/tiny-cuda-nn/loss.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,7 @@ std::unique_ptr<Loss<T>> default_loss(const std::string& name) {

std::vector<std::string> builtin_losses();

template <typename T>
void register_loss(const std::string& name, const std::function<Loss<T>*(const json&)>& factory);

}
3 changes: 3 additions & 0 deletions src/loss.cu
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ void register_loss(const std::string& name, const std::function<Loss<T>*(const j
register_loss(loss_factories<T>(), name, factory);
}

template void register_loss<float>(const std::string& name, const std::function<Loss<float>*(const json&)>& factory);
template void register_loss<__half>(const std::string& name, const std::function<Loss<__half>*(const json&)>& factory);

template <typename T>
Loss<T>* create_loss(const json& loss) {
std::string name = loss.value("otype", "RelativeL2");
Expand Down