Skip to content

Commit 68a3f22

Browse files
committed
Rename parameters in native code to be more standardized
This aligns parameter naming for these functions with the rest of the project. See also: https://github.com/AssetRipper/AssetRipper.Bindings.LibTorchSharp/blob/a76753d26df195f667c003f8f10b3085882168a0/AssetRipper.Bindings.LibTorchSharp.SourceGenerator/ParameterNameChanges.cs#L7-L12
1 parent 6ceda53 commit 68a3f22

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/Native/LibTorchSharp/THSJIT.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ void THSJIT_Module_modules(const JITModule module, JITModule* (*allocator)(size_
113113
}
114114

115115
void THSJIT_Module_named_modules(const JITModule module,
116-
JITModule* (*allocator)(size_t length),
116+
JITModule* (*allocator1)(size_t length),
117117
const char** (*allocator2)(size_t length))
118118
{
119119
auto modules = (*module)->named_modules();
120-
JITModule* result = allocator(modules.size());
120+
JITModule* result = allocator1(modules.size());
121121
const char** names = allocator2(modules.size());
122122
int i = 0;
123123
for (const auto& child : modules) {
@@ -129,11 +129,11 @@ void THSJIT_Module_named_modules(const JITModule module,
129129
}
130130

131131
void THSJIT_Module_named_children(const JITModule module,
132-
JITModule* (*allocator)(size_t length),
132+
JITModule* (*allocator1)(size_t length),
133133
const char** (*allocator2)(size_t length))
134134
{
135135
auto modules = (*module)->named_children();
136-
JITModule* result = allocator(modules.size());
136+
JITModule* result = allocator1(modules.size());
137137
const char** names = allocator2(modules.size());
138138
int i = 0;
139139
for (const auto& child : modules) {
@@ -155,11 +155,11 @@ void THSJIT_Module_parameters(const JITModule module, Tensor* (*allocator)(size_
155155
}
156156

157157
void THSJIT_Module_named_parameters(const JITModule module,
158-
Tensor* (*allocator)(size_t length),
158+
Tensor* (*allocator1)(size_t length),
159159
const char** (*allocator2)(size_t length))
160160
{
161161
auto parameters = (*module)->named_parameters();
162-
Tensor* result = allocator(parameters.size());
162+
Tensor* result = allocator1(parameters.size());
163163
const char** names = allocator2(parameters.size());
164164
int i = 0;
165165
for (const auto& child : parameters) {
@@ -170,11 +170,11 @@ void THSJIT_Module_named_parameters(const JITModule module,
170170
}
171171

172172
void THSJIT_Module_named_buffers(const JITModule module,
173-
Tensor* (*allocator)(size_t length),
173+
Tensor* (*allocator1)(size_t length),
174174
const char** (*allocator2)(size_t length))
175175
{
176176
auto parameters = (*module)->named_buffers();
177-
Tensor* result = allocator(parameters.size());
177+
Tensor* result = allocator1(parameters.size());
178178
const char** names = allocator2(parameters.size());
179179
int i = 0;
180180
for (const auto& child : parameters) {
@@ -185,11 +185,11 @@ void THSJIT_Module_named_buffers(const JITModule module,
185185
}
186186

187187
void THSJIT_Module_named_attributes(const JITModule module, bool recurse,
188-
Tensor* (*allocator)(size_t length),
188+
Tensor* (*allocator1)(size_t length),
189189
const char** (*allocator2)(size_t length))
190190
{
191191
auto attributes = (*module)->named_attributes(recurse);
192-
Tensor* result = allocator(attributes.size());
192+
Tensor* result = allocator1(attributes.size());
193193
const char** names = allocator2(attributes.size());
194194
int i = 0;
195195
for (const auto& child : attributes) {

src/Native/LibTorchSharp/THSJIT.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,26 @@ EXPORT_API(void) THSJIT_TensorType_dispose(const JITTensorType type);
6464

6565
EXPORT_API(void) THSJIT_Module_modules(const JITModule module, JITModule* (*allocator)(size_t length));
6666
EXPORT_API(void) THSJIT_Module_named_modules(const JITModule module,
67-
JITModule* (*allocator)(size_t length),
67+
JITModule* (*allocator1)(size_t length),
6868
const char** (*allocator2)(size_t length));
6969

7070
EXPORT_API(void) THSJIT_Module_named_children(const JITModule module,
71-
JITModule* (*allocator)(size_t length),
71+
JITModule* (*allocator1)(size_t length),
7272
const char** (*allocator2)(size_t length));
7373

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

7676
EXPORT_API(void) THSJIT_Module_parameters(const JITModule module, Tensor* (*allocator)(size_t length));
7777
EXPORT_API(void) THSJIT_Module_named_parameters(const JITModule module,
78-
Tensor* (*allocator)(size_t length),
78+
Tensor* (*allocator1)(size_t length),
7979
const char** (*allocator2)(size_t length));
8080

8181
EXPORT_API(void) THSJIT_Module_named_buffers(const JITModule module,
82-
Tensor* (*allocator)(size_t length),
82+
Tensor* (*allocator1)(size_t length),
8383
const char** (*allocator2)(size_t length));
8484

8585
EXPORT_API(void) THSJIT_Module_named_attributes(const JITModule module, bool recurse,
86-
Tensor* (*allocator)(size_t length),
86+
Tensor* (*allocator1)(size_t length),
8787
const char** (*allocator2)(size_t length));
8888

8989
EXPORT_API(void) THSJIT_Module_set_attribute(const JITModule module, const char* name, Tensor tensor);

src/Native/LibTorchSharp/THSModule.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ Tensor THSNN_Module_get_parameter(const NNModule module, const char* name)
9898
CATCH_TENSOR(*(*module)->named_parameters().find(name));
9999
}
100100

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

106106
for (size_t i = 0; i < parameters.size(); i++)
107107
{

src/Native/LibTorchSharp/THSNN.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ EXPORT_API(void) THSNN_Module_get_named_parameters(const NNModule module,
1515
EXPORT_API(void) THSNN_Module_get_named_buffers(const NNModule module, Tensor* (*allocator1)(size_t length), const char** (*allocator2)(size_t length));
1616
EXPORT_API(void) THSNN_Module_get_named_children(const NNModule module, NNModule* (*allocator1)(size_t length), const char** (*allocator2)(size_t length));
1717
EXPORT_API(void) THSNN_Module_get_named_modules(const NNModule module, NNModule* (*allocator1)(size_t length), const char** (*allocator2)(size_t length));
18-
EXPORT_API(void) THSNN_Module_get_parameters(const NNModule module, Tensor* (*allocator1)(size_t length), bool recurse);
18+
EXPORT_API(void) THSNN_Module_get_parameters(const NNModule module, Tensor* (*allocator)(size_t length), bool recurse);
1919
EXPORT_API(int) THSNN_Module_is_training(NNModule module);
2020
EXPORT_API(void) THSNN_Module_train(NNModule module, bool on);
2121
EXPORT_API(long) THSNN_Module_children_size(const NNModule module);

0 commit comments

Comments
 (0)