Skip to content

Refactor jsi conversion & NITs#562

Merged
mkopcins merged 6 commits intosoftware-mansion:mainfrom
msluszniak:@ms/refactor-jsi
Aug 29, 2025
Merged

Refactor jsi conversion & NITs#562
mkopcins merged 6 commits intosoftware-mansion:mainfrom
msluszniak:@ms/refactor-jsi

Conversation

@msluszniak
Copy link
Copy Markdown
Member

Description

As in the title, some refactor of jsi.

Introduces a breaking change?

  • Yes
  • No

Type of change

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Documentation update (improves or adds clarity to existing documentation)
  • Other (chores, tests, code style improvements etc.)

Tested on

  • iOS
  • Android

Testing instructions

Needs to be manually testes / unit test (TODO)

Screenshots

Related issues

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • My changes generate no new warnings

Additional notes

Comment on lines -32 to -33
static_assert(std::is_integral<T>::value || std::is_floating_point<T>::value,
"Only integral and floating-point types are supported");
Copy link
Copy Markdown
Member Author

@msluszniak msluszniak Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assert is deleted because requires meta::IsNumeric<T> guarantees that the function will instantiate only if a value T already meets this condition (meta::isNumeric<T> is implemented as std::is_arithmetic_v<T>), so it is completely redundant.

@msluszniak
Copy link
Copy Markdown
Member Author

Awaiting for the test plan for the modified files

@msluszniak msluszniak marked this pull request as draft August 27, 2025 08:38
@msluszniak msluszniak marked this pull request as ready for review August 28, 2025 07:50
for (size_t i = 0; i < numShapeDims; ++i) {
int dim = getValue<int>(shapeArray.getValueAtIndex(runtime, i), runtime);
tensorView.sizes.push_back(static_cast<int32_t>(dim));
int32_t dim = getValue<int32_t>(shapeArray.getValueAtIndex(runtime, i), runtime);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity, why here you opted for int32_t instead of auto?

Copy link
Copy Markdown
Member Author

@msluszniak msluszniak Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because function specialisation for int32_t might return arbitrary type in general. Maybe here a function name kinda suggest that type probably be the same, but there is no guarantee. Here e.g.,

template <typename T>
auto someValue(T value,  T diff_value){
  return static_cast<float>(value / diff_value);
}

result value will be different for different specialization (floating point vs. integer types) but result is always float. But auto is also reasonable option here since we know the implementation of getValue.

On the other hand, when dealing with constructors, modern c++ casts, the resultant type is obvious so you can always safely use auto.

Also if the type of vector tensorView.sizes would be visible here, I'll probably opt to use auto, but here it's not visible at first glance

@mkopcins mkopcins merged commit 1cf016a into software-mansion:main Aug 29, 2025
2 checks passed
mkopcins pushed a commit that referenced this pull request Sep 2, 2025
## Description

As in the title, some refactor of jsi.

### Introduces a breaking change?

- [ ] Yes
- [x] No

### Type of change

- [ ] Bug fix (change which fixes an issue)
- [ ] New feature (change which adds functionality)
- [ ] Documentation update (improves or adds clarity to existing
documentation)
- [x] Other (chores, tests, code style improvements etc.)

### Tested on

- [ ] iOS
- [ ] Android

### Testing instructions

Needs to be manually testes / unit test (TODO)

### Screenshots

<!-- Add screenshots here, if applicable -->

### Related issues

<!-- Link related issues here using #issue-number -->

### Checklist

- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have updated the documentation accordingly
- [ ] My changes generate no new warnings

### Additional notes

<!-- Include any additional information, assumptions, or context that
reviewers might need to understand this PR. -->
KnextKoder pushed a commit to Synkhiv/react-native-executorch that referenced this pull request Nov 7, 2025
## Description

As in the title, some refactor of jsi.

### Introduces a breaking change?

- [ ] Yes
- [x] No

### Type of change

- [ ] Bug fix (change which fixes an issue)
- [ ] New feature (change which adds functionality)
- [ ] Documentation update (improves or adds clarity to existing
documentation)
- [x] Other (chores, tests, code style improvements etc.)

### Tested on

- [ ] iOS
- [ ] Android

### Testing instructions

Needs to be manually testes / unit test (TODO)

### Screenshots

<!-- Add screenshots here, if applicable -->

### Related issues

<!-- Link related issues here using #issue-number -->

### Checklist

- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have updated the documentation accordingly
- [ ] My changes generate no new warnings

### Additional notes

<!-- Include any additional information, assumptions, or context that
reviewers might need to understand this PR. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants