#include "cuda.h"
#include "../tensor.h"
#include "../utils.h"
#include <torch/torch.h>

namespace TensorOps {

Napi::Value Cuda(Tensor* self, const Napi::CallbackInfo& info) {
  Napi::Env env = info.Env();

  if (!torch::cuda::is_available()) {
    Napi::Error::New(env, "CUDA is not available").ThrowAsJavaScriptException();
    return env.Null();
  }

  torch::Tensor result = self->tensor.cuda();
  return Tensor::NewInstance(env, result);
}

}  // namespace TensorOps
