|
@@ -26,16 +26,25 @@
|
|
|
package remotecontrol
|
|
|
|
|
|
import (
|
|
|
+ context "context"
|
|
|
+ fmt "fmt"
|
|
|
"log"
|
|
|
+ "net"
|
|
|
+
|
|
|
+ "google.golang.org/grpc/codes"
|
|
|
+ status "google.golang.org/grpc/status"
|
|
|
|
|
|
neuralnetworkbase "../neuralnetworkbase"
|
|
|
"gonum.org/v1/gonum/mat"
|
|
|
+ grpc "google.golang.org/grpc"
|
|
|
)
|
|
|
|
|
|
type RemoteControl struct {
|
|
|
+ nn *neuralnetworkbase.NeuralNetwork
|
|
|
}
|
|
|
|
|
|
func (rw *RemoteControl) Init(nn *neuralnetworkbase.NeuralNetwork) {
|
|
|
+ rw.nn = nn
|
|
|
}
|
|
|
|
|
|
func (rw *RemoteControl) UpdateActivations(l int, a *mat.Dense) {
|
|
@@ -66,3 +75,37 @@ func NewLayerMatrix(l int, dense *mat.Dense, contentType LayerMatrix_ContentType
|
|
|
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+func (rw *RemoteControl) GetConfiguration(context.Context, *None) (*Configuration, error) {
|
|
|
+ return nil, status.Error(codes.Unimplemented, "Not implemented")
|
|
|
+}
|
|
|
+
|
|
|
+func (rw *RemoteControl) Activations(*None, RemoteControl_ActivationsServer) error {
|
|
|
+ return status.Error(codes.Unimplemented, "Not implemented")
|
|
|
+}
|
|
|
+
|
|
|
+func (rw *RemoteControl) Biases(*None, RemoteControl_BiasesServer) error {
|
|
|
+ return status.Error(codes.Unimplemented, "Not implemented")
|
|
|
+}
|
|
|
+
|
|
|
+func (rw *RemoteControl) Weights(*None, RemoteControl_WeightsServer) error {
|
|
|
+ return status.Error(codes.Unimplemented, "Not implemented")
|
|
|
+}
|
|
|
+
|
|
|
+func (rw *RemoteControl) Predict(context.Context, *Matrix) (*Matrix, error) {
|
|
|
+ return nil, status.Error(codes.Unimplemented, "Not implemented")
|
|
|
+}
|
|
|
+
|
|
|
+func (rw *RemoteControl) Run() {
|
|
|
+ grpcServer := grpc.NewServer()
|
|
|
+ RegisterRemoteControlServer(grpcServer, rw)
|
|
|
+ lis, err := net.Listen("tcp", "localhost:65001")
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("Failed to listen: %v\n", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ fmt.Printf("Listen localhost:65001\n")
|
|
|
+ if err := grpcServer.Serve(lis); err != nil {
|
|
|
+ fmt.Printf("Failed to serve: %v\n", err)
|
|
|
+ }
|
|
|
+}
|