Skip to content

Commit 2b89a0f

Browse files
committed
Tests and coverage-related fixes
1 parent 69580af commit 2b89a0f

File tree

4 files changed

+17
-46
lines changed

4 files changed

+17
-46
lines changed

lib/mpsgraphs/matmul.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@ end
6262

6363
matmul = matrixMultiplicationWithPrimaryTensor(graph, broadcastB, broadcastA)
6464

65-
afteralpha = let
66-
alphatensor = constantWithScalar(graph, alpha, castT)
65+
afteralpha = let alphatensor = constantWithScalar(graph, alpha, castT)
6766
multiplicationWithPrimaryTensor(graph, alphatensor, matmul)
6867
end
6968

70-
afterbeta = let
71-
betatensor = constantWithScalar(graph, beta, castT)
69+
afterbeta = let betatensor = constantWithScalar(graph, beta, castT)
7270
castplaceC = castTensor(graph, placeC, castT, "castplaceC")
7371
betaC = multiplicationWithPrimaryTensor(graph, betatensor, castplaceC)
7472
afterbeta = additionWithPrimaryTensor(graph, afteralpha, betaC)

lib/mpsgraphs/operations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@ Dumps the `graph`.
7373
!!! warning
7474
This function is undocumented from Apple so it may stop working at any time.
7575
"""
76-
dump_graph(graph::MPSGraph) = @objc [graph::id{MPSGraph} dump]::Nothing
76+
dump_graph(graph::MPSGraph) = @objc [graph::id{MPSGraph} dump]::Nothing ## COV_EXCL_LINE

test/mpsgraphs/core.jl

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,19 @@
1-
# # Contains definitions for api from MPSGraphCore.h, MPSGraphDevice.h
21

3-
# const MPSGraphTensorDataDictionary = NSDictionary#<MPSGraphTensor *,MPSGraphTensorData *>
2+
if MPS.is_supported(device())
43

5-
# ## MPSGraphCore.h
6-
# @objcwrapper MPSGraphObject <: NSObject
4+
using .MPS: MPSShape
5+
using .MPSGraphs: MPSGraph, MPSGraphDevice
6+
@testset "Core" begin
77

8-
# @objcwrapper MPSGraph <: MPSGraphObject
8+
graph = MPSGraph()
9+
@test graph isa MPSGraph
910

10-
# function MPSGraph()
11-
# MPSGraph(@objc [MPSGraph new]::id{MPSGraph})
12-
# end
11+
dev = device()
12+
graphdev = MPSGraphDevice(dev)
13+
@test graphdev isa MPSGraphDevice
14+
@test graphdev.type == MPSGraphs.MPSGraphDeviceTypeMetal
15+
@test graphdev.metalDevice == dev
1316

14-
# @objcwrapper MPSGraphType <: MPSGraphObject
17+
end # @testset "Core"
1518

16-
# @objcwrapper MPSGraphShapedType <: MPSGraphType
17-
18-
# @objcproperties MPSGraphShapedType begin
19-
# @autoproperty shape::id{MPSShape} setter=setShape
20-
# @autoproperty dataType::MPSDataType setter=setDataType
21-
# end
22-
23-
# function MPSGraphShapedType(shape::MPSShape, dataType)
24-
# tmp = @objc [MPSGraphShapedType alloc]::id{MPSGraphShapedType}
25-
# obj = MPSGraphShapedType(tmp)
26-
# finalizer(release, obj)
27-
# @objc [obj::id{MPSGraphShapedType} initWithShape:shape::id{MPSShape}
28-
# dataType:dataType::MPSDataType]::id{MPSGraphShapedType}
29-
30-
# return obj
31-
# end
32-
33-
# ## MPSGraphDevice.h
34-
# @objcwrapper MPSGraphDevice <: MPSGraphType
35-
36-
# @objcproperties MPSGraphDevice begin
37-
# @autoproperty type::MPSGraphDeviceType
38-
# @autoproperty metalDevice::id{MTLDevice}
39-
# end
40-
41-
# function MPSGraphDevice(device::MTLDevice)
42-
# obj = @objc [MPSGraphDevice deviceWithMTLDevice:device::id{MTLDevice}]::id{MPSGraphDevice}
43-
# MPSGraphDevice(obj)
44-
# end
19+
end # MPS.is_supported(device())

test/mpsgraphs/linalg.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ if MPS.is_supported(device())
3434
end
3535
end
3636

37-
# XXX: Batched matlmul not yet working
3837
@testset "batched matrix matrix multiplication" begin
3938
M = 8
4039
N = 7
@@ -95,8 +94,7 @@ end
9594
MPSGraphs.graph_matvecmul!(buf_c, buf_a, buf_b, alpha, beta)
9695

9796
@test all(Array(buf_c) .≈ truth_c)
98-
# @test Array(buf_c) ≈ truth_c
9997
end
10098
end
10199

102-
end
100+
end # MPS.is_supported(device())

0 commit comments

Comments
 (0)