gemini-code-assist[bot] commented on code in PR #167:
URL: https://github.com/apache/tvm-ffi/pull/167#discussion_r2441381566
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -308,14 +318,14 @@ class Tensor : public ObjectRef {
* \param idx The index of the size.
* \return The size of the idx-th dimension.
*/
- int64_t size(size_t idx) const { return get()->shape[idx]; }
+ int64_t size(int64_t idx) const { return get()->shape[idx]; }
/*!
* \brief Get the stride of the idx-th dimension.
* \param idx The index of the stride.
* \return The stride of the idx-th dimension.
*/
- int64_t stride(size_t idx) const { return get()->strides[idx]; }
+ int64_t stride(int64_t idx) const { return get()->strides[idx]; }
Review Comment:

Similar to the `size` method, the `stride` method also changes the index
type from `size_t` to `int64_t`. It's important to ensure that the index `idx`
is within the valid range and handle potential negative indices appropriately.
Consider adding bounds checking or casting to `size_t` if negative indices are
not intended.
```c
int64_t stride(int64_t idx) const {
if (idx < 0 || idx >= get()->ndim) {
TVM_FFI_THROW(IndexError) << "Index " << idx << " out of bounds for
dimension with size " << get()->ndim;
}
return get()->strides[idx];
}
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -600,14 +623,14 @@ class TensorView {
* \param idx The index of the size.
* \return The size of the idx-th dimension.
*/
- int64_t size(size_t idx) const { return tensor_.shape[idx]; }
+ int64_t size(int64_t idx) const { return tensor_.shape[idx]; }
/*!
* \brief Get the stride of the idx-th dimension.
* \param idx The index of the stride.
* \return The stride of the idx-th dimension.
*/
- int64_t stride(size_t idx) const { return tensor_.strides[idx]; }
+ int64_t stride(int64_t idx) const { return tensor_.strides[idx]; }
Review Comment:

Similar to the `Tensor` class, the `stride` method in `TensorView` also
changes the index type from `size_t` to `int64_t`. It's important to ensure
that the index `idx` is within the valid range and handle potential negative
indices appropriately. Consider adding bounds checking or casting to `size_t`
if negative indices are not intended.
```c
int64_t stride(int64_t idx) const {
if (idx < 0 || idx >= tensor_.ndim) {
TVM_FFI_THROW(IndexError) << "Index " << idx << " out of bounds for
dimension with size " << tensor_.ndim;
}
return tensor_.strides[idx];
}
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -600,14 +623,14 @@ class TensorView {
* \param idx The index of the size.
* \return The size of the idx-th dimension.
*/
- int64_t size(size_t idx) const { return tensor_.shape[idx]; }
+ int64_t size(int64_t idx) const { return tensor_.shape[idx]; }
Review Comment:

Similar to the `Tensor` class, the `size` method in `TensorView` also
changes the index type from `size_t` to `int64_t`. It's important to ensure
that the index `idx` is within the valid range and handle potential negative
indices appropriately. Consider adding bounds checking or casting to `size_t`
if negative indices are not intended.
```c
int64_t size(int64_t idx) const {
if (idx < 0 || idx >= tensor_.ndim) {
TVM_FFI_THROW(IndexError) << "Index " << idx << " out of bounds for
dimension with size " << tensor_.ndim;
}
return tensor_.shape[idx];
}
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -600,14 +623,14 @@ class TensorView {
* \param idx The index of the size.
* \return The size of the idx-th dimension.
*/
- int64_t size(size_t idx) const { return tensor_.shape[idx]; }
+ int64_t size(int64_t idx) const { return tensor_.shape[idx]; }
/*!
* \brief Get the stride of the idx-th dimension.
* \param idx The index of the stride.
* \return The stride of the idx-th dimension.
*/
- int64_t stride(size_t idx) const { return tensor_.strides[idx]; }
+ int64_t stride(int64_t idx) const { return tensor_.strides[idx]; }
Review Comment:

Similar to the `Tensor` class, the `stride` method in `TensorView` also
changes the index type from `size_t` to `int64_t`. It's important to ensure
that the index `idx` is within the valid range and handle potential negative
indices appropriately. Consider adding bounds checking or casting to `size_t`
if negative indices are not intended.
```c
int64_t stride(int64_t idx) const {
if (idx < 0 || idx >= tensor_.ndim) {
TVM_FFI_THROW(IndexError) << "Index " << idx << " out of bounds for
dimension with size " << tensor_.ndim;
}
return tensor_.strides[idx];
}
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -308,14 +318,14 @@ class Tensor : public ObjectRef {
* \param idx The index of the size.
* \return The size of the idx-th dimension.
*/
- int64_t size(size_t idx) const { return get()->shape[idx]; }
+ int64_t size(int64_t idx) const { return get()->shape[idx]; }
/*!
* \brief Get the stride of the idx-th dimension.
* \param idx The index of the stride.
* \return The stride of the idx-th dimension.
*/
- int64_t stride(size_t idx) const { return get()->strides[idx]; }
+ int64_t stride(int64_t idx) const { return get()->strides[idx]; }
Review Comment:

Similar to the `size` method, the `stride` method also changes the index
type from `size_t` to `int64_t`. It's important to ensure that the index `idx`
is within the valid range and handle potential negative indices appropriately.
Consider adding bounds checking or casting to `size_t` if negative indices are
not intended.
```c
int64_t stride(int64_t idx) const {
if (idx < 0 || idx >= get()->ndim) {
TVM_FFI_THROW(IndexError) << "Index " << idx << " out of bounds for
dimension with size " << get()->ndim;
}
return get()->strides[idx];
}
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -600,14 +623,14 @@ class TensorView {
* \param idx The index of the size.
* \return The size of the idx-th dimension.
*/
- int64_t size(size_t idx) const { return tensor_.shape[idx]; }
+ int64_t size(int64_t idx) const { return tensor_.shape[idx]; }
/*!
* \brief Get the stride of the idx-th dimension.
* \param idx The index of the stride.
* \return The stride of the idx-th dimension.
*/
- int64_t stride(size_t idx) const { return tensor_.strides[idx]; }
+ int64_t stride(int64_t idx) const { return tensor_.strides[idx]; }
Review Comment:

Similar to the `Tensor` class, the `stride` method in `TensorView` also
changes the index type from `size_t` to `int64_t`. It's important to ensure
that the index `idx` is within the valid range and handle potential negative
indices appropriately. Consider adding bounds checking or casting to `size_t`
if negative indices are not intended.
```c
int64_t stride(int64_t idx) const {
if (idx < 0 || idx >= tensor_.ndim) {
TVM_FFI_THROW(IndexError) << "Index " << idx << " out of bounds for
dimension with size " << tensor_.ndim;
}
return tensor_.strides[idx];
}
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -600,14 +623,14 @@ class TensorView {
* \param idx The index of the size.
* \return The size of the idx-th dimension.
*/
- int64_t size(size_t idx) const { return tensor_.shape[idx]; }
+ int64_t size(int64_t idx) const { return tensor_.shape[idx]; }
Review Comment:

Similar to the `Tensor` class, the `size` method in `TensorView` also
changes the index type from `size_t` to `int64_t`. It's important to ensure
that the index `idx` is within the valid range and handle potential negative
indices appropriately. Consider adding bounds checking or casting to `size_t`
if negative indices are not intended.
```c
int64_t size(int64_t idx) const {
if (idx < 0 || idx >= tensor_.ndim) {
TVM_FFI_THROW(IndexError) << "Index " << idx << " out of bounds for
dimension with size " << tensor_.ndim;
}
return tensor_.shape[idx];
}
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -332,6 +342,10 @@ class Tensor : public ObjectRef {
* \return True if the Tensor is contiguous, false otherwise.
*/
bool IsContiguous() const { return tvm::ffi::IsContiguous(*get()); }
+ /*!
+ * \brief Alias for torch aten naming.
+ */
+ inline bool is_contiguous() const { return IsContiguous(); }
Review Comment:

The alias `is_contiguous` is introduced, but the original function
`IsContiguous` is still used internally. Consider deprecating `IsContiguous` in
favor of `is_contiguous` to promote a consistent naming convention. This would
involve renaming the underlying implementation and updating all call sites.
```c
inline bool is_contiguous() const { return tvm::ffi::IsContiguous(*get()); }
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -600,14 +623,14 @@ class TensorView {
* \param idx The index of the size.
* \return The size of the idx-th dimension.
*/
- int64_t size(size_t idx) const { return tensor_.shape[idx]; }
+ int64_t size(int64_t idx) const { return tensor_.shape[idx]; }
Review Comment:

Similar to the `Tensor` class, the `size` method in `TensorView` also
changes the index type from `size_t` to `int64_t`. It's important to ensure
that the index `idx` is within the valid range and handle potential negative
indices appropriately. Consider adding bounds checking or casting to `size_t`
if negative indices are not intended.
```c
int64_t size(int64_t idx) const {
if (idx < 0 || idx >= tensor_.ndim) {
TVM_FFI_THROW(IndexError) << "Index " << idx << " out of bounds for
dimension with size " << tensor_.ndim;
}
return tensor_.shape[idx];
}
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -600,14 +623,14 @@ class TensorView {
* \param idx The index of the size.
* \return The size of the idx-th dimension.
*/
- int64_t size(size_t idx) const { return tensor_.shape[idx]; }
+ int64_t size(int64_t idx) const { return tensor_.shape[idx]; }
Review Comment:

Similar to the `Tensor` class, the `size` method in `TensorView` also
changes the index type from `size_t` to `int64_t`. It's important to ensure
that the index `idx` is within the valid range and handle potential negative
indices appropriately. Consider adding bounds checking or casting to `size_t`
if negative indices are not intended.
```c
int64_t size(int64_t idx) const {
if (idx < 0 || idx >= tensor_.ndim) {
TVM_FFI_THROW(IndexError) << "Index " << idx << " out of bounds for
dimension with size " << tensor_.ndim;
}
return tensor_.shape[idx];
}
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -332,6 +342,10 @@ class Tensor : public ObjectRef {
* \return True if the Tensor is contiguous, false otherwise.
*/
bool IsContiguous() const { return tvm::ffi::IsContiguous(*get()); }
+ /*!
+ * \brief Alias for torch aten naming.
+ */
+ inline bool is_contiguous() const { return IsContiguous(); }
Review Comment:

The alias `is_contiguous` is introduced, but the original function
`IsContiguous` is still used internally. Consider deprecating `IsContiguous` in
favor of `is_contiguous` to promote a consistent naming convention. This would
involve renaming the underlying implementation and updating all call sites.
```c
inline bool is_contiguous() const { return tvm::ffi::IsContiguous(*get()); }
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -308,14 +318,14 @@ class Tensor : public ObjectRef {
* \param idx The index of the size.
* \return The size of the idx-th dimension.
*/
- int64_t size(size_t idx) const { return get()->shape[idx]; }
+ int64_t size(int64_t idx) const { return get()->shape[idx]; }
/*!
* \brief Get the stride of the idx-th dimension.
* \param idx The index of the stride.
* \return The stride of the idx-th dimension.
*/
- int64_t stride(size_t idx) const { return get()->strides[idx]; }
+ int64_t stride(int64_t idx) const { return get()->strides[idx]; }
Review Comment:

Similar to the `size` method, the `stride` method also changes the index
type from `size_t` to `int64_t`. It's important to ensure that the index `idx`
is within the valid range and handle potential negative indices appropriately.
Consider adding bounds checking or casting to `size_t` if negative indices are
not intended.
```c
int64_t stride(int64_t idx) const {
if (idx < 0 || idx >= get()->ndim) {
TVM_FFI_THROW(IndexError) << "Index " << idx << " out of bounds for
dimension with size " << get()->ndim;
}
return get()->strides[idx];
}
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -332,6 +342,10 @@ class Tensor : public ObjectRef {
* \return True if the Tensor is contiguous, false otherwise.
*/
bool IsContiguous() const { return tvm::ffi::IsContiguous(*get()); }
+ /*!
+ * \brief Alias for torch aten naming.
+ */
+ inline bool is_contiguous() const { return IsContiguous(); }
Review Comment:

The alias `is_contiguous` is introduced, but the original function
`IsContiguous` is still used internally. Consider deprecating `IsContiguous` in
favor of `is_contiguous` to promote a consistent naming convention. This would
involve renaming the underlying implementation and updating all call sites.
```c
inline bool is_contiguous() const { return tvm::ffi::IsContiguous(*get()); }
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -600,14 +623,14 @@ class TensorView {
* \param idx The index of the size.
* \return The size of the idx-th dimension.
*/
- int64_t size(size_t idx) const { return tensor_.shape[idx]; }
+ int64_t size(int64_t idx) const { return tensor_.shape[idx]; }
/*!
* \brief Get the stride of the idx-th dimension.
* \param idx The index of the stride.
* \return The stride of the idx-th dimension.
*/
- int64_t stride(size_t idx) const { return tensor_.strides[idx]; }
+ int64_t stride(int64_t idx) const { return tensor_.strides[idx]; }
Review Comment:

Similar to the `Tensor` class, the `stride` method in `TensorView` also
changes the index type from `size_t` to `int64_t`. It's important to ensure
that the index `idx` is within the valid range and handle potential negative
indices appropriately. Consider adding bounds checking or casting to `size_t`
if negative indices are not intended.
```c
int64_t stride(int64_t idx) const {
if (idx < 0 || idx >= tensor_.ndim) {
TVM_FFI_THROW(IndexError) << "Index " << idx << " out of bounds for
dimension with size " << tensor_.ndim;
}
return tensor_.strides[idx];
}
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -308,14 +318,14 @@ class Tensor : public ObjectRef {
* \param idx The index of the size.
* \return The size of the idx-th dimension.
*/
- int64_t size(size_t idx) const { return get()->shape[idx]; }
+ int64_t size(int64_t idx) const { return get()->shape[idx]; }
/*!
* \brief Get the stride of the idx-th dimension.
* \param idx The index of the stride.
* \return The stride of the idx-th dimension.
*/
- int64_t stride(size_t idx) const { return get()->strides[idx]; }
+ int64_t stride(int64_t idx) const { return get()->strides[idx]; }
Review Comment:

Similar to the `size` method, the `stride` method also changes the index
type from `size_t` to `int64_t`. It's important to ensure that the index `idx`
is within the valid range and handle potential negative indices appropriately.
Consider adding bounds checking or casting to `size_t` if negative indices are
not intended.
```c
int64_t stride(int64_t idx) const {
if (idx < 0 || idx >= get()->ndim) {
TVM_FFI_THROW(IndexError) << "Index " << idx << " out of bounds for
dimension with size " << get()->ndim;
}
return get()->strides[idx];
}
```
##########
include/tvm/ffi/container/tensor.h:
##########
@@ -332,6 +342,10 @@ class Tensor : public ObjectRef {
* \return True if the Tensor is contiguous, false otherwise.
*/
bool IsContiguous() const { return tvm::ffi::IsContiguous(*get()); }
+ /*!
+ * \brief Alias for torch aten naming.
+ */
+ inline bool is_contiguous() const { return IsContiguous(); }
Review Comment:

The alias `is_contiguous` is introduced, but the original function
`IsContiguous` is still used internally. Consider deprecating `IsContiguous` in
favor of `is_contiguous` to promote a consistent naming convention. This would
involve renaming the underlying implementation and updating all call sites.
```c
inline bool is_contiguous() const { return tvm::ffi::IsContiguous(*get()); }
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]