Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Native/LibTorchSharp/THSJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void THSJIT_save_byte_array(JITModule module, char* bytes, int64_t size)
);
}

int THSJIT_Module_is_training(JITModule module)
bool THSJIT_Module_is_training(JITModule module)
{
return (*module)->is_training();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Native/LibTorchSharp/THSJIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ EXPORT_API(void) THSJIT_Module_invoke(const JITModule module, const char* name,

EXPORT_API(void) THSJIT_CompilationUnit_Invoke(const JITCompilationUnit module, const char* method, const TensorOrScalar* tensorPtrs, const int length, TensorOrScalar* (*allocator)(int32_t idx, size_t length), int8_t* typeCode, int32_t idx);

EXPORT_API(int) THSJIT_Module_is_training(JITModule module);
EXPORT_API(bool) THSJIT_Module_is_training(JITModule module);
EXPORT_API(void) THSJIT_Module_zero_grad(const JITModule module, bool set_to_none);
EXPORT_API(void) THSJIT_Module_train(JITModule module, bool on);
EXPORT_API(void) THSJIT_Module_eval(JITModule module);
Expand Down
6 changes: 3 additions & 3 deletions src/Native/LibTorchSharp/THSModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// General Module functions

int THSNN_Module_is_training(NNModule module)
bool THSNN_Module_is_training(NNModule module)
{
return (*module)->is_training();
}
Expand Down Expand Up @@ -88,9 +88,9 @@ void THSNN_Module_register_buffer(const NNModule module, const char* name, const
);
}

int THSNN_Module_has_parameter(const NNModule module, const char* name)
bool THSNN_Module_has_parameter(const NNModule module, const char* name)
{
CATCH_RETURN(int, 0, (*module)->named_parameters().contains(name));
CATCH_RETURN(bool, false, (*module)->named_parameters().contains(name));
}

Tensor THSNN_Module_get_parameter(const NNModule module, const char* name)
Expand Down
4 changes: 2 additions & 2 deletions src/Native/LibTorchSharp/THSNN.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

// API.

EXPORT_API(int) THSNN_Module_has_parameter(const NNModule module, const char* name);
EXPORT_API(bool) THSNN_Module_has_parameter(const NNModule module, const char* name);
EXPORT_API(Tensor) THSNN_Module_get_parameter(const NNModule module, const char* name);
EXPORT_API(void) THSNN_Module_get_named_parameters(const NNModule module, Tensor* (*allocator1)(size_t length), const char** (*allocator2)(size_t length));
EXPORT_API(void) THSNN_Module_get_named_buffers(const NNModule module, Tensor* (*allocator1)(size_t length), const char** (*allocator2)(size_t length));
EXPORT_API(void) THSNN_Module_get_named_children(const NNModule module, NNModule* (*allocator1)(size_t length), const char** (*allocator2)(size_t length));
EXPORT_API(void) THSNN_Module_get_named_modules(const NNModule module, NNModule* (*allocator1)(size_t length), const char** (*allocator2)(size_t length));
EXPORT_API(void) THSNN_Module_get_parameters(const NNModule module, Tensor* (*allocator1)(size_t length), bool recurse);
EXPORT_API(int) THSNN_Module_is_training(NNModule module);
EXPORT_API(bool) THSNN_Module_is_training(NNModule module);
EXPORT_API(void) THSNN_Module_train(NNModule module, bool on);
EXPORT_API(long) THSNN_Module_children_size(const NNModule module);
EXPORT_API(NNModule) THSNN_Module_child(const NNModule module, const int index);
Expand Down
22 changes: 11 additions & 11 deletions src/Native/LibTorchSharp/THSTensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <iostream>
#include <fstream>

int THSTensor_allclose(const Tensor left, const Tensor right, double rtol, double atol, bool equal_nan)
bool THSTensor_allclose(const Tensor left, const Tensor right, double rtol, double atol, bool equal_nan)
{
CATCH_RETURN(int, 0, left->allclose(*right, rtol, atol, equal_nan));
CATCH_RETURN(bool, false, left->allclose(*right, rtol, atol, equal_nan));
}

Tensor THSTensor_all(const Tensor tensor)
Expand Down Expand Up @@ -314,14 +314,14 @@ Tensor THSTensor_contiguous(const Tensor tensor)
CATCH_TENSOR(tensor->contiguous());
}

int THSTensor_is_contiguous(const Tensor tensor)
bool THSTensor_is_contiguous(const Tensor tensor)
{
bool result = false;
CATCH(result = tensor->is_contiguous(););
return result;
}

