Skip to content

Commit

Permalink
Prepare for "Fix type-safety of torch.nn.Module instances": fbcode/…
Browse files Browse the repository at this point in the history
…p* (#1448)

Summary:
Pull Request resolved: #1448

See D52890934

Reviewed By: r-barnes

Differential Revision: D66235323

fbshipit-source-id: a8781d76a63bf8003761055d7808190f73dea5e9
  • Loading branch information
ezyang authored and facebook-github-bot committed Nov 21, 2024
1 parent 72a32af commit 478942d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion captum/attr/_core/feature_ablation.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,10 @@ def _construct_ablated_input(
current_mask = current_mask.to(expanded_input.device)
assert baseline is not None, "baseline must be provided"
ablated_tensor = (
expanded_input * (1 - current_mask).to(expanded_input.dtype)
expanded_input
* (1 - current_mask).to(expanded_input.dtype)
# pyre-fixme[58]: `*` is not supported for operand types `Union[None, float,
# Tensor]` and `Tensor`.
) + (baseline * current_mask.to(expanded_input.dtype))
return ablated_tensor, current_mask

Expand Down
2 changes: 2 additions & 0 deletions captum/attr/_core/occlusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ def _construct_ablated_input(
torch.ones(1, dtype=torch.long, device=expanded_input.device)
- input_mask
).to(expanded_input.dtype)
# pyre-fixme[58]: `*` is not supported for operand types `Union[None, float,
# Tensor]` and `Tensor`.
) + (baseline * input_mask.to(expanded_input.dtype))
return ablated_tensor, input_mask

Expand Down

0 comments on commit 478942d

Please sign in to comment.