Hey, here is some super strange behaviour for at::IntList
that I do not understand. I try to initialize a at::IntList
of class A
from class B
.
Main
#include <torch/torch.h>
#include <iostream>
class A {
public:
A(torch::IntList list) : list_(list) { };
void Print() { std::cout << list_ << std::endl; };
private:
torch::IntList list_;
};
class B {
public:
B(int64_t c, int64_t d) : a_({c, d}) { a_.Print(); };
void Print() { a_.Print(); };
private:
A a_;
};
int main() {
B b(10, 10);
b.Print();
return 0;
}
The output is
[10, 10]
[140726518609664, 4206890]
CMake
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
find_package(Torch REQUIRED)
include_directories(${Torch_INCLUDE_DIRS})
add_executable(main main.cpp)
target_link_libraries(main ${TORCH_LIBRARIES})
Is it a mistake or a bug? This thing blows up my whole code as libtorch trys to allocate tons of GB of RAM due to that.