How to use init method of targets Package

Best Syzkaller code snippet using targets.init

target.go

Source:target.go Github

copy

Full Screen

1// +build !container2package targets3import (4 "context"5 "fmt"6 "github.com/kubemq-hub/builder/connector/common"7 "github.com/kubemq-io/kubemq-targets/pkg/logger"8 "github.com/kubemq-io/kubemq-targets/targets/aws/amazonmq"9 "github.com/kubemq-io/kubemq-targets/targets/aws/athena"10 "github.com/kubemq-io/kubemq-targets/targets/aws/cloudwatch/events"11 "github.com/kubemq-io/kubemq-targets/targets/aws/cloudwatch/logs"12 "github.com/kubemq-io/kubemq-targets/targets/aws/cloudwatch/metrics"13 "github.com/kubemq-io/kubemq-targets/targets/aws/dynamodb"14 "github.com/kubemq-io/kubemq-targets/targets/aws/elasticsearch"15 "github.com/kubemq-io/kubemq-targets/targets/aws/keyspaces"16 "github.com/kubemq-io/kubemq-targets/targets/aws/kinesis"17 "github.com/kubemq-io/kubemq-targets/targets/aws/lambda"18 "github.com/kubemq-io/kubemq-targets/targets/aws/msk"19 "github.com/kubemq-io/kubemq-targets/targets/aws/s3"20 "github.com/kubemq-io/kubemq-targets/targets/aws/sns"21 "github.com/kubemq-io/kubemq-targets/targets/azure/eventhubs"22 "github.com/kubemq-io/kubemq-targets/targets/azure/servicebus"23 "github.com/kubemq-io/kubemq-targets/targets/azure/storage/blob"24 "github.com/kubemq-io/kubemq-targets/targets/azure/storage/files"25 "github.com/kubemq-io/kubemq-targets/targets/azure/storage/queue"26 "github.com/kubemq-io/kubemq-targets/targets/azure/stores/azuresql"27 azurmysql "github.com/kubemq-io/kubemq-targets/targets/azure/stores/mysql"28 azurpostgres "github.com/kubemq-io/kubemq-targets/targets/azure/stores/postgres"29 "github.com/kubemq-io/kubemq-targets/targets/cache/hazelcast"30 "github.com/kubemq-io/kubemq-targets/targets/echo"31 "github.com/kubemq-io/kubemq-targets/targets/gcp/firebase"32 "github.com/kubemq-io/kubemq-targets/targets/storage/filesystem"33 "github.com/kubemq-io/kubemq-targets/targets/stores/crate"34 //"github.com/kubemq-io/kubemq-targets/targets/messaging/ibmmq"35 "github.com/kubemq-io/kubemq-targets/targets/messaging/nats"36 "github.com/kubemq-io/kubemq-targets/targets/storage/hdfs"37 "github.com/kubemq-io/kubemq-targets/targets/stores/aerospike"38 "github.com/kubemq-io/kubemq-targets/targets/stores/cockroachdb"39 "github.com/kubemq-io/kubemq-targets/targets/stores/consulkv"40 "github.com/kubemq-io/kubemq-targets/targets/stores/elastic"41 "github.com/kubemq-io/kubemq-targets/targets/stores/percona"42 "github.com/kubemq-io/kubemq-targets/targets/stores/rethinkdb"43 "github.com/kubemq-io/kubemq-targets/targets/stores/singlestore"44 "github.com/kubemq-io/kubemq-targets/config"45 awsmariadb "github.com/kubemq-io/kubemq-targets/targets/aws/rds/mariadb"46 awsmssql "github.com/kubemq-io/kubemq-targets/targets/aws/rds/mssql"47 awsmysql "github.com/kubemq-io/kubemq-targets/targets/aws/rds/mysql"48 awspostgres "github.com/kubemq-io/kubemq-targets/targets/aws/rds/postgres"49 "github.com/kubemq-io/kubemq-targets/targets/aws/rds/redshift"50 redshiftsvc "github.com/kubemq-io/kubemq-targets/targets/aws/redshift"51 "github.com/kubemq-io/kubemq-targets/targets/aws/sqs"52 "github.com/kubemq-io/kubemq-targets/targets/cache/memcached"53 "github.com/kubemq-io/kubemq-targets/targets/cache/redis"54 "github.com/kubemq-io/kubemq-targets/targets/gcp/bigquery"55 "github.com/kubemq-io/kubemq-targets/targets/gcp/bigtable"56 "github.com/kubemq-io/kubemq-targets/targets/gcp/cloudfunctions"57 "github.com/kubemq-io/kubemq-targets/targets/gcp/firestore"58 gcpmemcached "github.com/kubemq-io/kubemq-targets/targets/gcp/memorystore/memcached"59 gcpredis "github.com/kubemq-io/kubemq-targets/targets/gcp/memorystore/redis"60 "github.com/kubemq-io/kubemq-targets/targets/gcp/pubsub"61 "github.com/kubemq-io/kubemq-targets/targets/gcp/spanner"62 gcpmysql "github.com/kubemq-io/kubemq-targets/targets/gcp/sql/mysql"63 gcppostgres "github.com/kubemq-io/kubemq-targets/targets/gcp/sql/postgres"64 "github.com/kubemq-io/kubemq-targets/targets/gcp/storage"65 "github.com/kubemq-io/kubemq-targets/targets/http"66 "github.com/kubemq-io/kubemq-targets/targets/messaging/activemq"67 "github.com/kubemq-io/kubemq-targets/targets/messaging/kafka"68 "github.com/kubemq-io/kubemq-targets/targets/messaging/mqtt"69 "github.com/kubemq-io/kubemq-targets/targets/messaging/rabbitmq"70 "github.com/kubemq-io/kubemq-targets/targets/serverless/openfaas"71 "github.com/kubemq-io/kubemq-targets/targets/storage/minio"72 "github.com/kubemq-io/kubemq-targets/targets/stores/cassandra"73 "github.com/kubemq-io/kubemq-targets/targets/stores/couchbase"74 "github.com/kubemq-io/kubemq-targets/targets/stores/mongodb"75 "github.com/kubemq-io/kubemq-targets/targets/stores/mssql"76 "github.com/kubemq-io/kubemq-targets/targets/stores/mysql"77 "github.com/kubemq-io/kubemq-targets/targets/stores/postgres"78 "github.com/kubemq-io/kubemq-targets/types"79)80type Target interface {81 Init(ctx context.Context, cfg config.Spec, log *logger.Logger) error82 Do(ctx context.Context, request *types.Request) (*types.Response, error)83 Stop() error84 Connector() *common.Connector85}86func Init(ctx context.Context, cfg config.Spec, log *logger.Logger) (Target, error) {87 switch cfg.Kind {88 case "storage.filesystem":89 target := filesystem.New()90 if err := target.Init(ctx, cfg, log); err != nil {91 return nil, err92 }93 return target, nil94 case "echo":95 target := echo.New()96 if err := target.Init(ctx, cfg, log); err != nil {97 return nil, err98 }99 return target, nil100 case "aws.sqs":101 target := sqs.New()102 if err := target.Init(ctx, cfg, log); err != nil {103 return nil, err104 }105 return target, nil106 case "aws.sns":107 target := sns.New()108 if err := target.Init(ctx, cfg, log); err != nil {109 return nil, err110 }111 return target, nil112 case "aws.s3":113 target := s3.New()114 if err := target.Init(ctx, cfg, log); err != nil {115 return nil, err116 }117 return target, nil118 case "aws.lambda":119 target := lambda.New()120 if err := target.Init(ctx, cfg, log); err != nil {121 return nil, err122 }123 return target, nil124 case "aws.dynamodb":125 target := dynamodb.New()126 if err := target.Init(ctx, cfg, log); err != nil {127 return nil, err128 }129 return target, nil130 case "aws.athena":131 target := athena.New()132 if err := target.Init(ctx, cfg, log); err != nil {133 return nil, err134 }135 return target, nil136 case "aws.kinesis":137 target := kinesis.New()138 if err := target.Init(ctx, cfg, log); err != nil {139 return nil, err140 }141 return target, nil142 case "aws.elasticsearch":143 target := elasticsearch.New()144 if err := target.Init(ctx, cfg, log); err != nil {145 return nil, err146 }147 return target, nil148 case "aws.cloudwatch.logs":149 target := logs.New()150 if err := target.Init(ctx, cfg, log); err != nil {151 return nil, err152 }153 return target, nil154 case "aws.cloudwatch.events":155 target := events.New()156 if err := target.Init(ctx, cfg, log); err != nil {157 return nil, err158 }159 return target, nil160 case "aws.cloudwatch.metrics":161 target := metrics.New()162 if err := target.Init(ctx, cfg, log); err != nil {163 return nil, err164 }165 return target, nil166 case "aws.rds.mysql":167 target := awsmysql.New()168 if err := target.Init(ctx, cfg, log); err != nil {169 return nil, err170 }171 return target, nil172 case "aws.rds.postgres":173 target := awspostgres.New()174 if err := target.Init(ctx, cfg, log); err != nil {175 return nil, err176 }177 return target, nil178 case "aws.rds.mariadb":179 target := awsmariadb.New()180 if err := target.Init(ctx, cfg, log); err != nil {181 return nil, err182 }183 return target, nil184 case "aws.rds.mssql":185 target := awsmssql.New()186 if err := target.Init(ctx, cfg, log); err != nil {187 return nil, err188 }189 return target, nil190 case "aws.rds.redshift":191 target := redshift.New()192 if err := target.Init(ctx, cfg, log); err != nil {193 return nil, err194 }195 return target, nil196 case "aws.redshift.service":197 target := redshiftsvc.New()198 if err := target.Init(ctx, cfg, log); err != nil {199 return nil, err200 }201 return target, nil202 case "aws.keyspaces":203 target := keyspaces.New()204 if err := target.Init(ctx, cfg, log); err != nil {205 return nil, err206 }207 return target, nil208 case "aws.msk":209 target := msk.New()210 if err := target.Init(ctx, cfg, log); err != nil {211 return nil, err212 }213 return target, nil214 case "aws.amazonmq":215 target := amazonmq.New()216 if err := target.Init(ctx, cfg, log); err != nil {217 return nil, err218 }219 return target, nil220 case "cache.redis":221 target := redis.New()222 if err := target.Init(ctx, cfg, log); err != nil {223 return nil, err224 }225 return target, nil226 case "cache.memcached":227 target := memcached.New()228 if err := target.Init(ctx, cfg, log); err != nil {229 return nil, err230 }231 return target, nil232 case "cache.hazelcast":233 target := hazelcast.New()234 if err := target.Init(ctx, cfg, log); err != nil {235 return nil, err236 }237 return target, nil238 case "gcp.cache.memcached":239 target := gcpmemcached.New()240 if err := target.Init(ctx, cfg, log); err != nil {241 return nil, err242 }243 return target, nil244 case "gcp.cache.redis":245 target := gcpredis.New()246 if err := target.Init(ctx, cfg, log); err != nil {247 return nil, err248 }249 return target, nil250 case "gcp.bigquery":251 target := bigquery.New()252 if err := target.Init(ctx, cfg, log); err != nil {253 return nil, err254 }255 return target, nil256 case "gcp.bigtable":257 target := bigtable.New()258 if err := target.Init(ctx, cfg, log); err != nil {259 return nil, err260 }261 return target, nil262 case "gcp.cloudfunctions":263 target := cloudfunctions.New()264 if err := target.Init(ctx, cfg, log); err != nil {265 return nil, err266 }267 return target, nil268 case "gcp.firestore":269 target := firestore.New()270 if err := target.Init(ctx, cfg, log); err != nil {271 return nil, err272 }273 return target, nil274 case "gcp.firebase":275 target := firebase.New()276 if err := target.Init(ctx, cfg, log); err != nil {277 return nil, err278 }279 return target, nil280 case "gcp.stores.postgres":281 target := gcppostgres.New()282 if err := target.Init(ctx, cfg, log); err != nil {283 return nil, err284 }285 return target, nil286 case "gcp.stores.mysql":287 target := gcpmysql.New()288 if err := target.Init(ctx, cfg, log); err != nil {289 return nil, err290 }291 return target, nil292 case "gcp.pubsub":293 target := pubsub.New()294 if err := target.Init(ctx, cfg, log); err != nil {295 return nil, err296 }297 return target, nil298 case "gcp.spanner":299 target := spanner.New()300 if err := target.Init(ctx, cfg, log); err != nil {301 return nil, err302 }303 return target, nil304 case "gcp.storage":305 target := storage.New()306 if err := target.Init(ctx, cfg, log); err != nil {307 return nil, err308 }309 return target, nil310 case "http":311 target := http.New()312 if err := target.Init(ctx, cfg, log); err != nil {313 return nil, err314 }315 return target, nil316 case "messaging.activemq":317 target := activemq.New()318 if err := target.Init(ctx, cfg, log); err != nil {319 return nil, err320 }321 return target, nil322 case "messaging.kafka":323 target := kafka.New()324 if err := target.Init(ctx, cfg, log); err != nil {325 return nil, err326 }327 return target, nil328 case "messaging.mqtt":329 target := mqtt.New()330 if err := target.Init(ctx, cfg, log); err != nil {331 return nil, err332 }333 return target, nil334 case "messaging.rabbitmq":335 target := rabbitmq.New()336 if err := target.Init(ctx, cfg, log); err != nil {337 return nil, err338 }339 return target, nil340 //case "messaging.ibmmq":341 // target := ibmmq.New()342 // if err := target.Init(ctx, cfg); err != nil {343 // return nil, err344 // }345 // return target, nil346 case "messaging.nats":347 target := nats.New()348 if err := target.Init(ctx, cfg, log); err != nil {349 return nil, err350 }351 return target, nil352 case "stores.cassandra":353 target := cassandra.New()354 if err := target.Init(ctx, cfg, log); err != nil {355 return nil, err356 }357 return target, nil358 case "stores.couchbase":359 target := couchbase.New()360 if err := target.Init(ctx, cfg, log); err != nil {361 return nil, err362 }363 return target, nil364 case "stores.mongodb":365 target := mongodb.New()366 if err := target.Init(ctx, cfg, log); err != nil {367 return nil, err368 }369 return target, nil370 case "stores.mssql":371 target := mssql.New()372 if err := target.Init(ctx, cfg, log); err != nil {373 return nil, err374 }375 return target, nil376 case "stores.mysql":377 target := mysql.New()378 if err := target.Init(ctx, cfg, log); err != nil {379 return nil, err380 }381 return target, nil382 case "stores.elasticsearch":383 target := elastic.New()384 if err := target.Init(ctx, cfg, log); err != nil {385 return nil, err386 }387 return target, nil388 case "stores.postgres":389 target := postgres.New()390 if err := target.Init(ctx, cfg, log); err != nil {391 return nil, err392 }393 return target, nil394 case "stores.cockroachdb":395 target := cockroachdb.New()396 if err := target.Init(ctx, cfg, log); err != nil {397 return nil, err398 }399 return target, nil400 case "stores.percona":401 target := percona.New()402 if err := target.Init(ctx, cfg, log); err != nil {403 return nil, err404 }405 return target, nil406 case "stores.crate":407 target := crate.New()408 if err := target.Init(ctx, cfg, log); err != nil {409 return nil, err410 }411 return target, nil412 case "stores.aerospike":413 target := aerospike.New()414 if err := target.Init(ctx, cfg, log); err != nil {415 return nil, err416 }417 return target, nil418 case "stores.rethinkdb":419 target := rethinkdb.New()420 if err := target.Init(ctx, cfg, log); err != nil {421 return nil, err422 }423 return target, nil424 case "stores.singlestore":425 target := singlestore.New()426 if err := target.Init(ctx, cfg, log); err != nil {427 return nil, err428 }429 return target, nil430 case "stores.consulkv":431 target := consulkv.New()432 if err := target.Init(ctx, cfg, log); err != nil {433 return nil, err434 }435 return target, nil436 case "serverless.openfaas":437 target := openfaas.New()438 if err := target.Init(ctx, cfg, log); err != nil {439 return nil, err440 }441 return target, nil442 case "storage.minio":443 target := minio.New()444 if err := target.Init(ctx, cfg, log); err != nil {445 return nil, err446 }447 return target, nil448 case "storage.hdfs":449 target := hdfs.New()450 if err := target.Init(ctx, cfg, log); err != nil {451 return nil, err452 }453 return target, nil454 case "azure.storage.blob":455 target := blob.New()456 if err := target.Init(ctx, cfg, log); err != nil {457 return nil, err458 }459 return target, nil460 case "azure.storage.queue":461 target := queue.New()462 if err := target.Init(ctx, cfg, log); err != nil {463 return nil, err464 }465 return target, nil466 case "azure.storage.files":467 target := files.New()468 if err := target.Init(ctx, cfg, log); err != nil {469 return nil, err470 }471 return target, nil472 case "azure.eventhubs":473 target := eventhubs.New()474 if err := target.Init(ctx, cfg, log); err != nil {475 return nil, err476 }477 return target, nil478 case "azure.servicebus":479 target := servicebus.New()480 if err := target.Init(ctx, cfg, log); err != nil {481 return nil, err482 }483 return target, nil484 case "azure.stores.azuresql":485 target := azuresql.New()486 if err := target.Init(ctx, cfg, log); err != nil {487 return nil, err488 }489 return target, nil490 case "azure.stores.postgres":491 target := azurpostgres.New()492 if err := target.Init(ctx, cfg, log); err != nil {493 return nil, err494 }495 return target, nil496 case "azure.stores.mysql":497 target := azurmysql.New()498 if err := target.Init(ctx, cfg, log); err != nil {499 return nil, err500 }501 return target, nil502 default:503 return nil, fmt.Errorf("invalid kind %s for target %s", cfg.Kind, cfg.Name)504 }505}506func Connectors() common.Connectors {507 return []*common.Connector{508 echo.Connector(),509 // cache510 redis.Connector(),511 memcached.Connector(),512 //stores513 postgres.Connector(),514 crate.Connector(),515 mysql.Connector(),516 mssql.Connector(),517 mongodb.Connector(),518 elastic.Connector(),519 cassandra.Connector(),520 couchbase.Connector(),521 cockroachdb.Connector(),522 percona.Connector(),523 aerospike.Connector(),524 rethinkdb.Connector(),525 singlestore.Connector(),526 consulkv.Connector(),527 // http528 http.Connector(),529 // messaging530 mqtt.Connector(),531 rabbitmq.Connector(),532 kafka.Connector(),533 activemq.Connector(),534 //ibmmq.Connector(),535 nats.Connector(),536 hazelcast.Connector(),537 //storage538 minio.Connector(),539 hdfs.Connector(),540 filesystem.Connector(),541 // serverless542 openfaas.Connector(),543 // aws544 sqs.Connector(),545 sns.Connector(),546 s3.Connector(),547 amazonmq.Connector(),548 awspostgres.Connector(),549 awsmysql.Connector(),550 awsmariadb.Connector(),551 awsmssql.Connector(),552 dynamodb.Connector(),553 redshift.Connector(),554 redshiftsvc.Connector(),555 athena.Connector(),556 msk.Connector(),557 lambda.Connector(),558 kinesis.Connector(),559 keyspaces.Connector(),560 elasticsearch.Connector(),561 events.Connector(),562 logs.Connector(),563 metrics.Connector(),564 // gcp565 pubsub.Connector(),566 gcpredis.Connector(),567 gcpmemcached.Connector(),568 gcppostgres.Connector(),569 gcpmysql.Connector(),570 spanner.Connector(),571 bigtable.Connector(),572 bigquery.Connector(),573 cloudfunctions.Connector(),574 firebase.Connector(),575 firestore.Connector(),576 storage.Connector(),577 // azure578 azurpostgres.Connector(),579 azurmysql.Connector(),580 azuresql.Connector(),581 queue.Connector(),582 files.Connector(),583 blob.Connector(),584 servicebus.Connector(),585 eventhubs.Connector(),586 }587}...

