Skip to content

Commit b988a64

Browse files
committed
fix: naming
1 parent 5a51ba0 commit b988a64

5 files changed

Lines changed: 16 additions & 16 deletions

File tree

packages/react-native-executorch/common/rnexecutorch/data_processing/ImageProcessing.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ cv::Mat readImage(const std::string &imageURI) {
114114
return image;
115115
}
116116

117-
TensorPtr getTensorFromMatrix(const std::vector<int32_t> &tensorDim,
117+
TensorPtr getTensorFromMatrix(const std::vector<int32_t> &tensorDims,
118118
const cv::Mat &matrix) {
119119
std::vector<float> inputVector = colorMatToVector(matrix);
120-
return executorch::extension::make_tensor_ptr(tensorDim, inputVector);
120+
return executorch::extension::make_tensor_ptr(tensorDims, inputVector);
121121
}
122122

123123
cv::Mat getMatrixFromTensor(cv::Size size, const Tensor &tensor) {
@@ -128,26 +128,26 @@ cv::Mat getMatrixFromTensor(cv::Size size, const Tensor &tensor) {
128128

129129
std::pair<TensorPtr, cv::Size>
130130
readImageToTensor(const std::string &path,
131-
const std::vector<int32_t> &tensorDim) {
131+
const std::vector<int32_t> &tensorDims) {
132132
cv::Mat input = imageprocessing::readImage(path);
133133
cv::Size imageSize = input.size();
134134

135-
if (tensorDim.size() < 2) {
135+
if (tensorDims.size() < 2) {
136136
char errorMessage[100];
137137
std::snprintf(errorMessage, sizeof(errorMessage),
138138
"Unexpected tensor size, expected at least 2 dimentions "
139139
"but got: %zu.",
140-
tensorDim.size());
140+
tensorDims.size());
141141
throw std::runtime_error(errorMessage);
142142
}
143-
cv::Size tensorSize = cv::Size(tensorDim[tensorDim.size() - 1],
144-
tensorDim[tensorDim.size() - 2]);
143+
cv::Size tensorSize = cv::Size(tensorDims[tensorDims.size() - 1],
144+
tensorDims[tensorDims.size() - 2]);
145145

146146
cv::resize(input, input, tensorSize);
147147

148148
cv::cvtColor(input, input, cv::COLOR_BGR2RGB);
149149

150-
return {imageprocessing::getTensorFromMatrix(tensorDim, input), imageSize};
150+
return {imageprocessing::getTensorFromMatrix(tensorDims, input), imageSize};
151151
}
152152
} // namespace imageprocessing
153153
} // namespace rnexecutorch

packages/react-native-executorch/common/rnexecutorch/data_processing/ImageProcessing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ cv::Mat bufferToColorMat(const std::span<const float> &buffer,
2626
std::string saveToTempFile(const cv::Mat &image);
2727
/// @brief Read image in a BGR format to a cv::Mat
2828
cv::Mat readImage(const std::string &imageURI);
29-
TensorPtr getTensorFromMatrix(const std::vector<int32_t> &tensorDim,
29+
TensorPtr getTensorFromMatrix(const std::vector<int32_t> &tensorDims,
3030
const cv::Mat &mat);
3131
cv::Mat getMatrixFromTensor(cv::Size size, const Tensor &tensor);
3232
/// @brief Read image, resize it and copy it to an ET tensor to store it.
3333
/// @return Returns a tensor pointer and the original size of the image.
3434
std::pair<TensorPtr, cv::Size>
3535
readImageToTensor(const std::string &path,
36-
const std::vector<int32_t> &tensorDim);
36+
const std::vector<int32_t> &tensorDims);
3737

3838
} // namespace rnexecutorch::imageprocessing

packages/react-native-executorch/common/rnexecutorch/models/classification/Classification.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ Classification::Classification(const std::string &modelSource,
3030

3131
std::unordered_map<std::string_view, float>
3232
Classification::forward(std::string imageSource) {
33-
auto tensor =
33+
auto inputTensor =
3434
imageprocessing::readImageToTensor(imageSource, getInputShape()[0]).first;
3535

36-
auto forwardResult = forwardET(tensor);
36+
auto forwardResult = forwardET(inputTensor);
3737
if (!forwardResult.ok()) {
3838
throw std::runtime_error(
3939
"Failed to forward, error: " +

packages/react-native-executorch/common/rnexecutorch/models/object_detection/ObjectDetection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ ObjectDetection::postprocess(const std::vector<EValue> &tensors,
6565

6666
std::vector<Detection> ObjectDetection::forward(std::string imageSource,
6767
double detectionThreshold) {
68-
auto [tensor, originalSize] =
68+
auto [inputTensor, originalSize] =
6969
imageprocessing::readImageToTensor(imageSource, getInputShape()[0]);
7070

71-
auto forwardResult = forwardET(tensor);
71+
auto forwardResult = forwardET(inputTensor);
7272
if (!forwardResult.ok()) {
7373
throw std::runtime_error(
7474
"Failed to forward, error: " +

packages/react-native-executorch/common/rnexecutorch/models/style_transfer/StyleTransfer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ std::string StyleTransfer::postprocess(const Tensor &tensor,
4242
}
4343

4444
std::string StyleTransfer::forward(std::string imageSource) {
45-
auto [tensor, originalSize] =
45+
auto [inputTensor, originalSize] =
4646
imageprocessing::readImageToTensor(imageSource, getInputShape()[0]);
4747

48-
auto forwardResult = forwardET(tensor);
48+
auto forwardResult = forwardET(inputTensor);
4949
if (!forwardResult.ok()) {
5050
throw std::runtime_error(
5151
"Failed to forward, error: " +

0 commit comments

Comments
 (0)