Thanks so the line that triggers the error is at:
“x=torch::nn::functional::softplus(bn1(fc1(x))+bn1_b);”
x is defined as
torch::Tensor x=torch::autograd::Variable(torch::rand({batch_size,z_dim}));
The code does not allow me to use
    "assert(x.device().type()==torch::kCUDA);"

So in the debugger, how shall I check if x is CPU tensor or GPU tensor please ? Are there any other tensors that I need to check ? Thanks.
bn1, fc1 and bn1_b are defined as:
GeneratorImpl(int64_t z_dim, int64_t output_dim){
    fc1 = register_module("fc1", torch::nn::Linear(torch::nn::LinearOptions(z_dim, 500).bias(false)));

    bn1 = register_module("bn1", torch::nn::BatchNorm1d(torch::nn::BatchNorm1dOptions(500).eps(1e-6).momentum(0.5).affine(false)));
  
    fc2 = register_module("fc2", torch::nn::Linear(torch::nn::LinearOptions(500, 500).bias(false)));
  
    bn2 = register_module("bn2", torch::nn::BatchNorm1d(torch::nn::BatchNorm1dOptions(500).eps(1e-6).momentum(0.5).affine(false)));
 
    fc3 = register_module("fc3",LinearWeightNorm(500, output_dim, 1));
    bn1_b = register_parameter("bn1_b",torch::zeros(500));
    bn2_b = register_parameter("bn2_b",torch::zeros(500));
    torch::nn::init::xavier_uniform_(fc1->weight);
    torch::nn::init::xavier_uniform_(fc2->weight);
};