Full Screen

Full Screen

op_ctc_loss_test.go

Source:op_ctc_loss_test.go Github

copy

Full Screen

1package gorgonia2import (3 "fmt"4 "testing"5 "github.com/stretchr/testify/require"6 "gorgonia.org/tensor"7)8func TestCTCLossDo(t *testing.T) {9 testCases := []struct {10 Dtype tensor.Dtype11 reduction Reduction12 logProbsInit InitWFn13 logProbsShape tensor.Shape14 targetsInit InitWFn15 targetsShape tensor.Shape16 inputLengthsInit InitWFn17 inputLengthsShape tensor.Shape18 targetLengthsInit InitWFn19 targetLengthsShape tensor.Shape20 expectedOutput tensor.Tensor21 expectedInputGrad tensor.Tensor22 }{23 {24 Dtype: Float64,25 reduction: ReductionMean,26 logProbsInit: RangedFromWithStep(0.0, 0.01),27 logProbsShape: tensor.Shape{4, 4, 4},28 targetsInit: RangedFromWithStep(2, 0),29 targetsShape: tensor.Shape{4, 4},30 inputLengthsInit: RangedFromWithStep(4, 0),31 inputLengthsShape: tensor.Shape{4},32 targetLengthsInit: RangedFromWithStep(2, 0),33 targetLengthsShape: tensor.Shape{4},34 expectedOutput: tensor.New(35 tensor.WithShape(),36 tensor.WithBacking([]float64{-1.428742987863855}),37 ),38 expectedInputGrad: tensor.New(39 tensor.WithShape(4, 4, 4),40 tensor.WithBacking([]float64{0.8016031528676627, 1.010050167084168, 0.21859818715909318, 1.030454533953517, 0.842413927060051, 1.0512710963760241, 0.2602333936776974, 1.0725081812542165, 0.8848902205426215, 1.0941742837052104, 0.30356776520798545, 1.1162780704588713, 0.9291000044470383, 1.1388283833246218, 0.3486706459895643, 1.161834242728283, 0.5743124474256416, 1.1853048513203654, 0.7964157866879789, 1.2092495976572515, 0.6222043345940014, 1.2336780599567434, 0.8452751541535497, 1.258600009929478, 0.6720507267552366, 1.2840254166877416, 0.8961285102319406, 1.3099644507332475, 0.7239313887712684, 1.3364274880254723, 0.9490572311421717, 1.3634251141321778, 0.7779293407697887, 1.3909681284637805, 1.0041460141297627, 1.4190675485932576, 0.8341309909941721, 1.4477346146633248, 1.0614830130003936, 1.476980793882643, 0.8926262740751023, 1.506817785112854, 1.121159979184803, 1.5372575235482817, 0.9535087949451677, 1.5683121854901692, 1.1832724085606505, 1.5999941932173607, 1.4176775550605565, 1.6323162199553793, 0.8471181178324659, 1.6652911949458866, 1.4836308025665494, 1.698932308618551, 0.9144037093171966, 1.7332530178673957, 1.5522756531637645, 1.7682670514337357, 0.9844352778824115, 1.8039884153978574, 1.6237219532581721, 1.840431398781638, 1.0573248889786804, 1.8776105792643438}),41 ),42 },43 {44 Dtype: Float32,45 reduction: ReductionSum,46 logProbsInit: RangedFromWithStep(0.0, 0.01),47 logProbsShape: tensor.Shape{4, 4, 4},48 targetsInit: RangedFromWithStep(2, 0),49 targetsShape: tensor.Shape{4, 4},50 inputLengthsInit: RangedFromWithStep(4, 0),51 inputLengthsShape: tensor.Shape{4},52 targetLengthsInit: RangedFromWithStep(2, 0),53 targetLengthsShape: tensor.Shape{4},54 expectedOutput: tensor.New(55 tensor.WithShape(),56 tensor.WithBacking([]float32{-11.429942}),57 ),58 expectedInputGrad: tensor.New(59 tensor.WithShape(4, 4, 4),60 tensor.WithBacking([]float32{0.8016031, 1.0100502, 0.21859795, 1.0304545, 0.8424139, 1.0512711, 0.26023316, 1.0725082, 0.88489014, 1.0941743, 0.303568, 1.116278, 0.9291, 1.1388284, 0.3486709, 1.1618342, 0.57431227, 1.1853049, 0.79641575, 1.2092496, 0.6222042, 1.2336781, 0.84527516, 1.2586, 0.6720507, 1.2840254, 0.8961285, 1.3099644, 0.7239313, 1.3364275, 0.94905716, 1.363425, 0.7779292, 1.3909681, 1.0041459, 1.4190674, 0.83413076, 1.4477345, 1.0614828, 1.4769807, 0.89262605, 1.5068176, 1.1211598, 1.5372573, 0.9535085, 1.5683119, 1.1832721, 1.599994, 1.4176772, 1.6323159, 0.8471178, 1.6652908, 1.4836304, 1.6989319, 0.9144034, 1.7332526, 1.5522753, 1.7682667, 0.98443496, 1.803988, 1.6237215, 1.8404309, 1.0573245, 1.87761}),61 ),62 },63 {64 Dtype: Float64,65 reduction: ReductionSum,66 logProbsInit: RangedFromWithStep(0.0, 0.01),67 logProbsShape: tensor.Shape{4, 3, 5},68 targetsInit: RangedFromWithStep(2, 0),69 targetsShape: tensor.Shape{3, 4},70 inputLengthsInit: RangedFromWithStep(4, 0),71 inputLengthsShape: tensor.Shape{3},72 targetLengthsInit: RangedFromWithStep(2, 0),73 targetLengthsShape: tensor.Shape{3},74 expectedOutput: tensor.New(75 tensor.WithShape(),76 tensor.WithBacking([]float64{-8.27245792718313}),77 ),78 expectedInputGrad: tensor.New(79 tensor.WithShape(4, 3, 5),80 tensor.WithBacking([]float64{0.8016031528676626, 1.010050167084168, 0.21859818715909318, 1.030454533953517, 1.0408107741923882, 0.8528742492436868, 1.0618365465453596, 0.27090502838655417, 1.0832870676749586, 1.0941742837052104, 0.9067740709433104, 1.1162780704588713, 0.32589369871171314, 1.1388283833246218, 1.1502737988572274, 0.5626358191621145, 1.1735108709918103, 0.784503274886534, 1.1972173631218102, 1.2092495976572515, 0.6222043345940012, 1.2336780599567434, 0.8452751541535495, 1.258600009929478, 1.2712491503214047, 0.684826993121573, 1.2969300866657718, 0.9091628742994162, 1.323129812337437, 1.3364274880254723, 0.7506603840098345, 1.3634251141321778, 0.9763261879021259, 1.3909681284637805, 1.404947590563594, 0.8198691250270892, 1.4333294145603404, 1.0469330382294935, 1.462284589434225, 1.476980793882643, 0.8926262740751021, 1.506817785112854, 1.1211599791848028, 1.5372575235482817, 1.5527072185113364, 1.3699153383578317, 1.584073984994482, 0.7983910403496982, 1.6160744021928939, 1.6323162199553793, 1.4503244235677912, 1.6652911949458866, 0.8804244968312241, 1.698932308618551, 1.716006862184859, 1.5348561707350583, 1.7506725002961017, 0.9666638985660732, 1.7860384307500738, 1.8039884153978574}),81 ),82 },83 }84 for i, tC := range testCases {85 t.Run(fmt.Sprintf("Example #%v %v (%v)", i+1, tC.Dtype, tC.logProbsShape), func(t *testing.T) {86 ac := require.New(t)87 g := NewGraph()88 logProbs := NewTensor(g, tC.Dtype, tC.logProbsShape.Dims(), WithShape(tC.logProbsShape...), WithInit(tC.logProbsInit), WithName("logProbs"))89 targets := NewTensor(g, tensor.Int, tC.targetsShape.Dims(), WithShape(tC.targetsShape...), WithInit(tC.targetsInit), WithName("targets"))90 inputLengths := NewTensor(g, tensor.Int, tC.inputLengthsShape.Dims(), WithShape(tC.inputLengthsShape...), WithInit(tC.inputLengthsInit), WithName("inputLengths"))91 targetLengths := NewTensor(g, tensor.Int, tC.targetLengthsShape.Dims(), WithShape(tC.targetLengthsShape...), WithInit(tC.targetLengthsInit), WithName("targetLengths"))92 val, err := CTCLoss(logProbs, targets, inputLengths, targetLengths, tC.reduction)93 ac.NoError(err)94 _, err = Grad(val, logProbs)95 ac.NoError(err)96 vm := NewTapeMachine(g)97 ac.NoError(vm.RunAll())98 ac.Equal(tC.expectedOutput.Shape(), val.Shape())99 ac.InDelta(tC.expectedOutput.Data(), val.Value().Data(), 1e-5, "actual: %#v", val.Value().Data())100 t.Logf("dx: %#v", logProbs.Deriv().Value().Data())101 ac.Equal(tC.expectedInputGrad.Shape(), logProbs.Deriv().Shape())102 ac.InDeltaSlice(tC.expectedInputGrad.Data(), logProbs.Deriv().Value().Data(), 1e-5, "actual: %#v", logProbs.Deriv().Value().Data())103 })104 }105}106func BenchmarkCTCLossForward(b *testing.B) {107 testCases := []struct {108 Dtype tensor.Dtype109 reduction Reduction110 logProbsInit InitWFn111 logProbsShape tensor.Shape112 targetsInit InitWFn113 targetsShape tensor.Shape114 inputLengthsInit InitWFn115 inputLengthsShape tensor.Shape116 targetLengthsInit InitWFn117 targetLengthsShape tensor.Shape118 }{119 {120 Dtype: Float64,121 reduction: ReductionMean,122 logProbsInit: RangedFromWithStep(0.0, 0.01),123 logProbsShape: tensor.Shape{4, 4, 4},124 targetsInit: RangedFromWithStep(2, 0),125 targetsShape: tensor.Shape{4, 4},126 inputLengthsInit: RangedFromWithStep(4, 0),127 inputLengthsShape: tensor.Shape{4},128 targetLengthsInit: RangedFromWithStep(2, 0),129 targetLengthsShape: tensor.Shape{4},130 },131 {132 Dtype: Float64,133 reduction: ReductionMean,134 logProbsInit: RangedFromWithStep(0.0, 0.01),135 logProbsShape: tensor.Shape{4, 1024, 4},136 targetsInit: RangedFromWithStep(2, 0),137 targetsShape: tensor.Shape{1024, 4},138 inputLengthsInit: RangedFromWithStep(4, 0),139 inputLengthsShape: tensor.Shape{1024},140 targetLengthsInit: RangedFromWithStep(2, 0),141 targetLengthsShape: tensor.Shape{1024},142 },143 {144 Dtype: Float64,145 reduction: ReductionMean,146 logProbsInit: RangedFromWithStep(0.0, 0.01),147 logProbsShape: tensor.Shape{4, 1024, 1024},148 targetsInit: RangedFromWithStep(2, 0),149 targetsShape: tensor.Shape{1024, 4},150 inputLengthsInit: RangedFromWithStep(4, 0),151 inputLengthsShape: tensor.Shape{1024},152 targetLengthsInit: RangedFromWithStep(2, 0),153 targetLengthsShape: tensor.Shape{1024},154 },155 {156 Dtype: Float64,157 reduction: ReductionMean,158 logProbsInit: RangedFromWithStep(0.0, 0.01),159 logProbsShape: tensor.Shape{4, 2048, 8},160 targetsInit: RangedFromWithStep(2, 0),161 targetsShape: tensor.Shape{2048, 4},162 inputLengthsInit: RangedFromWithStep(4, 0),163 inputLengthsShape: tensor.Shape{2048},164 targetLengthsInit: RangedFromWithStep(2, 0),165 targetLengthsShape: tensor.Shape{2048},166 },167 }168 for i, tC := range testCases {169 op := newCTCLossOp(tC.Dtype, tC.targetsShape.Dims(), ReductionSum)170 logsProbs := tensor.New(171 tensor.WithShape(tC.logProbsShape...),172 tensor.WithBacking(tC.logProbsInit(op.dtype, tC.logProbsShape...)),173 )174 targets := tensor.New(175 tensor.WithShape(tC.targetsShape...),176 tensor.WithBacking(tC.targetsInit(Int, tC.targetsShape...)),177 )178 inputLengths := tensor.New(179 tensor.WithShape(tC.inputLengthsShape...),180 tensor.WithBacking(tC.inputLengthsInit(Int, tC.inputLengthsShape...)),181 )182 targetLengths := tensor.New(183 tensor.WithShape(tC.targetLengthsShape...),184 tensor.WithBacking(tC.targetLengthsInit(Int, tC.targetLengthsShape...)),185 )186 b.Run(fmt.Sprintf("Benchmark #%v %v (%v)", i+1, tC.Dtype, tC.logProbsShape), func(b *testing.B) {187 for i := 0; i < b.N; i++ {188 _, err := op.Do(logsProbs, targets, inputLengths, targetLengths)189 b.StopTimer()190 if err != nil {191 panic(err)192 }193 b.StartTimer()194 }195 })196 }197}...

Full Screen

Full Screen

targets.go

Source:targets.go Github

copy

Full Screen

...81 updated = append(updated, t)82 systemTargets = updated83 return nil84}85func initSystemTargets(cfgMap map[string]http.Config) (tgts []Target, err error) {86 for _, l := range cfgMap {87 if l.Enabled {88 t := http.New(l)89 if err = t.Init(); err != nil {90 return tgts, err91 }92 tgts = append(tgts, t)93 }94 }95 return tgts, err96}97func initKafkaTargets(cfgMap map[string]kafka.Config) (tgts []Target, err error) {98 for _, l := range cfgMap {99 if l.Enabled {100 t := kafka.New(l)101 if err = t.Init(); err != nil {102 return tgts, err103 }104 tgts = append(tgts, t)105 }106 }107 return tgts, err108}109// Split targets into two groups:110// group1 contains all targets of type t111// group2 contains the remaining targets112func splitTargets(targets []Target, t types.TargetType) (group1 []Target, group2 []Target) {113 for _, target := range targets {114 if target.Type() == t {115 group1 = append(group1, target)116 } else {117 group2 = append(group2, target)118 }119 }120 return121}122func cancelTargets(targets []Target) {123 for _, target := range targets {124 target.Cancel()125 }126}127// UpdateSystemTargets swaps targets with newly loaded ones from the cfg128func UpdateSystemTargets(cfg Config) error {129 newTgts, err := initSystemTargets(cfg.HTTP)130 if err != nil {131 return err132 }133 swapSystemMuRW.Lock()134 consoleTargets, otherTargets := splitTargets(systemTargets, types.TargetConsole)135 newTgts = append(newTgts, consoleTargets...)136 systemTargets = newTgts137 swapSystemMuRW.Unlock()138 cancelTargets(otherTargets) // cancel running targets139 return nil140}141// UpdateAuditWebhookTargets swaps audit webhook targets with newly loaded ones from the cfg142func UpdateAuditWebhookTargets(cfg Config) error {143 newWebhookTgts, err := initSystemTargets(cfg.AuditWebhook)144 if err != nil {145 return err146 }147 swapAuditMuRW.Lock()148 // Retain kafka targets149 oldWebhookTgts, otherTgts := splitTargets(auditTargets, types.TargetHTTP)150 newWebhookTgts = append(newWebhookTgts, otherTgts...)151 auditTargets = newWebhookTgts152 swapAuditMuRW.Unlock()153 cancelTargets(oldWebhookTgts) // cancel running targets154 return nil155}156// UpdateAuditKafkaTargets swaps audit kafka targets with newly loaded ones from the cfg157func UpdateAuditKafkaTargets(cfg Config) error {158 newKafkaTgts, err := initKafkaTargets(cfg.AuditKafka)159 if err != nil {160 return err161 }162 swapAuditMuRW.Lock()163 // Retain webhook targets164 oldKafkaTgts, otherTgts := splitTargets(auditTargets, types.TargetKafka)165 newKafkaTgts = append(newKafkaTgts, otherTgts...)166 auditTargets = newKafkaTgts167 swapAuditMuRW.Unlock()168 cancelTargets(oldKafkaTgts) // cancel running targets169 return nil170}...

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1targets := new(targets)2targets.init()3targets := new(targets)4targets.init()5targets := new(targets)6targets.init()7targets := new(targets)8targets.init()9targets := new(targets)10targets.init()11targets := new(targets)12targets.init()13targets := new(targets)14targets.init()15targets := new(targets)16targets.init()17targets := new(targets)18targets.init()19targets := new(targets)20targets.init()21targets := new(targets)22targets.init()23targets := new(targets)24targets.init()25targets := new(targets)26targets.init()27targets := new(targets)28targets.init()29targets := new(targets)30targets.init()31targets := new(targets)32targets.init()33targets := new(targets)34targets.init()35targets := new(targets)36targets.init()37targets := new(targets)38targets.init()39targets := new(targets)40targets.init()

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1func main() {2 targets.Init()3 fmt.Println("2.go main")4}5func main() {6 targets.Init()7 fmt.Println("3.go main")8}9func main() {10 targets.Init()11 fmt.Println("4.go main")12}13func main() {14 targets.Init()15 fmt.Println("5.go main")16}17func main() {18 targets.Init()19 fmt.Println("6.go main")20}21func main() {22 targets.Init()23 fmt.Println("7.go main")24}25func main() {26 targets.Init()27 fmt.Println("8.go main")28}29func main() {30 targets.Init()31 fmt.Println("9.go main")32}33func main() {34 targets.Init()35 fmt.Println("10.go main")36}37func main() {38 targets.Init()39 fmt.Println("11.go main")40}41func main() {42 targets.Init()43 fmt.Println("12.go main")44}45func main() {46 targets.Init()47 fmt.Println("13.go main")48}49func main() {50 targets.Init()51 fmt.Println("14.go main")52}53func main() {54 targets.Init()55 fmt.Println("15.go main")56}57func main() {58 targets.Init()59 fmt.Println("16.go main")60}

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1func main() {2 targets.Init()3 fmt.Println(targets.Hello)4}5func main() {6 targets.Init()7 fmt.Println(targets.Hello)8}9func main() {10 targets.Init()11 fmt.Println(targets.Hello)12}13func main() {14 targets.Init()15 fmt.Println(targets.Hello)16}17func main() {18 targets.Init()19 fmt.Println(targets.Hello)20}21func main() {22 targets.Init()23 fmt.Println(targets.Hello)24}25func main() {26 targets.Init()27 fmt.Println(targets.Hello)28}29func main() {30 targets.Init()31 fmt.Println(targets.Hello)32}33func main() {34 targets.Init()35 fmt.Println(targets.Hello)36}37func main() {38 targets.Init()39 fmt.Println(targets.Hello)40}41func main() {42 targets.Init()43 fmt.Println(targets.Hello)44}45func main() {46 targets.Init()47 fmt.Println(targets.Hello)48}49func main() {50 targets.Init()51 fmt.Println(targets.Hello)52}53func main() {54 targets.Init()55 fmt.Println(targets.Hello)56}57func main() {58 targets.Init()59 fmt.Println(targets.Hello)60}61func main()

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(targets.GetTargets())4}5import (6type Target struct {7}8func init() {9 targets = make([]Target, 0)10 fmt.Println("Loading targets")11 targets = append(targets, Target{"Target1", "Type1"})12 targets = append(targets, Target{"Target2", "Type2"})13}14func GetTargets() []Target {15}

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 targets.Print()4}5import (6type Target struct {7}8var targets = []Target{9 {"A"},10 {"B"},11 {"C"},12}13func init() {14 fmt.Println("init")15}16func Print() {17 for _, t := range targets {18 fmt.Println(t.Name)19 }20}21import (22func main() {23 fmt.Println(a, b, c, d)24 f := func() {25 fmt.Println(a, b, c, d)26 }27 f()28 f()29}

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("Hello, World!")4 targets.init()5}6type targets struct {7}8func (t targets) init() {9 fmt.Println(t.name)10}

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 targets.Init()4 fmt.Println("Hello World!")5 z01.PrintRune('!6}7import (8func Init() {9 fmt.Println("Hello World!")10 z01.PrintRune('!11}12import "testing"13func TestInit(t *testing.T) {14 Init()15}16import (17func main() {18 targets.Init()19 fmt.Println("Hello World!")20 z01.PrintRune('!21}22import (23func Init() {24 fmt.Println("Hello World!")25 z01.PrintRune('!26}27import "testing"28func TestInit(t *testing.T) {29 Init()30}31import (32func main() {33 targets.Init()34 fmt.Println("Hello World!")35 z01.PrintRune('!36}37import (38func Init() {39 fmt.Println("Hello World!")40 z01.PrintRune('!41}42import "testing"43func TestInit(t *testing.T) {44 Init()45}46import (47func main() {48 targets.Init()49 fmt.Println("Hello World!")50 z01.PrintRune('!51}52import (53func Init() {54 fmt.Println("Hello

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("init method of targets class is called")4 targets.Init()5}6import (7func main() {8 fmt.Println(targets.Name)9 fmt.Println(targets.Age)10}

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4}5import (6func main() {7 fmt.Println("Hello, playground")8}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Syzkaller automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful