-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from glinscott/next
get latest from leela-chess
- Loading branch information
Showing
23 changed files
with
1,334 additions
and
939 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,9 @@ tensorflow_cc = declare_dependency( | |
deps = [] | ||
deps += tensorflow_cc | ||
deps += cc.find_library('stdc++fs') | ||
deps += cc.find_library('libcublas', dirs: '/opt/cuda/lib64/') | ||
deps += cc.find_library('libcudnn', dirs: '/opt/cuda/lib64/') | ||
deps += cc.find_library('libcudart', dirs: '/opt/cuda/lib64/') | ||
deps += cc.find_library('libcublas', dirs: ['/opt/cuda/lib64/', '/usr/local/cuda/lib64/']) | ||
deps += cc.find_library('libcudnn', dirs: ['/opt/cuda/lib64/', '/usr/local/cuda/lib64/']) | ||
deps += cc.find_library('libcudart', dirs: ['/opt/cuda/lib64/', '/usr/local/cuda/lib64/']) | ||
# deps += dependency('libprofiler') | ||
|
||
nvcc = find_program('nvcc') | ||
|
@@ -38,7 +38,7 @@ cuda_files = [ | |
|
||
cuda_gen = generator(nvcc, | ||
output: '@[email protected]', | ||
arguments: ['-c', '@INPUT@', '-o', '@OUTPUT@', '-I', '../src'], | ||
arguments: ['--std=c++14', '-c', '@INPUT@', '-o', '@OUTPUT@', '-I', '../src'], | ||
) | ||
|
||
files = [ | ||
|
@@ -47,6 +47,7 @@ files = [ | |
'src/mcts/node.cc', | ||
'src/mcts/search.cc', | ||
'src/neural/cache.cc', | ||
'src/neural/factory.cc', | ||
'src/neural/loader.cc', | ||
'src/neural/writer.cc', | ||
'src/neural/network_mux.cc', | ||
|
@@ -82,12 +83,7 @@ test('ChessBoard', | |
files, include_directories: includes, dependencies: test_deps | ||
)) | ||
|
||
test('Network', | ||
executable('network_test', 'src/neural/network_test.cc', | ||
files, include_directories: includes, dependencies: test_deps | ||
)) | ||
|
||
test('HashCat', | ||
executable('hashcat_test', 'src/utils/hashcat_test.cc', | ||
files, include_directories: includes, dependencies: test_deps | ||
)) | ||
)) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
This file is part of Leela Chess Zero. | ||
Copyright (C) 2018 The LCZero Authors | ||
Leela Chess is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Leela Chess is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Leela Chess. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "neural/factory.h" | ||
|
||
#include <algorithm> | ||
#include <iostream> | ||
|
||
namespace lczero { | ||
|
||
NetworkFactory* NetworkFactory::Get() { | ||
static NetworkFactory factory; | ||
return &factory; | ||
} | ||
|
||
NetworkFactory::Register::Register(const std::string& name, FactoryFunc factory, | ||
int priority) { | ||
NetworkFactory::Get()->RegisterNetwork(name, factory, priority); | ||
}; | ||
|
||
void NetworkFactory::RegisterNetwork(const std::string& name, | ||
FactoryFunc factory, int priority) { | ||
factories_.emplace_back(name, factory, priority); | ||
std::sort(factories_.begin(), factories_.end()); | ||
} | ||
|
||
std::vector<std::string> NetworkFactory::GetBackendsList() const { | ||
std::vector<std::string> result; | ||
for (const auto& x : factories_) result.emplace_back(x.name); | ||
return result; | ||
} | ||
|
||
std::unique_ptr<Network> NetworkFactory::Create(const std::string& network, | ||
const Weights& weights, | ||
const OptionsDict& options) { | ||
for (const auto& factory : factories_) { | ||
if (factory.name == network) { | ||
return factory.factory(weights, options); | ||
} | ||
} | ||
throw Exception("Unknown backend: " + network); | ||
} | ||
|
||
} // namespace lczero |
Oops, something went wrong.