It depends on your application. But say that you have the data you want to pass to your tensor in a array, say int x[4] = {1, 2, 3, 4}, then you can create a tensor by putting x as argument.
#include <torch/torch.h>
#include <iostream>

int main(){
	int x[4] = {1, 2, 3, 4};
	torch::Tensor tensor = torch::tensor(x);
	std::cout<< tensor << std::endl;
	return 0;
}

It works for std::vector too:
#include <torch/torch.h>
#include <iostream>
#include <vector>

int main(){
	std::vector<int> x = {1, 2, 3, 4};
	torch::Tensor tensor = torch::tensor(x);
	std::cout<< tensor << std::endl;
	return 0;
}

And finally, it works for pointers too:
#include <torch/torch.h>
#include <iostream>

int main(){
	int *x = (int *) malloc(4 * sizeof(int));
	for(int i = 0; i < 4; i++){
		x[i] = i;
	}
	torch::Tensor tensor = torch::zeros({4}).to(torch::kInt);
	std::memcpy(tensor.data<int>(), x, 4 * sizeof(int));
	std::cout<< tensor << std::endl;
	free(x);
	return 0;
}