天天看點

“load”: 不是“torch::jit”的成員

嚴重性    代碼    說明    項目    檔案    行    禁止顯示狀态

錯誤    C2039    “load”: 不是“torch::jit”的成員    simnet    d:\soft\libtorch-win-shared-with-deps-latest\build_person\main2.cpp    59    

解決:

加上頭檔案:

#include <torch/script.h> // One-stop header.

#include <torch/script.h>

	torch::DeviceType device_type;

	if (torch::cuda::is_available()) {
		device_type = torch::kCUDA;
	}
	else {
		device_type = torch::kCPU;
	}
	torch::Device device(device_type);


	// Deserialize the ScriptModule from a file using torch::jit::load().
	//反序列化pytorch模型,并加載到module變量
	std::shared_ptr<torch::jit::script::Module> module = torch::jit::load(argv[1], device);

	assert(module != nullptr);
           

torch::jit 沒有成員load