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

namespace TensorOps {

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

  std::string dtype_str;
  auto dtype = self->tensor.dtype();

  if (dtype == torch::kFloat32) dtype_str = "float32";
  else if (dtype == torch::kFloat64) dtype_str = "float64";
  else if (dtype == torch::kInt32) dtype_str = "int32";
  else if (dtype == torch::kInt64) dtype_str = "int64";
  else if (dtype == torch::kInt16) dtype_str = "int16";
  else if (dtype == torch::kInt8) dtype_str = "int8";
  else if (dtype == torch::kUInt8) dtype_str = "uint8";
  else if (dtype == torch::kBool) dtype_str = "bool";
  else dtype_str = "unknown";

  return Napi::String::New(env, dtype_str);
}

}  // namespace TensorOps
