Skip to content

Instantly share code, notes, and snippets.

import torch
from torch import tensor, device
import torch.fx as fx
from torch._dynamo.testing import rand_strided
from math import inf
import torch._inductor.inductor_prims
import torch._dynamo.config
import torch._inductor.config
import torch._functorch.config
@bdhirsh
bdhirsh / gist:7dadbf6296f8f7d1abcf4c482f438aaa
Created February 23, 2023 20:52
how to teach functionalization about a custom, mutable operator
// In my_cpp_file_that_registers_ops_to_the_dispatcher.cpp
#include <ATen/FunctionalTensorWrapper.h>
#include <torch/library.h>
// The implementation of my out-of-place op, "foo"
at::Tensor foo_impl(const at::Tensor& x) {
return x.mul(2);
}