int64_t THSTensor_is_nonzero(const Tensor tensor)
bool THSTensor_is_nonzero(const Tensor tensor)
{
bool result = false;
CATCH(result = tensor->is_nonzero();)
Expand Down Expand Up @@ -360,7 +360,7 @@ Tensor THSTensor_pin_memory(const Tensor tensor)
CATCH_TENSOR(tensor->pin_memory());
}

int64_t THSTensor_is_pinned(const Tensor tensor)
bool THSTensor_is_pinned(const Tensor tensor)
{
bool result = false;
CATCH(result = tensor->is_pinned(););
Expand Down Expand Up @@ -932,9 +932,9 @@ Tensor THSTensor_inverse(const Tensor tensor)
CATCH_TENSOR(tensor->inverse());
}

int THSTensor_is_sparse(const Tensor tensor)
bool THSTensor_is_sparse(const Tensor tensor)
{
CATCH_RETURN(int, 0, tensor->is_sparse());
CATCH_RETURN(bool, false, tensor->is_sparse());
}

Scalar THSTensor_item(const Tensor tensor)
Expand Down Expand Up @@ -1242,19 +1242,19 @@ Tensor THSTensor_renorm(const Tensor tensor, const float p, const int64_t dim, c
CATCH_TENSOR(tensor->renorm(p, dim, maxnorm));
}

int THSTensor_requires_grad(const Tensor tensor)
bool THSTensor_requires_grad(const Tensor tensor)
{
CATCH_RETURN(int, 0, tensor->requires_grad());
CATCH_RETURN(bool, false, tensor->requires_grad());
}

void THSTensor_retain_grad(const Tensor tensor)
{
CATCH(tensor->retain_grad(););
}

int64_t THSTensor_is_leaf(const Tensor tensor)
bool THSTensor_is_leaf(const Tensor tensor)
{
CATCH_RETURN(int64_t, 0, tensor->is_leaf(););
CATCH_RETURN(bool, false, tensor->is_leaf());
}

Tensor THSTensor_reshape(const Tensor tensor, const int64_t* shape, const int length)
Expand Down
16 changes: 8 additions & 8 deletions src/Native/LibTorchSharp/THSTensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ EXPORT_API(Tensor) THSTensor_adjoint(const Tensor tensor);

EXPORT_API(Tensor) THSTensor_alias(const Tensor tensor);

EXPORT_API(int) THSTensor_allclose(const Tensor left, const Tensor right, double rtol, double atol, bool equal_nan);
EXPORT_API(bool) THSTensor_allclose(const Tensor left, const Tensor right, double rtol, double atol, bool equal_nan);

EXPORT_API(Tensor) THSTensor_all(const Tensor tensor);

Expand Down Expand Up @@ -285,7 +285,7 @@ EXPORT_API(Tensor) THSTensor_complex(const Tensor real, const Tensor imag);

EXPORT_API(Tensor) THSTensor_conj(const Tensor tensor);

EXPORT_API(int64_t) THSTensor_is_nonzero(const Tensor tensor);
EXPORT_API(bool) THSTensor_is_nonzero(const Tensor tensor);

EXPORT_API(Tensor) THSTensor_conj_physical(const Tensor tensor);

Expand Down Expand Up @@ -381,7 +381,7 @@ EXPORT_API(Tensor) THSTensor_cuda(const Tensor tensor);

EXPORT_API(Tensor) THSTensor_pin_memory(const Tensor tensor);

EXPORT_API(int64_t) THSTensor_is_pinned(const Tensor tensor);
EXPORT_API(bool) THSTensor_is_pinned(const Tensor tensor);

EXPORT_API(void) THSTensor_cummax(const Tensor tensor, Tensor* (*allocator)(size_t length), const int64_t dim);

Expand Down Expand Up @@ -484,7 +484,7 @@ EXPORT_API(Tensor) THSTensor_eq_scalar(const Tensor left, const Scalar right);

EXPORT_API(void) THSTensor_eq_scalar_(const Tensor left, const Scalar right);

EXPORT_API(int) THSTensor_equal(const Tensor left, const Tensor right);
EXPORT_API(bool) THSTensor_equal(const Tensor left, const Tensor right);

EXPORT_API(Tensor) THSTensor_exp(const Tensor tensor);

Expand Down Expand Up @@ -692,11 +692,11 @@ EXPORT_API(Tensor) THSTensor_inner(const Tensor left, const Tensor right);

EXPORT_API(Tensor) THSTensor_inverse(const Tensor tensor);

EXPORT_API(int) THSTensor_is_contiguous(const Tensor input);
EXPORT_API(bool) THSTensor_is_contiguous(const Tensor input);

EXPORT_API(int64_t) THSTensor_is_leaf(const Tensor tensor);
EXPORT_API(bool) THSTensor_is_leaf(const Tensor tensor);

EXPORT_API(int) THSTensor_is_sparse(const Tensor tensor);
EXPORT_API(bool) THSTensor_is_sparse(const Tensor tensor);

EXPORT_API(Tensor) THSTensor_isclose(const Tensor tensor, const Tensor other, const double rtol, const double atol, const bool equal_nan);

Expand Down Expand Up @@ -1145,7 +1145,7 @@ EXPORT_API(Tensor) THSTensor_repeat_interleave(const Tensor tensor, const Tensor

EXPORT_API(Tensor) THSTensor_repeat_interleave_int64(const Tensor tensor, const int64_t repeats, const int64_t dim, const int64_t output_size);

EXPORT_API(int) THSTensor_requires_grad(const Tensor tensor);
EXPORT_API(bool) THSTensor_requires_grad(const Tensor tensor);

EXPORT_API(Tensor) THSTensor_reshape(const Tensor tensor, const int64_t* shape, const int length);

Expand Down
4 changes: 2 additions & 2 deletions src/Native/LibTorchSharp/THSTensorMath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,9 @@ void THSTensor_eq_scalar_(const Tensor left, const Scalar right)
CATCH(left->eq_(*right);)
}

int THSTensor_equal(const Tensor left, const Tensor right)
bool THSTensor_equal(const Tensor left, const Tensor right)
{
CATCH_RETURN(int, 0, left->equal(*right));
CATCH_RETURN(bool, false, left->equal(*right));
}

Tensor THSTensor_exp(const Tensor tensor)
Expand Down
4 changes: 2 additions & 2 deletions src/Native/LibTorchSharp/THSTorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ void THSGenerator_dispose(const Generator generator)
delete generator;
}

int THSTorchCuda_is_available()
bool THSTorchCuda_is_available()
{
return torch::cuda::is_available();
}

int THSTorchCuda_cudnn_is_available()
bool THSTorchCuda_cudnn_is_available()
{
return torch::cuda::cudnn_is_available();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Native/LibTorchSharp/THSTorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ EXPORT_API(Generator) THSGenerator_new(uint64_t seed, int64_t device, int64_t in
EXPORT_API(int64_t) THSGenerator_initial_seed(const Generator gen);
EXPORT_API(void) THSGenerator_dispose(const Generator generator);

EXPORT_API(int) THSTorchCuda_is_available();
EXPORT_API(int) THSTorchCuda_cudnn_is_available();
EXPORT_API(bool) THSTorchCuda_is_available();
EXPORT_API(bool) THSTorchCuda_cudnn_is_available();
EXPORT_API(int) THSTorchCuda_device_count();
EXPORT_API(void) THSTorchCuda_synchronize(const int64_t device);

Expand Down
8 changes: 4 additions & 4 deletions src/TorchSharp/PInvoke/LibTorchSharp.THSTensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ internal static extern IntPtr THSTensor_upsample_nearest3d(IntPtr input,
internal static extern long THSTensor_numel(IntPtr handle);

[DllImport("LibTorchSharp")]
internal static extern long THSTensor_is_leaf(IntPtr handle);
internal static extern byte THSTensor_is_leaf(IntPtr handle);

[DllImport("LibTorchSharp")]
internal static extern IntPtr THSTensor_alias(IntPtr handle);
Expand Down Expand Up @@ -386,13 +386,13 @@ internal static extern IntPtr THSTensor_upsample_nearest3d(IntPtr input,
internal static extern long THSTensor_copy_(IntPtr handle, IntPtr source, [MarshalAs(UnmanagedType.U1)] bool non_blocking);

[DllImport("LibTorchSharp")]
internal static extern int THSTensor_is_contiguous(IntPtr handle);
internal static extern byte THSTensor_is_contiguous(IntPtr handle);

[DllImport("LibTorchSharp")]
internal static extern IntPtr THSTensor_contiguous(IntPtr handle);

[DllImport("LibTorchSharp")]
internal static extern long THSTensor_is_pinned(IntPtr handle);
internal static extern byte THSTensor_is_pinned(IntPtr handle);

[DllImport("LibTorchSharp")]
internal static extern IntPtr THSTensor_pin_memory(IntPtr handle);
Expand Down Expand Up @@ -758,7 +758,7 @@ internal static extern IntPtr THSTensor_upsample_nearest3d(IntPtr input,
internal static extern IntPtr THSTensor_isnan(IntPtr tensor);

[DllImport("LibTorchSharp")]
internal static extern long THSTensor_is_nonzero(IntPtr handle);
internal static extern byte THSTensor_is_nonzero(IntPtr handle);

[DllImport("LibTorchSharp")]
internal static extern IntPtr THSTensor_isreal(IntPtr tensor);
Expand Down