when trying to compile and run through bazel according to your instruction on MacBook Pro M1 with Xcode 13.4 and swift 5.4, I was getting Float16 not available for macOS error.
There are a bunch of error related to Float16:
---------- other log's ignored before this line ----------
ERROR: /Users/david/Project/DALL-E/swift-diffusion/examples/BUILD.bazel:102:13: Compiling Swift module //examples:txt2img failed: (Exit 1): worker failed: error executing command bazel-out/darwin-opt-exec-2B5CBBC6/bin/external/build_bazel_rules_swift/tools/worker/worker swiftc @bazel-out/darwin-opt/bin/examples/examples_txt2img.swiftmodule-0.params
error: emit-module command failed with exit code 1 (use -v to see invocation)
examples/txt2img/main.swift:6:37: error: 'Float16' is unavailable in macOS
public typealias UseFloatingPoint = Float16
^~~~~~~
Swift.Float16:4:23: note: 'Float16' has been explicitly marked unavailable here
@Frozen public struct Float16 {
^
examples/txt2img/main.swift:121:17: error: global function 'CLIPTextModel(:vocabularySize:maxLength:embeddingSize:numLayers:numHeads:batchSize:intermediateSize:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
let textModel = CLIPTextModel(
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/src/CLIPTextModel.swift:71:13: note: where 'T' = 'UseFloatingPoint' (aka 'Float16')
public func CLIPTextModel<T: TensorNumeric>(
^
examples/txt2img/main.swift:135:42: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
let casualAttentionMask = graph.variable(Tensor(.CPU, .NHWC(1, 1, 77, 77)))
^
examples/txt2img/main.swift:139:57: error: type 'UseFloatingPoint' (aka 'Float16') has no member 'greatestFiniteMagnitude'
casualAttentionMask[0, 0, i, j] = -UseFloatingPoint.greatestFiniteMagnitude
~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~
examples/txt2img/main.swift:161:17: error: cannot infer contextual base in reference to member 'CHW'
).reshaped(.CHW(2, 77, 768))
~^~~
examples/txt2img/main.swift:162:13: error: instance method 'variable(::of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
let x_T = graph.variable(.GPU(0), .NCHW(1, 4, startHeight, startWidth), of: UseFloatingPoint.self)
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
examples/txt2img/main.swift:165:13: error: instance method 'variable(::of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
var xIn = graph.variable(.GPU(0), .NCHW(2, 4, startHeight, startWidth), of: UseFloatingPoint.self)
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
examples/txt2img/main.swift:167:44: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
unet.compile(inputs: xIn, graph.variable(Tensor(from: ts)), c)
^
examples/txt2img/main.swift:173:33: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
var oldDenoised: DynamicGraph.Tensor? = nil
^
examples/txt2img/main.swift:183:28: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
let t = graph.variable(Tensor(from: ts))
^
examples/txt2img/main.swift:189:20: error: instance method 'variable(::of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
var etUncond = graph.variable(
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
examples/txt2img/main.swift:191:18: error: instance method 'variable(::of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
var etCond = graph.variable(
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
examples/txt2img/main.swift:6:37: error: 'Float16' is unavailable in macOS
public typealias UseFloatingPoint = Float16
^~~~~~~
Swift.Float16:4:23: note: 'Float16' has been explicitly marked unavailable here
@Frozen public struct Float16 {
^
examples/txt2img/main.swift:121:17: error: global function 'CLIPTextModel(:vocabularySize:maxLength:embeddingSize:numLayers:numHeads:batchSize:intermediateSize:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
let textModel = CLIPTextModel(
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/src/CLIPTextModel.swift:71:13: note: where 'T' = 'UseFloatingPoint' (aka 'Float16')
public func CLIPTextModel<T: TensorNumeric>(
^
examples/txt2img/main.swift:135:42: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
let casualAttentionMask = graph.variable(Tensor(.CPU, .NHWC(1, 1, 77, 77)))
^
examples/txt2img/main.swift:139:57: error: type 'UseFloatingPoint' (aka 'Float16') has no member 'greatestFiniteMagnitude'
casualAttentionMask[0, 0, i, j] = -UseFloatingPoint.greatestFiniteMagnitude
~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~
examples/txt2img/main.swift:161:17: error: cannot infer contextual base in reference to member 'CHW'
).reshaped(.CHW(2, 77, 768))
~^~~
examples/txt2img/main.swift:162:13: error: instance method 'variable(::of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
let x_T = graph.variable(.GPU(0), .NCHW(1, 4, startHeight, startWidth), of: UseFloatingPoint.self)
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
examples/txt2img/main.swift:165:13: error: instance method 'variable(::of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
var xIn = graph.variable(.GPU(0), .NCHW(2, 4, startHeight, startWidth), of: UseFloatingPoint.self)
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
examples/txt2img/main.swift:167:44: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
unet.compile(inputs: xIn, graph.variable(Tensor(from: ts)), c)
^
examples/txt2img/main.swift:173:33: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
var oldDenoised: DynamicGraph.Tensor? = nil
^
examples/txt2img/main.swift:183:28: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
let t = graph.variable(Tensor(from: ts))
^
examples/txt2img/main.swift:189:20: error: instance method 'variable(::of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
var etUncond = graph.variable(
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
examples/txt2img/main.swift:191:18: error: instance method 'variable(:_:of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
var etCond = graph.variable(
^
/private/var/tmp/_bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
swift_worker: Could not copy bazel-out/darwin-opt/bin/_swift_incremental/examples/txt2img_objs/txt2img/main.swift.o to bazel-out/darwin-opt/bin/examples/txt2img_objs/txt2img/main.swift.o (No such file or directory)
Target //examples:txt2img failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 164.415s, Critical Path: 34.07s
INFO: 258 processes: 54 internal, 198 darwin-sandbox, 6 worker.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
when trying to compile and run through bazel according to your instruction on MacBook Pro M1 with Xcode 13.4 and swift 5.4, I was getting Float16 not available for macOS error.
There are a bunch of error related to Float16:
---------- other log's ignored before this line ----------
ERROR: /Users/david/Project/DALL-E/swift-diffusion/examples/BUILD.bazel:102:13: Compiling Swift module //examples:txt2img failed: (Exit 1): worker failed: error executing command bazel-out/darwin-opt-exec-2B5CBBC6/bin/external/build_bazel_rules_swift/tools/worker/worker swiftc @bazel-out/darwin-opt/bin/examples/examples_txt2img.swiftmodule-0.params
error: emit-module command failed with exit code 1 (use -v to see invocation)
examples/txt2img/main.swift:6:37: error: 'Float16' is unavailable in macOS
public typealias UseFloatingPoint = Float16
^~~~~~~
Swift.Float16:4:23: note: 'Float16' has been explicitly marked unavailable here
@Frozen public struct Float16 {
^
examples/txt2img/main.swift:121:17: error: global function 'CLIPTextModel(:vocabularySize:maxLength:embeddingSize:numLayers:numHeads:batchSize:intermediateSize:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
let textModel = CLIPTextModel(
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/src/CLIPTextModel.swift:71:13: note: where 'T' = 'UseFloatingPoint' (aka 'Float16')
public func CLIPTextModel<T: TensorNumeric>(
^
examples/txt2img/main.swift:135:42: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
let casualAttentionMask = graph.variable(Tensor(.CPU, .NHWC(1, 1, 77, 77)))
^
examples/txt2img/main.swift:139:57: error: type 'UseFloatingPoint' (aka 'Float16') has no member 'greatestFiniteMagnitude'
casualAttentionMask[0, 0, i, j] = -UseFloatingPoint.greatestFiniteMagnitude
~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~
examples/txt2img/main.swift:161:17: error: cannot infer contextual base in reference to member 'CHW'
).reshaped(.CHW(2, 77, 768))
~^~~
examples/txt2img/main.swift:162:13: error: instance method 'variable(::of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
let x_T = graph.variable(.GPU(0), .NCHW(1, 4, startHeight, startWidth), of: UseFloatingPoint.self)
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
examples/txt2img/main.swift:165:13: error: instance method 'variable(::of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
var xIn = graph.variable(.GPU(0), .NCHW(2, 4, startHeight, startWidth), of: UseFloatingPoint.self)
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
examples/txt2img/main.swift:167:44: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
unet.compile(inputs: xIn, graph.variable(Tensor(from: ts)), c)
^
examples/txt2img/main.swift:173:33: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
var oldDenoised: DynamicGraph.Tensor? = nil
^
examples/txt2img/main.swift:183:28: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
let t = graph.variable(Tensor(from: ts))
^
examples/txt2img/main.swift:189:20: error: instance method 'variable(::of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
var etUncond = graph.variable(
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
examples/txt2img/main.swift:191:18: error: instance method 'variable(::of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
var etCond = graph.variable(
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
examples/txt2img/main.swift:6:37: error: 'Float16' is unavailable in macOS
public typealias UseFloatingPoint = Float16
^~~~~~~
Swift.Float16:4:23: note: 'Float16' has been explicitly marked unavailable here
@Frozen public struct Float16 {
^
examples/txt2img/main.swift:121:17: error: global function 'CLIPTextModel(:vocabularySize:maxLength:embeddingSize:numLayers:numHeads:batchSize:intermediateSize:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
let textModel = CLIPTextModel(
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/src/CLIPTextModel.swift:71:13: note: where 'T' = 'UseFloatingPoint' (aka 'Float16')
public func CLIPTextModel<T: TensorNumeric>(
^
examples/txt2img/main.swift:135:42: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
let casualAttentionMask = graph.variable(Tensor(.CPU, .NHWC(1, 1, 77, 77)))
^
examples/txt2img/main.swift:139:57: error: type 'UseFloatingPoint' (aka 'Float16') has no member 'greatestFiniteMagnitude'
casualAttentionMask[0, 0, i, j] = -UseFloatingPoint.greatestFiniteMagnitude
~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~
examples/txt2img/main.swift:161:17: error: cannot infer contextual base in reference to member 'CHW'
).reshaped(.CHW(2, 77, 768))
~^~~
examples/txt2img/main.swift:162:13: error: instance method 'variable(::of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
let x_T = graph.variable(.GPU(0), .NCHW(1, 4, startHeight, startWidth), of: UseFloatingPoint.self)
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
examples/txt2img/main.swift:165:13: error: instance method 'variable(::of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
var xIn = graph.variable(.GPU(0), .NCHW(2, 4, startHeight, startWidth), of: UseFloatingPoint.self)
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
examples/txt2img/main.swift:167:44: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
unet.compile(inputs: xIn, graph.variable(Tensor(from: ts)), c)
^
examples/txt2img/main.swift:173:33: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
var oldDenoised: DynamicGraph.Tensor? = nil
^
examples/txt2img/main.swift:183:28: error: type 'UseFloatingPoint' (aka 'Float16') does not conform to protocol 'TensorNumeric'
let t = graph.variable(Tensor(from: ts))
^
examples/txt2img/main.swift:189:20: error: instance method 'variable(::of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
var etUncond = graph.variable(
^
/private/var/tmp/bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
examples/txt2img/main.swift:191:18: error: instance method 'variable(:_:of:)' requires that 'UseFloatingPoint' (aka 'Float16') conform to 'TensorNumeric'
var etCond = graph.variable(
^
/private/var/tmp/_bazel_david/dbc2f5fdbf3e5db2dfb4ac1d16060e30/execroot/main/external/s4nnc/nnc/DynamicGraph.swift:611:15: note: where 'Element' = 'UseFloatingPoint' (aka 'Float16')
public func variable<Element: TensorNumeric>(
^
swift_worker: Could not copy bazel-out/darwin-opt/bin/_swift_incremental/examples/txt2img_objs/txt2img/main.swift.o to bazel-out/darwin-opt/bin/examples/txt2img_objs/txt2img/main.swift.o (No such file or directory)
Target //examples:txt2img failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 164.415s, Critical Path: 34.07s
INFO: 258 processes: 54 internal, 198 darwin-sandbox, 6 worker.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully