Post

Replies

Boosts

Views

Activity

Torchaudio Models convert to cormel
I have seen a lot of tutorials on pytorchvision models being able to be converted to coreml models but I have not been able to google or find any tutorials for torchaudio models. Is converting to a torchaudio to coreml model even possible? Does anybody have links that show how to do it?
0
0
131
2w
Static function encapsulation in Swift by passing Protocols.Type better than OO encapsulation and just as testable?
Given that I have a function that does not need to share and store state; should I use a static class/struct/enum to hold the function? I have read in many places that it is a bad design to use static functions to hold code, as static function do not adhere to the SOLID principles and are considered procedural code. Testability seems to be there as I can isolate the parent class with the injected static Enums by injecting mock static enums. E.g. I can encapsulate and have polymorphism by using protocols for static functions: Static Protocol Approach enum StaticEnum: TestProtocol { static func staticMethod() { print("hello") } } enum StaticEnum2: TestProtocol { static func staticMethod() { print("hello2") } } protocol TestProtocol { static func staticMethod() } class TestClass { let staticTypes: [TestProtocol.Type] init (staticTypes: [TestProtocol.Type]) { self.staticTypes = staticTypes } } class TestFactory { func makeTestClass() -> TestClass { return TestClass(staticTypes: [StaticEnum.self, StaticEnum2.self]) } } vs Object Oriented Approach class InstanceClass: TestProtocol { func staticMethod() { print("hello") } } class InstanceClass2: TestProtocol { func staticMethod() { print("hello2") } } protocol TestProtocol { func staticMethod() } class TestClass { let instances: [TestProtocol] init (instances: [TestProtocol]) { self.instances = instances } } class TestFactory { func makeTestClass() -> TestClass { return TestClass(instances: [InstanceClass(), InstanceClass2()]) } } The static version still allows for protocol polymorphism as you can have multiple enums adhere to the static protocols. Furthermore no initialisation is needed after the first dispatch call to create the static function. Is there any drawback in using the Static Protocol approach?
0
0
994
May ’22