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
20 changes: 10 additions & 10 deletions src/Native/LibTorchSharp/THSJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ void THSJIT_Module_modules(const JITModule module, JITModule* (*allocator)(size_
}

void THSJIT_Module_named_modules(const JITModule module,
JITModule* (*allocator)(size_t length),
JITModule* (*allocator1)(size_t length),
const char** (*allocator2)(size_t length))
{
auto modules = (*module)->named_modules();
JITModule* result = allocator(modules.size());
JITModule* result = allocator1(modules.size());
const char** names = allocator2(modules.size());
int i = 0;
for (const auto& child : modules) {
Expand All @@ -129,11 +129,11 @@ void THSJIT_Module_named_modules(const JITModule module,
}

void THSJIT_Module_named_children(const JITModule module,
JITModule* (*allocator)(size_t length),
JITModule* (*allocator1)(size_t length),
const char** (*allocator2)(size_t length))
{
auto modules = (*module)->named_children();
JITModule* result = allocator(modules.size());
JITModule* result = allocator1(modules.size());
const char** names = allocator2(modules.size());
int i = 0;
for (const auto& child : modules) {
Expand All @@ -155,11 +155,11 @@ void THSJIT_Module_parameters(const JITModule module, Tensor* (*allocator)(size_
}

void THSJIT_Module_named_parameters(const JITModule module,
Tensor* (*allocator)(size_t length),
Tensor* (*allocator1)(size_t length),
const char** (*allocator2)(size_t length))
{
auto parameters = (*module)->named_parameters();
Tensor* result = allocator(parameters.size());
Tensor* result = allocator1(parameters.size());
const char** names = allocator2(parameters.size());
int i = 0;
for (const auto& child : parameters) {
Expand All @@ -170,11 +170,11 @@ void THSJIT_Module_named_parameters(const JITModule module,
}

void THSJIT_Module_named_buffers(const JITModule module,
Tensor* (*allocator)(size_t length),
Tensor* (*allocator1)(size_t length),
const char** (*allocator2)(size_t length))
{
auto parameters = (*module)->named_buffers();
Tensor* result = allocator(parameters.size());
Tensor* result = allocator1(parameters.size());
const char** names = allocator2(parameters.size());
int i = 0;
for (const auto& child : parameters) {
Expand All @@ -185,11 +185,11 @@ void THSJIT_Module_named_buffers(const JITModule module,
}

void THSJIT_Module_named_attributes(const JITModule module, bool recurse,
Tensor* (*allocator)(size_t length),
Tensor* (*allocator1)(size_t length),
const char** (*allocator2)(size_t length))
{
auto attributes = (*module)->named_attributes(recurse);
Tensor* result = allocator(attributes.size());
Tensor* result = allocator1(attributes.size());
const char** names = allocator2(attributes.size());
int i = 0;
for (const auto& child : attributes) {
Expand Down
10 changes: 5 additions & 5 deletions src/Native/LibTorchSharp/THSJIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,26 @@ EXPORT_API(void) THSJIT_TensorType_dispose(const JITTensorType type);

EXPORT_API(void) THSJIT_Module_modules(const JITModule module, JITModule* (*allocator)(size_t length));
EXPORT_API(void) THSJIT_Module_named_modules(const JITModule module,
JITModule* (*allocator)(size_t length),
JITModule* (*allocator1)(size_t length),
const char** (*allocator2)(size_t length));

EXPORT_API(void) THSJIT_Module_named_children(const JITModule module,
JITModule* (*allocator)(size_t length),
JITModule* (*allocator1)(size_t length),
const char** (*allocator2)(size_t length));

EXPORT_API(JITMethod) THSJIT_Module_get_method(const JITModule module, const char* name);

EXPORT_API(void) THSJIT_Module_parameters(const JITModule module, Tensor* (*allocator)(size_t length));
EXPORT_API(void) THSJIT_Module_named_parameters(const JITModule module,
Tensor* (*allocator)(size_t length),
Tensor* (*allocator1)(size_t length),
const char** (*allocator2)(size_t length));

EXPORT_API(void) THSJIT_Module_named_buffers(const JITModule module,
Tensor* (*allocator)(size_t length),
Tensor* (*allocator1)(size_t length),
const char** (*allocator2)(size_t length));

EXPORT_API(void) THSJIT_Module_named_attributes(const JITModule module, bool recurse,
Tensor* (*allocator)(size_t length),
Tensor* (*allocator1)(size_t length),
const char** (*allocator2)(size_t length));

EXPORT_API(void) THSJIT_Module_set_attribute(const JITModule module, const char* name, Tensor tensor);
Expand Down
4 changes: 2 additions & 2 deletions src/Native/LibTorchSharp/THSModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ Tensor THSNN_Module_get_parameter(const NNModule module, const char* name)
CATCH_TENSOR(*(*module)->named_parameters().find(name));
}

void THSNN_Module_get_parameters(const NNModule module, Tensor* (*allocator1)(size_t length), bool recurse)
void THSNN_Module_get_parameters(const NNModule module, Tensor* (*allocator)(size_t length), bool recurse)
{
auto parameters = (*module)->parameters(recurse);
Tensor* result1 = allocator1(parameters.size());
Tensor* result1 = allocator(parameters.size());

for (size_t i = 0; i < parameters.size(); i++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Native/LibTorchSharp/THSNN.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ EXPORT_API(void) THSNN_Module_get_named_parameters(const NNModule module,
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(void) THSNN_Module_get_parameters(const NNModule module, Tensor* (*allocator)(size_t length), bool recurse);
EXPORT_API(int) 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);
Expand Down