Fix:
1. python create model not match swift model in ane build folder.
2. fix ane lib path and add a dummy backward function for use_ane.py
can run in examples folder.
MODIFY
accel/ane/1_build/run.swift
accel/ane/1_build/run.swift
@@ -11,12 +11,17 @@ opts.usesCPUOnly = false
class MNISTInput : MLFeatureProvider {
var featureNames: Set<String> {
get {
- return ["image"]
+ return ["image", "image2"]
}
}
func featureValue(for featureName: String) -> MLFeatureValue? {
if (featureName == "image") {
- let tokenIDMultiArray = try? MLMultiArray(shape: [3], dataType: MLMultiArrayDataType.float32)
+ let tokenIDMultiArray = try? MLMultiArray(shape: [64], dataType: MLMultiArrayDataType.float32)
+ tokenIDMultiArray?[0] = NSNumber(value: 1337)
+ return MLFeatureValue(multiArray: tokenIDMultiArray!)
+ }
+ if (featureName == "image2") {
+ let tokenIDMultiArray = try? MLMultiArray(shape: [64], dataType: MLMultiArrayDataType.float32)
tokenIDMultiArray?[0] = NSNumber(value: 1337)
return MLFeatureValue(multiArray: tokenIDMultiArray!)
}

MODIFY
tinygrad/ops_ane.py
tinygrad/ops_ane.py
@@ -32,4 +32,8 @@ class ReLU(Function):
ret = ctx.ane.tensor(input.shape)
ctx.ane.run(compile_relu(ctx.ane, input.sz), input, ret)
return ret
+
+ def backward(ctx, grad_output):
+ return 0
+
register('relu', ReLU, device=Device.ANE)

MODIFY
tinygrad/tensor.py
tinygrad/tensor.py
@@ -61,8 +61,8 @@ ane = None
def require_init_ane():
global ane
if ane is None:
- import ane.lib.ane, tinygrad.ops_ane
- ane = ane.lib.ane.ANE()
+ import accel.ane.lib.ane as anelib, tinygrad.ops_ane
+ ane = anelib.ANE()
# **** start with two base classes, Tensor and Function ****

Fix: (#279)

1. python create model not match swift model in ane build folder.
2. fix ane lib path and add a dummy backward function for use_ane.py
can run in examples folder.