Skip to content

Commit a7523e5

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 bdc2bcb commit a7523e5

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
@@ -130,11 +130,11 @@ void THSJIT_Module_modules(const JITModule module, JITModule* (*allocator)(size_
130130
}
131131

132132
void THSJIT_Module_named_modules(const JITModule module,
133-
JITModule* (*allocator)(size_t length),
133+
JITModule* (*allocator1)(size_t length),
134134
const char** (*allocator2)(size_t length))
135135
{
136136
auto modules = (*module)->named_modules();
137-
JITModule* result = allocator(modules.size());
137+
JITModule* result = allocator1(modules.size());
138138
const char** names = allocator2(modules.size());
139139
int i = 0;
140140
for (const auto& child : modules) {
@@ -146,11 +146,11 @@ void THSJIT_Module_named_modules(const JITModule module,
146146
}
147147

148148
void THSJIT_Module_named_children(const JITModule module,
149-
JITModule* (*allocator)(size_t length),
149+
JITModule* (*allocator1)(size_t length),
150150
const char** (*allocator2)(size_t length))
151151
{
152152
auto modules = (*module)->named_children();
153-
JITModule* result = allocator(modules.size());
153+
JITModule* result = allocator1(modules.size());
154154
const char** names = allocator2(modules.size());
155155
int i = 0;
156156
for (const auto& child : modules) {
@@ -172,11 +172,11 @@ void THSJIT_Module_parameters(const JITModule module, Tensor* (*allocator)(size_
172172
}
173173

174174
void THSJIT_Module_named_parameters(const JITModule module,
175-
Tensor* (*allocator)(size_t length),
175+
Tensor* (*allocator1)(size_t length),
176176
const char** (*allocator2)(size_t length))
177177
{
178178
auto parameters = (*module)->named_parameters();
179-
Tensor* result = allocator(parameters.size());
179+
Tensor* result = allocator1(parameters.size());
180180
const char** names = allocator2(parameters.size());
181181
int i = 0;
182182
for (const auto& child : parameters) {
@@ -187,11 +187,11 @@ void THSJIT_Module_named_parameters(const JITModule module,
187187
}
188188

189189
void THSJIT_Module_named_buffers(const JITModule module,
190-
Tensor* (*allocator)(size_t length),
190+
Tensor* (*allocator1)(size_t length),
191191
const char** (*allocator2)(size_t length))
192192
{
193193
auto parameters = (*module)->named_buffers();
194-
Tensor* result = allocator(parameters.size());
194+
Tensor* result = allocator1(parameters.size());
195195
const char** names = allocator2(parameters.size());
196196
int i = 0;
197197
for (const auto& child : parameters) {
@@ -202,11 +202,11 @@ void THSJIT_Module_named_buffers(const JITModule module,
202202
}
203203

204204
void THSJIT_Module_named_attributes(const JITModule module, bool recurse,
205-
Tensor* (*allocator)(size_t length),
205+
Tensor* (*allocator1)(size_t length),
206206
const char** (*allocator2)(size_t length))
207207
{
208208
auto attributes = (*module)->named_attributes(recurse);
209-
Tensor* result = allocator(attributes.size());
209+
Tensor* result = allocator1(attributes.size());
210210
const char** names = allocator2(attributes.size());
211211
int i = 0;
212212
for (const auto& child : attributes) {

src/Native/LibTorchSharp/THSJIT.h

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

6666
EXPORT_API(void) THSJIT_Module_modules(const JITModule module, JITModule* (*allocator)(size_t length));
6767
EXPORT_API(void) THSJIT_Module_named_modules(const JITModule module,
68-
JITModule* (*allocator)(size_t length),
68+
JITModule* (*allocator1)(size_t length),
6969
const char** (*allocator2)(size_t length));
7070

7171
EXPORT_API(void) THSJIT_Module_named_children(const JITModule module,
72-
JITModule* (*allocator)(size_t length),
72+
JITModule* (*allocator1)(size_t length),
7373
const char** (*allocator2)(size_t length));
7474

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

7777
EXPORT_API(void) THSJIT_Module_parameters(const JITModule module, Tensor* (*allocator)(size_t length));
7878
EXPORT_API(void) THSJIT_Module_named_parameters(const JITModule module,
79-
Tensor* (*allocator)(size_t length),
79+
Tensor* (*allocator1)(size_t length),
8080
const char** (*allocator2)(size_t length));
8181

8282
EXPORT_API(void) THSJIT_Module_named_buffers(const JITModule module,
83-
Tensor* (*allocator)(size_t length),
83+
Tensor* (*allocator1)(size_t length),
8484
const char** (*allocator2)(size_t length));
8585

8686
EXPORT_API(void) THSJIT_Module_named_attributes(const JITModule module, bool recurse,
87-
Tensor* (*allocator)(size_t length),
87+
Tensor* (*allocator1)(size_t length),
8888
const char** (*allocator2)(size_t length));
8989

9090
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)