What do you mean by “nothing”? Is the cout not printing anything?
This code snippet works for me:
from torch.utils import cpp_extension

cpp_source = """
torch::Tensor my_fun(torch::Tensor x){
    auto srcdata = x.accessor<float, 3>();
    for (int i = 0; i < srcdata.size(0); i++) {
        int max_index = 0;
        float max_value = -1000;
        for (int j = 0; j < srcdata.size(1); j++) {
            for (int k =0;k< srcdata.size(2);k++){
                std::cout << "srcdata[" << i << "][" << j << "][" << k << "]: " << srcdata[i][j][k] << std::endl;
                if (srcdata[i][j][k] > max_value) {
                    max_value = srcdata[i][j][k];
                    max_index = k;
                }
            }
        }
    }
    return x;
}
"""

module = torch.utils.cpp_extension.load_inline(
    name="test_extension",
    cpp_sources=cpp_source,
    functions="my_fun",
    verbose=True,
)

x = torch.randn(3, 3, 3)
out = module.my_fun(x)
print(out)
print('done')