Accessor failed

auto srcdata = score.accessor<float,3>();

cout << srcdata[0][0][0] << endl;
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++)
		{
			cout << "maxvalue:" << srcdata[i][j][k] << endl;
			if (srcdata[i][j][k] > max_value) {
				max_value = srcdata[i][j][k];
				max_index = k;
			}

		}

but i get nothing by srcdata[i][j][k]

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')

when i execute ```
std::cout<<srcdata[i][j][k]<<endl:

i can not print nothing, why can you get the data in ```
srcdata and success get the value, is libtorch version?

Could you try to run my code and check, if you get valid outputs, please?
The code should be executable in your Python IDE.
I’m using the latest nightly binary.

t have tried,your code is right, it can get the value in ```
srcdata

std::vector<std::vector> crnn_deocdeMat(torch::Tensor score, std::vectorstd::string alphabetChinese) {

score = score.permute({1,0,2});
c10::IntList score_size = score.sizes();
cout << "score_size:" << score_size << endl;
//const float* srcdata = reinterpret_cast<const float *>(score.data_ptr());
auto srcdata = score.accessor<float,3>();
cout << ";;;;" << srcdata[0][0][0] << endl;

}
cout << “;;;;” << srcdata[0][0][0] << endl;this line print nothing,i dont know why,it si so strange