@@ -269,13 +269,237 @@ record reluOp : serializable {
269269
270270 proc children do return (input,);
271271
272- proc forward () {
272+ proc forward () do
273273 return input.array.relu();
274+ }
275+
276+ record siluOp : serializable {
277+ var input: shared BaseTensorResource(?);
278+
279+ proc children do return (input,);
280+
281+ proc forward () do
282+ return input.array.silu();
283+ }
284+
285+ record mishOp : serializable {
286+ var input: shared BaseTensorResource(?);
287+
288+ proc children do return (input,);
289+
290+ proc forward () do
291+ return input.array.mish();
292+ }
293+
294+ record sigmoidOp : serializable {
295+ var input: shared BaseTensorResource(?);
296+
297+ proc children do return (input,);
298+
299+ proc forward () do
300+ return input.array.sigmoid();
301+ }
302+
303+ record tanhOp : serializable {
304+ var input: shared BaseTensorResource(?);
305+
306+ proc children do return (input,);
307+
308+ proc forward () do
309+ return input.array.tanh();
310+ }
311+
312+ record relu6Op : serializable {
313+ var input: shared BaseTensorResource(?);
314+
315+ proc children do return (input,);
316+
317+ proc forward () do
318+ return input.array.relu6();
319+ }
320+
321+ record seluOp : serializable {
322+ var input: shared BaseTensorResource(?);
323+
324+ proc children do return (input,);
325+
326+ proc forward () do
327+ return input.array.selu();
328+ }
329+
330+ record logsigmoidOp : serializable {
331+ var input: shared BaseTensorResource(?);
332+
333+ proc children do return (input,);
334+
335+ proc forward () do
336+ return input.array.logsigmoid();
337+ }
338+
339+ record tanhshrinkOp : serializable {
340+ var input: shared BaseTensorResource(?);
341+
342+ proc children do return (input,);
343+
344+ proc forward () do
345+ return input.array.tanhshrink();
346+ }
347+
348+ record softsignOp : serializable {
349+ var input: shared BaseTensorResource(?);
350+
351+ proc children do return (input,);
352+
353+ proc forward () do
354+ return input.array.softsign();
355+ }
356+
357+ record rreluOp : serializable {
358+ var input: shared BaseTensorResource(?);
359+ var lower: eltType = 0.125 ;
360+ var upper: eltType = 1.0 / 3.0 ;
361+
362+ proc init (low: eltType, up: eltType) {
363+ lower = low;
364+ upper = up;
274365 }
275- inline proc _relu(x) do
276- return ((0.0 < x): input.eltType) * x;
277366
278- proc spec : GradOpSpec do return new dict ((" operation" ," ReLU" ));
367+ proc children do return (input,);
368+
369+ proc forward () do
370+ return input.array.rrelu(lower, upper);
371+ }
372+
373+ record hardswishOp : serializable {
374+ var input: shared BaseTensorResource(?);
375+
376+ proc children do return (input,);
377+
378+ proc forward () do
379+ return input.array.hardswish();
380+ }
381+
382+ record hardsigmoidOp : serializable {
383+ var input: shared BaseTensorResource(?);
384+
385+ proc children do return (input,);
386+
387+ proc forward () do
388+ return input.array.hardsigmoid();
389+ }
390+
391+ record hardshrinkOp : serializable {
392+ var input: shared BaseTensorResource(?);
393+
394+ proc children do return (input,);
395+
396+ proc forward () do
397+ return input.array.hardshrink();
398+ }
399+
400+ record thresholdOp : serializable {
401+ var input: shared BaseTensorResource(?);
402+ var threshold: eltType; // PyTorch has no defaults for threshold
403+ var value: eltType;
404+
405+ proc init (t: eltType, v: eltType) {
406+ threshold = t;
407+ value = v;
408+ }
409+
410+ proc children do return (input,);
411+
412+ proc forward () do
413+ return input.array.threshold(threshold, value);
414+ }
415+
416+ record hardtanhOp : serializable {
417+ var input: shared BaseTensorResource(?);
418+ var min_val: eltType = - 1.0 ;
419+ var max_val: eltType = 1.0 ;
420+
421+ proc init (min_v: eltType, max_v: eltType) {
422+ min_val = min_v;
423+ max_val = max_v;
424+ }
425+
426+ proc children do return (input,);
427+
428+ proc forward () do
429+ return input.array.threshold(min_val, max_val);
430+ }
431+
432+ record eluOp : serializable {
433+ var input: shared BaseTensorResource(?);
434+ var alpha: eltType = 1.0 ;
435+
436+ proc init (a: eltType) {
437+ alpha = a;
438+ }
439+
440+ proc children do return (input,);
441+
442+ proc forward () do
443+ return input.array.elu(alpha);
444+ }
445+
446+ record softplusOp : serializable {
447+ var input: shared BaseTensorResource(?);
448+ var beta: eltType = 1.0 ;
449+ var threshold: eltType = 20.0 ;
450+
451+ proc init (b: eltType, t: eltType) {
452+ beta = b;
453+ threshold = t;
454+ }
455+
456+ proc children do return (input,);
457+
458+ proc forward () do
459+ return input.array.softplus(beta, threshold);
460+ }
461+
462+ record celuOp : serializable {
463+ var input: shared BaseTensorResource(?);
464+ var alpha: eltType = 1.0 ;
465+
466+ proc init (a: eltType) {
467+ alpha = a;
468+ }
469+
470+ proc children do return (input,);
471+
472+ proc forward () do
473+ return input.array.celu(alpha);
474+ }
475+
476+ record leakyreluOp : serializable {
477+ var input: shared BaseTensorResource(?);
478+ var negative_slope: eltType = exp(- 2.0 );
479+
480+ proc init (ns: eltType) {
481+ negative_slope = ns;
482+ }
483+
484+ proc children do return (input,);
485+
486+ proc forward () do
487+ return input.array.leakyrelu(negative_slope);
488+ }
489+
490+ record softshrinkOp : serializable {
491+ var input: shared BaseTensorResource(?);
492+ var l: eltType = 0.5 ;
493+
494+ proc init (L: eltType = 0.5 ) {
495+ l = L;
496+ if l < 0 then util.err(" argument to softshrink function must be non-negative" );
497+ }
498+
499+ proc children do return (input,);
500+
501+ proc forward () do
502+ return input.array.softshrink(l);
279503}
280504
281505record squareOp : serializable {
0 commit comments