Skip to content

Commit e7108dd

Browse files
authored
Don't use tensor shape dynamism when comparing tensors.
Differential Revision: D76482174 Pull Request resolved: #11626
1 parent 2b7dfe2 commit e7108dd

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

extension/apple/ExecuTorch/Exported/ExecuTorchTensor.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ - (BOOL)isEqualToTensor:(nullable ExecuTorchTensor *)other {
137137
[self.shape isEqual:other.shape] &&
138138
[self.dimensionOrder isEqual:other.dimensionOrder] &&
139139
[self.strides isEqual:other.strides] &&
140-
self.shapeDynamism == other.shapeDynamism &&
141140
(data && otherData ? std::memcmp(data, otherData, size) == 0 : data == otherData);
142141
}
143142

extension/apple/ExecuTorch/__tests__/TensorTest.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ class TensorTest: XCTestCase {
208208
XCTAssertTrue(tensor1.isEqual(tensor1))
209209
XCTAssertFalse(tensor1.isEqual(NSString(string: "Not a tensor")))
210210
XCTAssertFalse(tensor4.isEqual(tensor2.copy()))
211+
let tensor5 = data.withUnsafeMutableBytes {
212+
Tensor(bytesNoCopy: $0.baseAddress!, shape: [2, 2], dataType: .float, shapeDynamism: .static)
213+
}
214+
XCTAssertTrue(tensor1.isEqual(tensor5))
211215
}
212216

213217
func testInitScalarsUInt8() {

0 commit comments

Comments
 (0)