no member named 'KInt16' in namespace 'torch'
I am working on a cpp extension for pytorch, and followed the official tutorial, using libtorch and cmake to compile the program. But I met the problem of creating tensor.
This code can work.
#include &lt;torch/torch.h&gt;
#include &lt;iostream&gt;
int main(){
    std::vector&lt;int64_t&gt; test_data = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    torch::Tensor s = torch::from_blob(test_data.data(), {3, 3}, torch::kInt64);
    std::cout &lt;&lt; &quot;test case pass&quot; &lt;&lt; std::endl;
}

But this code can't work.
int main(){
    auto option = torch::TensorOptions().dtype(torch::KInt16);
    auto b = torch::zeros({2,3}, option);
    std::cout &lt;&lt; &quot;test case pass&quot; &lt;&lt; std::endl;
}

and the compile error log is here.
error: no member named 'KInt16' in namespace 'torch'; did you mean 'kInt16'?


As explicitly stated by the error message, you made a typo : you should have written
torch::kInt16 instead of torch::KInt16. The k should not be capitalized.
