Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

SIGABRT on matmul() #885

Open
ematejska opened this issue Apr 24, 2020 · 6 comments
Open

SIGABRT on matmul() #885

ematejska opened this issue Apr 24, 2020 · 6 comments

Comments

@ematejska
Copy link
Contributor

libc++abi.dylib: terminating with uncaught exception of type Xbyak::Error: can't protect

I got this error on matmul using example from git repo readme with additional row in input data

struct MLPClassifier {
    var w1 = Tensor<Float>(repeating: 0.1, shape: [2, 4])
    var w2 = Tensor<Float>(shape: [4, 1], scalars: [0.4, -0.5, -0.5, 0.4])
    var b1 = Tensor<Float>([0.2, -0.3, -0.3, 0.2])
    var b2 = Tensor<Float>([[0.4]])


    func prediction(for x: Tensor<Float>) -> Tensor<Float> {
        let o1 = tanh(matmul(x, w1) + b1)
        return tanh(matmul(o1, w2) + b2)
    }
}
let input = Tensor<Float>([[0.2, 0.8], [0.2, 0.8]])
print(input.shape)
let classifier = MLPClassifier()
let prediction = classifier.prediction(for: input)
print(prediction)
@ematejska
Copy link
Contributor Author

This issue was submitted in JIRA by Artiom Bastun here: https://bugs.swift.org/projects/TF/issues/TF-1230. Moving from JIRA to Github Issues as much as possible for the project.

@ematejska
Copy link
Contributor Author

Followup comment from Artiom Bastun:

I managed to get around this with

let locale = Python.import("locale")
locale.setlocale(locale.LC_ALL, "")

I guess it's the same issue like this one microsoft/homebrew-mssql-release#18

@ByCyril
Copy link

ByCyril commented Apr 28, 2020

I get the same error even with applying the said work-around. Problem persist on both release and developer versions of S4TF

let a: Tensor<Float> = [[0.0, 1.0, 0.0],
 [0.0, 1.0, 1.0],
 [1.0, 1.0, 1.0]]
 
 let b: Tensor<Float> = [[-0.074010275, -0.074010275, 0.14814812],
 [ 0.12646824, 0.12646824, 0.12646824],
 [ -0.05096831, 0.14284894, 0.14284894]]
 
 print(matmul(a, b))

@ByCyril
Copy link

ByCyril commented Apr 28, 2020

After continued tinkering, it seems that there is issues when predefining a tensor with its shape.

If I create the same tensor and specifying the shape

let a = Tensor(shape: [3,3], scalars: [0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0])
let b = Tensor(shape: [3,3], scalars: [-0.0740, -0.0740,   0.148, 0.126,   0.126,   0.126, -0.050,
print(matmul(a, b))

the code works.

I'm not sure if this is a bug with tensorflow or its just how it works.

@dan-zheng
Copy link
Member

dan-zheng commented Apr 28, 2020

I get the same error even with applying the said work-around. Problem persist on both release and developer versions of S4TF

let a: Tensor<Float> = [[0.0, 1.0, 0.0],
 [0.0, 1.0, 1.0],
 [1.0, 1.0, 1.0]]
 
 let b: Tensor<Float> = [[-0.074010275, -0.074010275, 0.14814812],
 [ 0.12646824, 0.12646824, 0.12646824],
 [ -0.05096831, 0.14284894, 0.14284894]]
 
 print(matmul(a, b))

Could you please share details on how you reproduced an error for this program?
I couldn't reproduce it in Colab, or locally on macOS.

Screen Shot 2020-04-28 at 10 48 17 AM

@Stunba
Copy link

Stunba commented Apr 28, 2020

I dunno where the problem is but it happens with matmul for two matrices, it works when multiplying vector and matrix.
Screenshot 2020-04-28 at 21 19 12

Also there isn't error when using Python 2.7:
PythonLibrary.useVersion(2, 7)
or setting locale for Python 3.7
locale.setlocale(locale.LC_ALL, "")

I'm using latest swift tensorflow toolchain on mac os 10.15.4, xcode 11.4.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants