vector.data() would convert std::vector to float*, which can be passed into torch::from_blob().

at::ArrayRef shouldn’t make things faster, and auto input_ = torch::from_blob(img.data, {img.rows, img.cols, 3}) should just work.

torch::from_blob() calls tensorFromBlob() internally (https://github.com/pytorch/pytorch/blob/075c7b1fef537205a0bdb8e45d2f800e6c024603/aten/src/ATen/templates/NativeFunctions.h#L28-L34 61). The only difference with those two statements is where the device and data type is specified (for  torch::from_blob() we can pass a TensorOptions param to specify device and data type).
If module is a JIT model, the result of module->forward(inputs) is a torch::jit::IValue, and toTensor() retrieves the torch::Tensor from it. If If module is a C++ frontned model, the result of module->forward(inputs) should already be a torch::Tensor and we don’t need toTensor().