ai.muna.muna 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/Build/AndroidBuildHandler.cs +96 -0
- package/Editor/Build/AndroidBuildHandler.cs.meta +11 -0
- package/Editor/Build/BuildHandler.cs +128 -0
- package/Editor/Build/BuildHandler.cs.meta +11 -0
- package/Editor/Build/LinuxBuildHandler.cs +26 -0
- package/Editor/Build/LinuxBuildHandler.cs.meta +11 -0
- package/Editor/Build/WebGLBuildHandler.cs +69 -0
- package/Editor/Build/WebGLBuildHandler.cs.meta +11 -0
- package/Editor/Build/WindowsBuildHandler.cs +24 -0
- package/Editor/Build/WindowsBuildHandler.cs.meta +11 -0
- package/Editor/Build/iOSBuildHandler.cs +119 -0
- package/Editor/Build/iOSBuildHandler.cs.meta +11 -0
- package/Editor/Build/macOSBuildHandler.cs +133 -0
- package/Editor/Build/macOSBuildHandler.cs.meta +11 -0
- package/Editor/Build.meta +8 -0
- package/Editor/Muna.Editor.asmdef +18 -0
- package/Editor/Muna.Editor.asmdef.meta +7 -0
- package/Editor/MunaMenu.cs +32 -0
- package/Editor/MunaMenu.cs.meta +11 -0
- package/Editor/MunaProjectSettings.cs +43 -0
- package/Editor/MunaProjectSettings.cs.meta +11 -0
- package/Editor/MunaSettingsProvider.cs +27 -0
- package/Editor/MunaSettingsProvider.cs.meta +11 -0
- package/Editor.meta +8 -0
- package/LICENSE +201 -0
- package/LICENSE.meta +7 -0
- package/Plugins/Android/Function.aar +0 -0
- package/Plugins/Android/Function.aar.meta +32 -0
- package/Plugins/Android.meta +8 -0
- package/Plugins/Linux/arm64/libFunction.so +0 -0
- package/Plugins/Linux/arm64/libFunction.so.meta +62 -0
- package/Plugins/Linux/arm64.meta +8 -0
- package/Plugins/Linux/x86_64/libFunction.so +0 -0
- package/Plugins/Linux/x86_64/libFunction.so.meta +82 -0
- package/Plugins/Linux/x86_64.meta +8 -0
- package/Plugins/Linux.meta +8 -0
- package/Plugins/Web/libFunction.a +0 -0
- package/Plugins/Web/libFunction.a.meta +87 -0
- package/Plugins/Web.meta +8 -0
- package/Plugins/Windows/arm64/Function.dll +0 -0
- package/Plugins/Windows/arm64/Function.dll.meta +58 -0
- package/Plugins/Windows/arm64.meta +8 -0
- package/Plugins/Windows/x86_64/Function.dll +0 -0
- package/Plugins/Windows/x86_64/Function.dll.meta +82 -0
- package/Plugins/Windows/x86_64.meta +8 -0
- package/Plugins/Windows.meta +8 -0
- package/Plugins/iOS/Function.xcframework/Info.plist +75 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64/Function.framework/Function +0 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64/Function.framework/Headers/FXNConfiguration.h +313 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64/Function.framework/Headers/FXNPrediction.h +165 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64/Function.framework/Headers/FXNPredictionStream.h +63 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64/Function.framework/Headers/FXNPredictor.h +108 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64/Function.framework/Headers/FXNStatus.h +42 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64/Function.framework/Headers/FXNValue.h +395 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64/Function.framework/Headers/FXNValueMap.h +148 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64/Function.framework/Headers/FXNVersion.h +26 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64/Function.framework/Headers/Function.h +18 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64/Function.framework/Info.plist +0 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64/Function.framework/Modules/module.modulemap +6 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64/Function.framework/PrivacyInfo.xcprivacy +36 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64/Function.framework/_CodeSignature/CodeResources +223 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64_x86_64-simulator/Function.framework/Function +0 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64_x86_64-simulator/Function.framework/Headers/FXNConfiguration.h +313 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64_x86_64-simulator/Function.framework/Headers/FXNPrediction.h +165 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64_x86_64-simulator/Function.framework/Headers/FXNPredictionStream.h +63 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64_x86_64-simulator/Function.framework/Headers/FXNPredictor.h +108 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64_x86_64-simulator/Function.framework/Headers/FXNStatus.h +42 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64_x86_64-simulator/Function.framework/Headers/FXNValue.h +395 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64_x86_64-simulator/Function.framework/Headers/FXNValueMap.h +148 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64_x86_64-simulator/Function.framework/Headers/FXNVersion.h +26 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64_x86_64-simulator/Function.framework/Headers/Function.h +18 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64_x86_64-simulator/Function.framework/Info.plist +0 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64_x86_64-simulator/Function.framework/Modules/module.modulemap +6 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64_x86_64-simulator/Function.framework/PrivacyInfo.xcprivacy +36 -0
- package/Plugins/iOS/Function.xcframework/ios-arm64_x86_64-simulator/Function.framework/_CodeSignature/CodeResources +223 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64/Function.framework/Function +0 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64/Function.framework/Headers/FXNConfiguration.h +313 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64/Function.framework/Headers/FXNPrediction.h +165 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64/Function.framework/Headers/FXNPredictionStream.h +63 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64/Function.framework/Headers/FXNPredictor.h +108 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64/Function.framework/Headers/FXNStatus.h +42 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64/Function.framework/Headers/FXNValue.h +395 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64/Function.framework/Headers/FXNValueMap.h +148 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64/Function.framework/Headers/FXNVersion.h +26 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64/Function.framework/Headers/Function.h +18 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64/Function.framework/Info.plist +0 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64/Function.framework/Modules/module.modulemap +6 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64/Function.framework/PrivacyInfo.xcprivacy +36 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64/Function.framework/_CodeSignature/CodeResources +223 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64_x86_64-simulator/Function.framework/Function +0 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64_x86_64-simulator/Function.framework/Headers/FXNConfiguration.h +313 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64_x86_64-simulator/Function.framework/Headers/FXNPrediction.h +165 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64_x86_64-simulator/Function.framework/Headers/FXNPredictionStream.h +63 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64_x86_64-simulator/Function.framework/Headers/FXNPredictor.h +108 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64_x86_64-simulator/Function.framework/Headers/FXNStatus.h +42 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64_x86_64-simulator/Function.framework/Headers/FXNValue.h +395 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64_x86_64-simulator/Function.framework/Headers/FXNValueMap.h +148 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64_x86_64-simulator/Function.framework/Headers/FXNVersion.h +26 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64_x86_64-simulator/Function.framework/Headers/Function.h +18 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64_x86_64-simulator/Function.framework/Info.plist +0 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64_x86_64-simulator/Function.framework/Modules/module.modulemap +6 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64_x86_64-simulator/Function.framework/PrivacyInfo.xcprivacy +36 -0
- package/Plugins/iOS/Function.xcframework/xros-arm64_x86_64-simulator/Function.framework/_CodeSignature/CodeResources +223 -0
- package/Plugins/iOS/Function.xcframework.meta +83 -0
- package/Plugins/iOS.meta +8 -0
- package/Plugins/macOS/Function.dylib +0 -0
- package/Plugins/macOS/Function.dylib.meta +82 -0
- package/Plugins/macOS.meta +8 -0
- package/Plugins.meta +8 -0
- package/README.md +79 -0
- package/README.md.meta +7 -0
- package/Runtime/API/DotNetClient.cs +106 -0
- package/Runtime/API/DotNetClient.cs.meta +11 -0
- package/Runtime/API/MunaClient.cs +96 -0
- package/Runtime/API/MunaClient.cs.meta +11 -0
- package/Runtime/API.meta +8 -0
- package/Runtime/Beta/BetaClient.cs +33 -0
- package/Runtime/Beta/BetaClient.cs.meta +11 -0
- package/Runtime/Beta/PredictionService.cs +32 -0
- package/Runtime/Beta/PredictionService.cs.meta +11 -0
- package/Runtime/Beta/RemoteAcceleration.cs +38 -0
- package/Runtime/Beta/RemoteAcceleration.cs.meta +11 -0
- package/Runtime/Beta/RemotePredictionService.cs +187 -0
- package/Runtime/Beta/RemotePredictionService.cs.meta +11 -0
- package/Runtime/Beta/Value.cs +92 -0
- package/Runtime/Beta/Value.cs.meta +11 -0
- package/Runtime/Beta.meta +8 -0
- package/Runtime/C/Configuration.cs +139 -0
- package/Runtime/C/Configuration.cs.meta +11 -0
- package/Runtime/C/Function.cs +294 -0
- package/Runtime/C/Function.cs.meta +11 -0
- package/Runtime/C/Prediction.cs +70 -0
- package/Runtime/C/Prediction.cs.meta +11 -0
- package/Runtime/C/PredictionStream.cs +36 -0
- package/Runtime/C/PredictionStream.cs.meta +11 -0
- package/Runtime/C/Predictor.cs +42 -0
- package/Runtime/C/Predictor.cs.meta +11 -0
- package/Runtime/C/Value.cs +194 -0
- package/Runtime/C/Value.cs.meta +11 -0
- package/Runtime/C/ValueMap.cs +50 -0
- package/Runtime/C/ValueMap.cs.meta +11 -0
- package/Runtime/C.meta +8 -0
- package/Runtime/Muna.Runtime.asmdef +27 -0
- package/Runtime/Muna.Runtime.asmdef.meta +7 -0
- package/Runtime/Muna.cs +109 -0
- package/Runtime/Muna.cs.meta +11 -0
- package/Runtime/Services/Prediction.cs +247 -0
- package/Runtime/Services/Prediction.cs.meta +11 -0
- package/Runtime/Services/Predictor.cs +44 -0
- package/Runtime/Services/Predictor.cs.meta +11 -0
- package/Runtime/Services/User.cs +43 -0
- package/Runtime/Services/User.cs.meta +11 -0
- package/Runtime/Services.meta +8 -0
- package/Runtime/Types/Dtype.cs +118 -0
- package/Runtime/Types/Dtype.cs.meta +11 -0
- package/Runtime/Types/Image.cs +93 -0
- package/Runtime/Types/Image.cs.meta +11 -0
- package/Runtime/Types/Prediction.cs +113 -0
- package/Runtime/Types/Prediction.cs.meta +11 -0
- package/Runtime/Types/Predictor.cs +193 -0
- package/Runtime/Types/Predictor.cs.meta +11 -0
- package/Runtime/Types/Tensor.cs +58 -0
- package/Runtime/Types/Tensor.cs.meta +11 -0
- package/Runtime/Types/User.cs +54 -0
- package/Runtime/Types/User.cs.meta +11 -0
- package/Runtime/Types.meta +8 -0
- package/Runtime.meta +8 -0
- package/Unity/API/PredictionCacheClient.cs +144 -0
- package/Unity/API/PredictionCacheClient.cs.meta +11 -0
- package/Unity/API/UnityClient.cs +147 -0
- package/Unity/API/UnityClient.cs.meta +11 -0
- package/Unity/API.meta +8 -0
- package/Unity/Internal/MunaSettings.cs +59 -0
- package/Unity/Internal/MunaSettings.cs.meta +11 -0
- package/Unity/Internal.meta +8 -0
- package/Unity/Muna.Unity.asmdef +29 -0
- package/Unity/Muna.Unity.asmdef.meta +7 -0
- package/Unity/MunaUnity.cs +130 -0
- package/Unity/MunaUnity.cs.meta +11 -0
- package/Unity/Types/CachedPrediction.cs +36 -0
- package/Unity/Types/CachedPrediction.cs.meta +11 -0
- package/Unity/Types.meta +8 -0
- package/Unity.meta +8 -0
- package/package.json +38 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Muna
|
|
3
|
+
* Copyright © 2025 NatML Inc. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#nullable enable
|
|
7
|
+
#pragma warning disable 8618
|
|
8
|
+
|
|
9
|
+
namespace Muna {
|
|
10
|
+
|
|
11
|
+
using System;
|
|
12
|
+
using Newtonsoft.Json;
|
|
13
|
+
using Newtonsoft.Json.Converters;
|
|
14
|
+
|
|
15
|
+
/// <summary>
|
|
16
|
+
/// Prediction.
|
|
17
|
+
/// </summary>
|
|
18
|
+
[Preserve, Serializable]
|
|
19
|
+
public class Prediction {
|
|
20
|
+
|
|
21
|
+
/// <summary>
|
|
22
|
+
/// Prediction ID.
|
|
23
|
+
/// </summary>
|
|
24
|
+
public string id;
|
|
25
|
+
|
|
26
|
+
/// <summary>
|
|
27
|
+
/// Predictor tag.
|
|
28
|
+
/// </summary>
|
|
29
|
+
public string tag;
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
/// Date created.
|
|
33
|
+
/// </summary>
|
|
34
|
+
[JsonConverter(typeof(IsoDateTimeConverter))]
|
|
35
|
+
public DateTime created;
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
/// Prediction results.
|
|
39
|
+
/// </summary>
|
|
40
|
+
public object?[]? results;
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
/// Prediction latency in milliseconds.
|
|
44
|
+
/// </summary>
|
|
45
|
+
public double? latency;
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
/// Prediction error.
|
|
49
|
+
/// This is `null` if the prediction completed successfully.
|
|
50
|
+
/// </summary>
|
|
51
|
+
public string? error;
|
|
52
|
+
|
|
53
|
+
/// <summary>
|
|
54
|
+
/// Prediction logs.
|
|
55
|
+
/// </summary>
|
|
56
|
+
public string? logs;
|
|
57
|
+
|
|
58
|
+
/// <summary>
|
|
59
|
+
/// Predictor resources.
|
|
60
|
+
/// </summary>
|
|
61
|
+
public PredictionResource[]? resources;
|
|
62
|
+
|
|
63
|
+
/// <summary>
|
|
64
|
+
/// Prediction configuration token.
|
|
65
|
+
/// </summary>
|
|
66
|
+
public string? configuration;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// <summary>
|
|
70
|
+
/// Prediction resource.
|
|
71
|
+
/// </summary>
|
|
72
|
+
[Preserve, Serializable]
|
|
73
|
+
public class PredictionResource {
|
|
74
|
+
|
|
75
|
+
/// <summary>
|
|
76
|
+
/// Resource type.
|
|
77
|
+
/// </summary>
|
|
78
|
+
public string type;
|
|
79
|
+
|
|
80
|
+
/// <summary>
|
|
81
|
+
/// Resource URL.
|
|
82
|
+
/// </summary>
|
|
83
|
+
public string url;
|
|
84
|
+
|
|
85
|
+
/// <summary>
|
|
86
|
+
/// Resource name.
|
|
87
|
+
/// </summary>
|
|
88
|
+
public string? name;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/// <summary>
|
|
92
|
+
/// Prediction acceleration.
|
|
93
|
+
/// </summary>
|
|
94
|
+
[Flags]
|
|
95
|
+
public enum Acceleration : int {
|
|
96
|
+
/// <summary>
|
|
97
|
+
/// Automatically choose the best acceleration for the current device.
|
|
98
|
+
/// </summary>
|
|
99
|
+
Auto = 0,
|
|
100
|
+
/// <summary>
|
|
101
|
+
/// Predictions run on the CPU.
|
|
102
|
+
/// </summary>
|
|
103
|
+
CPU = 1 << 0,
|
|
104
|
+
/// <summary>
|
|
105
|
+
/// Predictions run on the GPU.
|
|
106
|
+
/// </summary>
|
|
107
|
+
GPU = 1 << 1,
|
|
108
|
+
/// <summary>
|
|
109
|
+
/// Predictions run on the neural processor.
|
|
110
|
+
/// </summary>
|
|
111
|
+
NPU = 1 << 2,
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Muna
|
|
3
|
+
* Copyright © 2025 NatML Inc. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#nullable enable
|
|
7
|
+
#pragma warning disable 8618
|
|
8
|
+
|
|
9
|
+
namespace Muna {
|
|
10
|
+
|
|
11
|
+
using System;
|
|
12
|
+
using System.Runtime.Serialization;
|
|
13
|
+
using Newtonsoft.Json;
|
|
14
|
+
using Newtonsoft.Json.Converters;
|
|
15
|
+
|
|
16
|
+
/// <summary>
|
|
17
|
+
/// Prediction function.
|
|
18
|
+
/// </summary>
|
|
19
|
+
[Preserve, Serializable]
|
|
20
|
+
public class Predictor {
|
|
21
|
+
|
|
22
|
+
/// <summary>
|
|
23
|
+
/// Predictor tag.
|
|
24
|
+
/// </summary>
|
|
25
|
+
public string tag;
|
|
26
|
+
|
|
27
|
+
/// <summary>
|
|
28
|
+
/// Predictor owner.
|
|
29
|
+
/// </summary>
|
|
30
|
+
public User owner;
|
|
31
|
+
|
|
32
|
+
/// <summary>
|
|
33
|
+
/// Predictor name.
|
|
34
|
+
/// </summary>
|
|
35
|
+
public string name;
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
/// Predictor description.
|
|
39
|
+
/// </summary>
|
|
40
|
+
public string description;
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
/// Predictor status.
|
|
44
|
+
/// </summary>
|
|
45
|
+
public PredictorStatus status;
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
/// Predictor access.
|
|
49
|
+
/// </summary>
|
|
50
|
+
public PredictorAccess access;
|
|
51
|
+
|
|
52
|
+
/// <summary>
|
|
53
|
+
/// Date created.
|
|
54
|
+
/// </summary>
|
|
55
|
+
[JsonConverter(typeof(IsoDateTimeConverter))]
|
|
56
|
+
public DateTime created;
|
|
57
|
+
|
|
58
|
+
/// <summary>
|
|
59
|
+
/// Predictor card.
|
|
60
|
+
/// </summary>
|
|
61
|
+
public string? card;
|
|
62
|
+
|
|
63
|
+
/// <summary>
|
|
64
|
+
/// Predictor media URL.
|
|
65
|
+
/// We encourage animated GIFs where possible.
|
|
66
|
+
/// </summary>
|
|
67
|
+
public string? media;
|
|
68
|
+
|
|
69
|
+
/// <summary>
|
|
70
|
+
/// Predictor signature.
|
|
71
|
+
/// </summary>
|
|
72
|
+
public Signature? signature;
|
|
73
|
+
|
|
74
|
+
/// <summary>
|
|
75
|
+
/// Predictor license URL.
|
|
76
|
+
/// </summary>
|
|
77
|
+
public string? license;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/// <summary>
|
|
81
|
+
/// Predictor signature.
|
|
82
|
+
/// </summary>
|
|
83
|
+
[Preserve, Serializable]
|
|
84
|
+
public class Signature {
|
|
85
|
+
|
|
86
|
+
/// <summary>
|
|
87
|
+
/// Prediction inputs.
|
|
88
|
+
/// </summary>
|
|
89
|
+
public Parameter[] inputs;
|
|
90
|
+
|
|
91
|
+
/// <summary>
|
|
92
|
+
/// Prediction outputs.
|
|
93
|
+
/// </summary>
|
|
94
|
+
public Parameter[] outputs;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/// <summary>
|
|
98
|
+
/// Predictor parameter.
|
|
99
|
+
/// </summary>
|
|
100
|
+
[Preserve, Serializable]
|
|
101
|
+
public class Parameter {
|
|
102
|
+
|
|
103
|
+
/// <summary>
|
|
104
|
+
/// Parameter name.
|
|
105
|
+
/// </summary>
|
|
106
|
+
public string? name;
|
|
107
|
+
|
|
108
|
+
/// <summary>
|
|
109
|
+
/// Parameter type.
|
|
110
|
+
/// </summary>
|
|
111
|
+
public Dtype? type;
|
|
112
|
+
|
|
113
|
+
/// <summary>
|
|
114
|
+
/// Parameter description.
|
|
115
|
+
/// </summary>
|
|
116
|
+
public string? description;
|
|
117
|
+
|
|
118
|
+
/// <summary>
|
|
119
|
+
/// Parameter is optional.
|
|
120
|
+
/// </summary>
|
|
121
|
+
public bool? optional;
|
|
122
|
+
|
|
123
|
+
/// <summary>
|
|
124
|
+
/// Parameter value range for numeric parameters.
|
|
125
|
+
/// </summary>
|
|
126
|
+
public float[]? range;
|
|
127
|
+
|
|
128
|
+
/// <summary>
|
|
129
|
+
/// Parameter value choices for enumeration parameters.
|
|
130
|
+
/// </summary>
|
|
131
|
+
public EnumerationMember[]? enumeration;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/// <summary>
|
|
135
|
+
/// Prediction parameter enumeration member.
|
|
136
|
+
/// </summary>
|
|
137
|
+
[Preserve, Serializable]
|
|
138
|
+
public class EnumerationMember {
|
|
139
|
+
/// <summary>
|
|
140
|
+
/// Enumeration member name.
|
|
141
|
+
/// </summary>
|
|
142
|
+
public string name;
|
|
143
|
+
/// <summary>
|
|
144
|
+
/// Enumeration member value.
|
|
145
|
+
/// This is usually a `string` or `int`.
|
|
146
|
+
/// </summary>
|
|
147
|
+
public object value;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// <summary>
|
|
151
|
+
/// Predictor access mode.
|
|
152
|
+
/// </summary>
|
|
153
|
+
[JsonConverter(typeof(StringEnumConverter))]
|
|
154
|
+
public enum PredictorAccess : int {
|
|
155
|
+
/// <summary>
|
|
156
|
+
/// Predictor is public.
|
|
157
|
+
/// </summary>
|
|
158
|
+
[EnumMember(Value = @"public")]
|
|
159
|
+
Public = 0,
|
|
160
|
+
/// <summary>
|
|
161
|
+
/// Predictor is private to the user or organization.
|
|
162
|
+
/// </summary>
|
|
163
|
+
[EnumMember(Value = @"private")]
|
|
164
|
+
Private = 1,
|
|
165
|
+
/// <summary>
|
|
166
|
+
/// Predictor is public but unlisted from discovery.
|
|
167
|
+
/// </summary>
|
|
168
|
+
[EnumMember(Value = @"unlisted")]
|
|
169
|
+
Unlisted = 2,
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/// <summary>
|
|
173
|
+
/// Predictor status.
|
|
174
|
+
/// </summary>
|
|
175
|
+
[JsonConverter(typeof(StringEnumConverter))]
|
|
176
|
+
public enum PredictorStatus : int {
|
|
177
|
+
/// <summary>
|
|
178
|
+
/// Predictor is being compiled.
|
|
179
|
+
/// </summary>
|
|
180
|
+
[EnumMember(Value = @"compiling")]
|
|
181
|
+
Compiling = 0,
|
|
182
|
+
/// <summary>
|
|
183
|
+
/// Predictor is active.
|
|
184
|
+
/// </summary>
|
|
185
|
+
[EnumMember(Value = @"active")]
|
|
186
|
+
Active = 1,
|
|
187
|
+
/// <summary>
|
|
188
|
+
/// Predictor is archived.
|
|
189
|
+
/// </summary>
|
|
190
|
+
[EnumMember(Value = @"archived")]
|
|
191
|
+
Archived = 3,
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Muna
|
|
3
|
+
* Copyright © 2025 NatML Inc. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#nullable enable
|
|
7
|
+
|
|
8
|
+
namespace Muna {
|
|
9
|
+
|
|
10
|
+
/// <summary>
|
|
11
|
+
/// Tensor.
|
|
12
|
+
/// </summary>
|
|
13
|
+
[Preserve]
|
|
14
|
+
public unsafe readonly struct Tensor<T> where T : unmanaged {
|
|
15
|
+
|
|
16
|
+
#region --Client API--
|
|
17
|
+
/// <summary>
|
|
18
|
+
/// Tensor data.
|
|
19
|
+
/// </summary>
|
|
20
|
+
public readonly T[] data;
|
|
21
|
+
|
|
22
|
+
/// <summary>
|
|
23
|
+
/// Tensor shape.
|
|
24
|
+
/// </summary>
|
|
25
|
+
public readonly int[] shape;
|
|
26
|
+
|
|
27
|
+
/// <summary>
|
|
28
|
+
/// Create a tensor.
|
|
29
|
+
/// </summary>
|
|
30
|
+
/// <param name="data">Tensor data.</param>
|
|
31
|
+
/// <param name="shape">Tensor shape.</param>
|
|
32
|
+
public Tensor(T[] data, int[] shape) {
|
|
33
|
+
this.data = data;
|
|
34
|
+
this.nativeData = null;
|
|
35
|
+
this.shape = shape;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/// <summary>
|
|
39
|
+
/// Create a tensor.
|
|
40
|
+
/// NOTE: DO NOT use this overload unless you absolutely know what you are doing.
|
|
41
|
+
/// </summary>
|
|
42
|
+
/// <param name="data">Tensor data.</param>
|
|
43
|
+
/// <param name="shape">Tensor shape.</param>
|
|
44
|
+
public Tensor(T* data, int[] shape) { // Enables zero copy into `FXNValue`
|
|
45
|
+
this.data = null!;
|
|
46
|
+
this.nativeData = data;
|
|
47
|
+
this.shape = shape;
|
|
48
|
+
}
|
|
49
|
+
#endregion
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
#region --Operations--
|
|
53
|
+
private readonly T* nativeData;
|
|
54
|
+
|
|
55
|
+
public ref T GetPinnableReference() => ref (nativeData == null ? ref data[0] : ref *nativeData);
|
|
56
|
+
#endregion
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Muna
|
|
3
|
+
* Copyright © 2025 NatML Inc. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#nullable enable
|
|
7
|
+
#pragma warning disable 8618
|
|
8
|
+
|
|
9
|
+
namespace Muna {
|
|
10
|
+
|
|
11
|
+
using System;
|
|
12
|
+
|
|
13
|
+
/// <summary>
|
|
14
|
+
/// Muna user.
|
|
15
|
+
/// </summary>
|
|
16
|
+
[Preserve, Serializable]
|
|
17
|
+
public class User {
|
|
18
|
+
|
|
19
|
+
/// <summary>
|
|
20
|
+
/// Username.
|
|
21
|
+
/// </summary>
|
|
22
|
+
public string username;
|
|
23
|
+
|
|
24
|
+
/// <summary>
|
|
25
|
+
/// Date created.
|
|
26
|
+
/// </summary>
|
|
27
|
+
public string created;
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
/// User display name.
|
|
31
|
+
/// </summary>
|
|
32
|
+
public string? name;
|
|
33
|
+
|
|
34
|
+
/// <summary>
|
|
35
|
+
/// User avatar.
|
|
36
|
+
/// </summary>
|
|
37
|
+
public string? avatar;
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
/// User bio.
|
|
41
|
+
/// </summary>
|
|
42
|
+
public string? bio;
|
|
43
|
+
|
|
44
|
+
/// <summary>
|
|
45
|
+
/// User website.
|
|
46
|
+
/// </summary>
|
|
47
|
+
public string? website;
|
|
48
|
+
|
|
49
|
+
/// <summary>
|
|
50
|
+
/// User GitHub handle.
|
|
51
|
+
/// </summary>
|
|
52
|
+
public string? github;
|
|
53
|
+
}
|
|
54
|
+
}
|
package/Runtime.meta
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Muna
|
|
3
|
+
* Copyright © 2025 NatML Inc. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#nullable enable
|
|
7
|
+
|
|
8
|
+
namespace Muna.API {
|
|
9
|
+
|
|
10
|
+
using System;
|
|
11
|
+
using System.Collections.Generic;
|
|
12
|
+
using System.IO;
|
|
13
|
+
using System.Linq;
|
|
14
|
+
using System.Threading.Tasks;
|
|
15
|
+
using UnityEngine;
|
|
16
|
+
using Newtonsoft.Json;
|
|
17
|
+
using Services;
|
|
18
|
+
|
|
19
|
+
/// <summary>
|
|
20
|
+
/// Muna API client for Unity Engine.
|
|
21
|
+
/// This uses Unity APIs for performing web requests.
|
|
22
|
+
/// Furthermore, this handles partial prediction caching for edge predictors.
|
|
23
|
+
/// </summary>
|
|
24
|
+
internal sealed class PredictionCacheClient : UnityClient {
|
|
25
|
+
|
|
26
|
+
#region --Client API--
|
|
27
|
+
/// <summary>
|
|
28
|
+
/// Create the client.
|
|
29
|
+
/// </summary>
|
|
30
|
+
/// <param name="url">Muna API URL.</param>
|
|
31
|
+
/// <param name="accessKey">Muna access key.</param>
|
|
32
|
+
/// <param name="cache">Prediction cache.</param>
|
|
33
|
+
public PredictionCacheClient(
|
|
34
|
+
string url,
|
|
35
|
+
string? accessKey,
|
|
36
|
+
List<CachedPrediction>? cache = default
|
|
37
|
+
) : base(url, accessKey) => this.cache = cache ?? new();
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
/// Perform a request to a Muna REST endpoint.
|
|
41
|
+
/// </summary>
|
|
42
|
+
/// <typeparam name="T">Deserialized response type.</typeparam>
|
|
43
|
+
/// <param name="method">HTTP request method.</param>
|
|
44
|
+
/// <param name="path">Endpoint path.</param>
|
|
45
|
+
/// <param name="payload">Request body.</param>
|
|
46
|
+
/// <param name="headers">Request body.</param>
|
|
47
|
+
/// <returns>Deserialized response.</returns>
|
|
48
|
+
public override async Task<T?> Request<T>(
|
|
49
|
+
string method,
|
|
50
|
+
string path,
|
|
51
|
+
Dictionary<string, object?>? payload = default,
|
|
52
|
+
Dictionary<string, string>? headers = default
|
|
53
|
+
) where T : class {
|
|
54
|
+
// Check payload
|
|
55
|
+
var tag = payload?.TryGetValue(@"tag", out var t) ?? false ? t as string : null;
|
|
56
|
+
var clientId = payload?.TryGetValue(@"clientId", out var id) ?? false ? id as string : null;
|
|
57
|
+
var configurationId = payload?.TryGetValue(@"configurationId", out var configuration) ?? false ?
|
|
58
|
+
configuration as string :
|
|
59
|
+
null;
|
|
60
|
+
if (
|
|
61
|
+
method != @"POST" ||
|
|
62
|
+
path != @"/predictions" ||
|
|
63
|
+
string.IsNullOrEmpty(tag) ||
|
|
64
|
+
string.IsNullOrEmpty(clientId) ||
|
|
65
|
+
string.IsNullOrEmpty(configurationId)
|
|
66
|
+
)
|
|
67
|
+
return await base.Request<T>(method, path, payload, headers);
|
|
68
|
+
// Get cached prediction
|
|
69
|
+
var sanitizedTag = tag.Substring(1).Replace("/", "_");
|
|
70
|
+
var cachePath = Path.Combine(
|
|
71
|
+
PredictorCachePath,
|
|
72
|
+
clientId,
|
|
73
|
+
configurationId,
|
|
74
|
+
$"{sanitizedTag}.json"
|
|
75
|
+
);
|
|
76
|
+
var cachedPrediction = TryLoadCachedPrediction(cachePath);
|
|
77
|
+
if (cachedPrediction != null)
|
|
78
|
+
return cachedPrediction as T;
|
|
79
|
+
// Create prediction
|
|
80
|
+
var predictionId = cache.FirstOrDefault(p => p.tag == tag && p.clientId == clientId)?.id;
|
|
81
|
+
var prediction = await base.Request<Prediction>(
|
|
82
|
+
method: @"POST",
|
|
83
|
+
path: @"/predictions",
|
|
84
|
+
payload: new () {
|
|
85
|
+
[@"tag"] = tag,
|
|
86
|
+
[@"clientId"] = clientId,
|
|
87
|
+
[@"configurationId"] = configurationId,
|
|
88
|
+
[@"predictionId"] = predictionId,
|
|
89
|
+
},
|
|
90
|
+
headers
|
|
91
|
+
);
|
|
92
|
+
prediction!.resources = await Task.WhenAll(prediction.resources.Select(GetCachedResource));
|
|
93
|
+
// Write
|
|
94
|
+
var predictionJson = JsonConvert.SerializeObject(
|
|
95
|
+
new CachedPrediction(prediction, clientId),
|
|
96
|
+
Formatting.Indented
|
|
97
|
+
);
|
|
98
|
+
Directory.CreateDirectory(Path.GetDirectoryName(cachePath));
|
|
99
|
+
File.WriteAllText(cachePath, predictionJson);
|
|
100
|
+
// Return
|
|
101
|
+
return prediction as T;
|
|
102
|
+
}
|
|
103
|
+
#endregion
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
#region --Operations--
|
|
107
|
+
private readonly List<CachedPrediction> cache;
|
|
108
|
+
private static string CacheRoot => Application.isEditor ?
|
|
109
|
+
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), @".fxn") :
|
|
110
|
+
Path.Combine(Application.persistentDataPath, @"fxn");
|
|
111
|
+
private static string ResourceCachePath => Path.Combine(CacheRoot, @"cache");
|
|
112
|
+
private static string PredictorCachePath => Path.Combine(CacheRoot, @"predictors");
|
|
113
|
+
|
|
114
|
+
private async Task<PredictionResource> GetCachedResource(PredictionResource resource) {
|
|
115
|
+
var path = PredictionService.GetResourcePath(resource, ResourceCachePath);
|
|
116
|
+
if (!File.Exists(path)) {
|
|
117
|
+
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
|
118
|
+
using var dataStream = await Download(resource.url);
|
|
119
|
+
using var fileStream = File.Create(path);
|
|
120
|
+
dataStream.CopyTo(fileStream);
|
|
121
|
+
}
|
|
122
|
+
return new PredictionResource { type = resource.type, url = $"file://{path}" };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private static Prediction? TryLoadCachedPrediction(string path) {
|
|
126
|
+
if (!File.Exists(path))
|
|
127
|
+
return null;
|
|
128
|
+
var json = File.ReadAllText(path);
|
|
129
|
+
var prediction = JsonConvert.DeserializeObject<Prediction>(json)!;
|
|
130
|
+
var resources = prediction.resources.Select(res => new PredictionResource {
|
|
131
|
+
type = res.type,
|
|
132
|
+
url = $"file://{PredictionService.GetResourcePath(res, ResourceCachePath)}",
|
|
133
|
+
name = res.name
|
|
134
|
+
}).ToArray();
|
|
135
|
+
if (!resources.All(res => File.Exists(new Uri(res.url).LocalPath))) {
|
|
136
|
+
File.Delete(path);
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
prediction.resources = resources;
|
|
140
|
+
return prediction;
|
|
141
|
+
}
|
|
142
|
+
#endregion
|
|
143
|
+
}
|
|
144
|
+
}
|