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

Update for libtorch 2.0 #1219

Merged
merged 3 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions open_spiel/algorithms/dqn_torch/dqn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void DQN::Learn() {
legal_actions_mask.push_back(
torch::from_blob(t.legal_actions_mask.data(),
{1, t.legal_actions_mask.size()},
torch::TensorOptions().dtype(torch::kInt32))
torch::TensorOptions().dtype(torch::kBool))
.clone());
actions.push_back(t.action);
rewards.push_back(t.reward);
Expand All @@ -231,7 +231,7 @@ void DQN::Learn() {
next_info_states_tensor).detach();

torch::Tensor illegal_action_masks_tensor =
1.0 - torch::stack(legal_actions_mask, 0);
torch::stack(legal_actions_mask, 0).bitwise_not();
torch::Tensor legal_q_values =
torch::masked_fill(target_q_values, illegal_action_masks_tensor,
kIllegalActionLogitsPenalty);
Expand Down
2 changes: 1 addition & 1 deletion open_spiel/scripts/global_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export OPEN_SPIEL_BUILD_WITH_LIBTORCH="${OPEN_SPIEL_BUILD_WITH_LIBTORCH:-"OFF"}"
# Note: there are currently known problems with the C++ PyTorch: inteferences
# with pybind11 versions. Until it is properly fixed, there is a workaround:
# https://github.com/deepmind/open_spiel/issues/966#issuecomment-1322982393
export OPEN_SPIEL_BUILD_WITH_LIBTORCH_DOWNLOAD_URL="${OPEN_SPIEL_BUILD_WITH_LIBTORCH_DOWNLOAD_URL:-"https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.10.1%2Bcpu.zip"}"
export OPEN_SPIEL_BUILD_WITH_LIBTORCH_DOWNLOAD_URL="${OPEN_SPIEL_BUILD_WITH_LIBTORCH_DOWNLOAD_URL:-"https://download.pytorch.org/libtorch/cu121/libtorch-win-shared-with-deps-2.3.0%2Bcu121.zip"}"
tacertain marked this conversation as resolved.
Show resolved Hide resolved

# Enable integration with GAMUT game generator (see games/gamut).
# Requires java and GAMUT, so disabled by default.
Expand Down