Skip to content

Commit 679b2a8

Browse files
committed
chore: get rid of numel within JsiTensorView ✨
1 parent e9ed5b0 commit 679b2a8

2 files changed

Lines changed: 5 additions & 14 deletions

File tree

packages/react-native-executorch/common/rnexecutorch/host_objects/JsiConversions.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ inline JsiTensorView getValue<JsiTensorView>(const jsi::Value &val,
6969
jsi::ArrayBuffer arrayBuffer = dataObj.getArrayBuffer(runtime);
7070
tensorView.dataPtr = arrayBuffer.data(runtime);
7171

72-
// Get the array size in bytes
73-
size_t arrayBytes = arrayBuffer.size(runtime);
74-
size_t elementBytes =
75-
executorch::runtime::elementSize(tensorView.scalarType);
76-
tensorView.numel = arrayBytes / elementBytes;
7772
} else {
7873
// Handle typed arrays (Float32Array, Int32Array, etc.)
7974
const bool isValidTypedArray = dataObj.hasProperty(runtime, "buffer") &&
@@ -83,9 +78,6 @@ inline JsiTensorView getValue<JsiTensorView>(const jsi::Value &val,
8378
if (!isValidTypedArray) {
8479
throw jsi::JSError(runtime, "Data must be an ArrayBuffer or TypedArray");
8580
}
86-
tensorView.numel =
87-
getValue<int>(dataObj.getProperty(runtime, "length"), runtime);
88-
8981
jsi::Value bufferValue = dataObj.getProperty(runtime, "buffer");
9082
if (!bufferValue.isObject() ||
9183
!bufferValue.asObject(runtime).isArrayBuffer(runtime)) {

packages/react-native-executorch/common/rnexecutorch/utils/JsiTensorView.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
using executorch::aten::ScalarType;
66

77
namespace rnexecutorch {
8-
struct JsiTensorView {
9-
void *dataPtr;
10-
ScalarType scalarType;
11-
std::vector<int32_t> shape;
12-
size_t numel;
13-
};
8+
struct JsiTensorView {
9+
void *dataPtr;
10+
ScalarType scalarType;
11+
std::vector<int32_t> shape;
12+
};
1413
} // namespace rnexecutorch

0 commit comments

Comments
 (0)