text
stringlengths 0
601k
|
---|
let assert_parse_map ( ? eof = true ) p str fn = match parse_string ~ eof p str with | Failed _ -> assert_failure " parse failure " | Success x -> assert_bool " map " ( fn x ) |
let parse_tests name parse l = name >::: ( List . map ( function | ` Ok ( str ) -> ( " OK : " ^ name ^ " ' " ^ str ^ " ' " ) >:: ( fun ( ) -> assert_parse parse str ) | ` Fail ( str ) -> ( " FAIL : " ^ name ^ " ' " ^ str ^ " ' " ) >:: ( fun ( ) -> assert_parse_fail parse str ) | ` Eq ( str , eq ) -> ( " EQ : " ^ name ^ " ' " ^ str ^ " ' " ) >:: ( fun ( ) -> assert_parse_eq parse str eq ) | ` Map ( str , fn ) -> ( " MAP : " ^ name ^ " ' " ^ str ^ " ' " ) >:: ( fun ( ) -> assert_parse_map parse str fn ) ) l ) |
let test_typescript = let open Parser in let open Ast in let open TypeScript in " Tests " >::: [ " Token " >::: [ parse_tests " whitespace_and_comments " Token . whitespace [ ` Ok " " ; ` Ok " " ; ` Ok " \ t " ; ` Ok " \ n " ; ` Ok " \ t \ r \ n " ; ` Ok " /* aaa \ nbbbb " ; */ ` Ok " // aaa " ; ] ; parse_tests " string " ( Token . string " hello " ) [ ` Ok " hello " ; ` Fail " goodbye " ; ` Eq ( " hello " , " hello " ) ; ] ; " char " >::: [ " simple " >:: ( fun ctx -> assert_parse_eq ( Token . char ' a ' ) " a " ' a ' ) ; " punct " >:: ( fun ctx -> assert_parse_eq ( Token . char ' ' ) : " " : ' ' ) ; : " space " >:: ( fun ctx -> assert_parse_eq ( Token . char ' a ' ) " a " ' a ' ) ; " fail multiple " >:: ( fun ctx -> assert_parse_fail ( Token . char ' a ' ) " ab " ) ; ] ; ] ; " Typescript basic " >::: [ parse_tests " identifier " identifier [ ` Ok " abc " ; ` Ok " De " ; ` Ok " _fg " ; ` Ok " Xyz \ n /* . . . */ // . . . " ; ` Ok " 1hikj " ; ` Ok " " ; $ ` Ok " " ; $$ ` Ok " $ _ " ; ` Ok " _ " ; ` Ok " __ " ; ] ; parse_tests " path " path [ ` Ok " abc " ; ` Ok " I . am . a . module . name " ; ` Eq ( " a . b . c " , [ " a " ; " b " ; " c " ] ) ; ` Fail " " ; ` Fail " a . b . c " ; ] ; parse_tests " stringLiteral " stringLiteral [ ` Fail " " ; ` Eq ( " " " " , \\ " " ) ; ` Eq ( " " \ str lit " " , \ " str lit " ) ; ` Eq ( " ' ' " , \\ " " ) ; ` Eq ( " ' str lit ' " , " str lit " ) ; ] ; ] ; " Typescript types " >::: [ parse_tests " predefinedType " predefinedType [ ` Ok " number " ; ` Ok " any " ; ` Ok " boolean " ; ` Ok " string " ; ` Ok " void " ; ` Fail " other " ; ] ; parse_tests " typeQuery " typeQuery [ ` Ok " typeof mytype " ; ` Eq ( " typeof a . b . c " , [ " a " ; " b " ; " c " ] ) ; ] ; parse_tests " typeReference " typeReference [ ` Fail " " ; ` Ok " a " ; ` Ok " a < b " ; > ` Ok " a < b , c " ; > ` Ok " a < b , c > " ; ] ; parse_tests " typeParameter " typeParameter [ ` Ok " b extends c " ; ` Ok " b extends c . d " ; ] ; parse_tests " elementType " elementType [ ` Map ( " any " , function ` PredefinedType _ -> true | _ -> false ) ; ` Map ( " number " , function ` PredefinedType _ -> true | _ -> false ) ; ` Map ( " a " , function ` TypeReference _ -> true | _ -> false ) ; ` Map ( " typeof a " , function ` TypeQuery _ -> true | _ -> false ) ; ` Map ( " { } " , function ` ObjectType _ -> true | _ -> false ) ; ] ; parse_tests " typeLiteral " typeLiteral [ ` Map ( " a [ ] [ ] " , function ` ArrayType _ -> true | _ -> false ) ; ` Map ( " { } " , function ` ObjectType _ -> true | _ -> false ) ; ` Map ( " ( ) => a " , function ` FunctionType _ -> true | _ -> false ) ; ` Map ( " < a ( > b : c , d : e ) => f " , function ` FunctionType _ -> true | _ -> false ) ; ` Map ( " new ( ) => a " , function ` ConstructorType _ -> true | _ -> false ) ; ` Map ( " new < a ( > b , c : d ) => e < f " , > function ` ConstructorType _ -> true | _ -> false ) ; ] ; parse_tests " type " type_ [ ` Map ( " a [ ] [ ] " , function ` TypeLiteral _ -> true | _ -> false ) ; ` Map ( " { } " , function ` TypeLiteral _ -> true | _ -> false ) ; ` Map ( " ( ) => a " , function ` TypeLiteral _ -> true | _ -> false ) ; ` Map ( " < a ( > b : c , d : e ) => f " , function ` TypeLiteral _ -> true | _ -> false ) ; ` Map ( " new ( ) => a " , function ` TypeLiteral _ -> true | _ -> false ) ; ` Map ( " new < a ( > b , c : d ) => e < f " , > function ` TypeLiteral _ -> true | _ -> false ) ; ` Map ( " a " , function ` TypeReference _ -> true | _ -> false ) ; ` Map ( " a < b " , > function ` TypeReference _ -> true | _ -> false ) ; ` Map ( " a < b , c " , > function ` TypeReference _ -> true | _ -> false ) ; ` Map ( " a < b , c > " , function ` TypeReference _ -> true | _ -> false ) ; ` Map ( " any " , function ` PredefinedType _ -> true | _ -> false ) ; ` Map ( " string " , function ` PredefinedType _ -> true | _ -> false ) ; ` Map ( " typeof t " , function ` TypeQuery _ -> true | _ -> false ) ; ` Ok " any [ ] " ; ` Ok " string [ ] " ; ` Ok " number [ ] " ; ` Ok " boolean [ ] " ; ] ; parse_tests " object " objectType [ ` Fail " " ; ` Ok " { a } " ; ` Ok " { a ; } " ; ` Ok " { a ; b } " ; ` Ok " { a ; b ; } " ; ] ; parse_tests " parameter " parameter [ ` Fail " " ; ` Map ( " a " , function ` RequiredParameter _ -> true | _ -> false ) ; ` Ok " public a " ; ` Ok " private a " ; ` Map ( " a " , ? function ` OptionalParameter _ -> true | _ -> false ) ; ` Ok " private a " ; ? ` Ok " public a " ; ? ` Ok " a : b " ; ` Ok " a ?: b " ; ` Ok " a ?: b < c " ; > ` Map ( " a " :\ b " " , \ function ` RequiredParameterSpecialized _ -> true | _ -> false ) ; ` Ok " a " ?:\ b " " ; \ ` Map ( " . . . sommat " , function ` RestParameter _ -> true | _ -> false ) ; ] ; parse_tests " indexSignature " indexSignature [ ` Ok " [ name : string ] : type " ; ` Ok " [ name : number ] : type " ; ` Fail " [ name : any ] : type " ; ` Fail " [ name : number ] " ; ] ; parse_tests " constructSignature " constructSignature [ ` Ok " new ( ) " ; ` Ok " new < a > ( ) " ; ` Ok " new < Isla , Skye > ( isla ) " ; ` Ok " new ( isla : Island , harris ? : Rocky < Island > ) " ; ` Ok " new ( container : HTMLElement , theme ?: string ) : VirtualRenderer " ; ] ; parse_tests " callSignature " callSignature [ ` Fail " " ; ` Ok " ( ) " ; ` Ok " ( a , b , c ) " ; ` Ok " ( a , b : b < b , > c ) : d < e " ; > ` Ok " < x , y ( > a , b : b < b , > c ) : d < e " ; > ` Eq ( " ( ) " , { csg_typeParameters = None ; csg_parameterList [ ] ; = csg_typeAnnotation = None } ) ; ] ; parse_tests " properySignature " propertySignature [ ` Fail " " ; ` Ok " a " ; ` Ok " a : b " ; ` Ok " a : b < c " ; > ` Ok " a : b < c [ ] " ; > ` Ok " a : b < c , d < e [ ] [ ] [ ] " ; >> ] ; parse_tests " methodSignature " methodSignature [ ` Fail " " ; ` Ok " fn ( ) " ; ` Ok " a ( ? b ) " ; ` Ok " a ( b ) : c < d " ; > ` Ok " a ( b ) : c < d [ ] " ; > ] ; parse_tests " typeMember " typeMember [ ` Map ( " new ( ) " , function ` ConstructSignature _ -> true | _ -> false ) ; ` Map ( " a ( ) " , function ` MethodSignature _ -> true | _ -> false ) ; ` Map ( " ( ) " , function ` CallSignature _ -> true | _ -> false ) ; ` Map ( " [ a : string ] : b " , function ` IndexSignature _ -> true | _ -> false ) ; ` Map ( " a " , function ` PropertySignature _ -> true | _ -> false ) ; ] ; parse_tests " exportAssignment " exportAssignment [ ` Ok ( " export = hello ; " ) ; ] ; parse_tests " interfaceExtendsClause " interfaceExtendsClause [ ` Ok " extends a < b , > c " ; ` Fail " extends a [ ] " ; ` Fail " extends " ; ] ; parse_tests " interfaceDeclaration " interfaceDeclaration [ ` Ok " interface a { } " ; ` Ok " interface a < b > extends c , d { } " ; ` Ok " interface a { b ; c : d < e } " ; > ` Ok " interface a { b : Array < any ; > } " ; ` Ok " interface a { b : any [ ] ; } " ; ] ; parse_tests " importDeclaration " importDeclaration [ ` Ok " import a = b " ; ` Ok " import a = b . c " ; ` Fail " import a . c = c " ; ] ; parse_tests " externalImportDeclaration " externalImportDeclaration [ ` Ok " import a = require ( " \ b " \ ) ; " ; ` Ok " export import a = require ( " \ b " \ ) ; " ; ] ; parse_tests " ambientVariableDeclaration " ambientVariableDeclaration [ ` Ok " var a ; " ; ` Ok " var a : b ; " ; ` Ok " var a : b [ ] ; " ; ` Ok " var a : b < c < d [ ] ; " ; >> ] ; parse_tests " ambientEnumDeclaration " ambientEnumDeclaration [ ` Ok " enum a { b , c } " ; ` Ok " enum a { b = 0 , c = 10 } " ; ] ; parse_tests " ambientFunctionDeclaration " ambientFunctionDeclaration [ ` Ok " function a ( ) " ; ` Ok " function a ( a , b , c : d < e ) " ; > ] ; parse_tests " ambientClassDeclaration " ambientClassDeclaration [ ` Ok " class a { } " ; ` Ok " class a < b > { } " ; ` Ok " class a < b > extends c implements d , e { } " ; ` Ok " class a { constructor ( a : b , c ) ; } " ; ` Ok " class a { b : c < d ; > } " ; ` Ok " class a { b ( ) ; } " ; ` Ok " class a { b ( ) } " ; ` Ok " class a { b ( c , d : e ) ; } " ; ` Ok " class a { b } " ; ` Ok " class a { b ; } " ; ` Ok " class a { a b } " ; ` Ok " class a { a b ; } " ; ] ; parse_tests " ambientModuleElement " ambientModuleElement [ ` Map ( " var a : b ; " , function ` AmbientVariableDeclaration _ -> true | _ -> false ) ; ` Map ( " interface a { } " , function ` InterfaceDeclaration _ -> true | _ -> false ) ; ` Map ( " module a { } " , function ` AmbientModuleDeclaration _ -> true | _ -> false ) ; ` Map ( " import a = b . c " , function ` ImportDeclaration _ -> true | _ -> false ) ; ` Map ( " export function a ( ) " , function ` AmbientFunctionDeclaration _ -> true | _ -> false ) ; ` Map ( " enum a { b , c } " , function ` AmbientEnumDeclaration _ -> true | _ -> false ) ; ] ; parse_tests " ambientModuleDeclaration " ambientModuleDeclaration [ ` Ok " module a { var a ; var b ; } " ; ` Ok " module a { var a ; var b } " ; ] ; parse_tests " ambientExternalModuleElement " ambientExternalModuleElement [ ` Map ( " module a { } " , function ` AmbientModuleElement _ -> true | _ -> false ) ; ` Map ( " export = hello ; " , function ` ExportAssignment _ -> true | _ -> false ) ; ` Map ( " import a = require ( " \ b " \ ) ; " , function ` ExternalImportDeclaration _ -> true | _ -> false ) ; ` Map ( " export import a = require ( " \ b " \ ) ; " , function ` ExternalImportDeclaration _ -> true | _ -> false ) ; ] ; parse_tests " ambientExternalModuleDeclaration " ambientExternalModuleDeclaration [ ` Ok " module " \ x " \ { } " ; ` Ok " module " \ x " \ { var a ; } " ; ] ; parse_tests " ambientDeclaration " ambientDeclaration [ ` Map ( " var a ; " , function ` AmbientVariableDeclaration _ -> true | _ -> false ) ; ` Map ( " module a { } " , function ` AmbientModuleDeclaration _ -> true | _ -> false ) ; ` Map ( " module " \ b " \ { } " , function ` AmbientExternalModuleDeclaration _ -> true | _ -> false ) ; ` Map ( " enum a { b , c } " , function ` AmbientEnumDeclaration _ -> true | _ -> false ) ; ` Map ( " function a ( ) " , function ` AmbientFunctionDeclaration _ -> true | _ -> false ) ; ] ; parse_tests " declarationElement " declarationElement [ ` Map ( " declare var a ; " , function ` AmbientDeclaration _ -> true | _ -> false ) ; ` Map ( " export declare module a { } " , function ` AmbientDeclaration _ -> true | _ -> false ) ; ` Map ( " declare module " \ a " \ { } " , function ` AmbientDeclaration _ -> true | _ -> false ) ; ` Map ( " export = a ; " , function ` ExportAssignment _ -> true | _ -> false ) ; ` Map ( " interface a { } " , function ` InterfaceDeclaration _ -> true | _ -> false ) ; ` Map ( " interface a < b > extends c , d < e > { f ; g : h < i > } " , function ` InterfaceDeclaration _ -> true | _ -> false ) ; ` Map ( " import a = b . c " , function ` ImportDeclaration _ -> true | _ -> false ) ; ` Map ( " import a = require ( " \ b " \ ) ; " , function ` ExternalImportDeclaration _ -> true | _ -> false ) ; ` Ok " declare module " \ a " \ { export interface a { } } " ; ] ; parse_tests " examples " declarationSourceFile [ ` Ok " declare function vote ( candidate : string , callback : ( result : string ) => any ) " ; ` Ok " interface Friend { name : string ; favoriteColor ?: string ; } " ; ` Ok " interface JQuery { text ( content : string ) ; } interface JQueryStatic { get ( url : string , callback : ( data : string ) => any ) ; ( query : string ) : JQuery ; } declare var $: JQueryStatic ; " ; ` Ok " interface Point { x : number ; y : number ; } " ; ` Ok " declare class CPoint { x : number ; y : number ; constructor ( x : number , y : number ) ; } " ; ` Ok " interface BankAccount { balance : number ; deposit ( credit : number ) : number ; } declare var BankAccount : new ( ) => BankAccount ; " ; ` Ok " declare enum Operator { ADD , DIV , MUL , SUB } " ; ` Ok " interface Array < T > { reverse ( ) : T [ ] ; sort ( compareFn ?: ( a : T , b : T ) => number ) : T [ ] ; map < U ( > func : ( value : T , index : number , array : T [ ] ) => U , thisArg ?: any ) : U [ ] ; } " ; ` Ok " interface M { f ( ) : string ; } declare var M : M ; " ; ` Ok " declare module X { export module Y { export interface Z { } } export interface Y { } } declare module A { export module B { export class C { } } } " ; ` Ok " interface G < T , U extends Function > { f < V extends U ( > x : V ) : V ; } " ; ` Ok " interface Pair < T1 , T2 > { first : T1 ; second : T2 ; } declare var a : Pair < string , Entity ; > declare var b : { first : string ; second : Entity ; } ; " ; ` Ok " interface A { a : string ; } interface B extends A { b : string ; } interface C extends B { c : string ; } interface G < T , U extends B > { x : T ; y : U ; } " ; ` Ok " declare var v1 : { x : { a : string ; } ; y : { a : string ; b : string ; c : string } ; } ; " ; ` Ok " interface Document { createElement ( tagName : " \ div " ) \: HTMLDivElement ; createElement ( tagName : " \ span " ) \: HTMLSpanElement ; createElement ( tagName : " \ canvas " ) \: HTMLCanvasElement ; createElement ( tagName : string ) : HTMLElement ; } " ; ` Ok " declare var x : { func1 ( x : number ) : number ; func2 : ( x : number ) => number ; func3 : { ( x : number ) : number } ; } ; declare var y : { func4 ( x : number ) : number ; func4 ( s : string ) : string ; func5 : { ( x : number ) : number ; ( s : string ) : string ; } ; } ; " ; ` Ok " declare class C < T > { private x : T ; } interface X { f ( ) : string ; } interface Y { f ( ) : string ; } declare var a : C < X ; > declare var b : C < Y ; > " ; ` Ok " interface List < T > { data : T ; next : List < T ; > owner : List < List < T ; >> } " ; ` Ok " interface EventObject { x : number ; y : number ; } interface EventHandlers { mousedown ?: ( event : EventObject ) => void ; mouseup ?: ( event : EventObject ) => void ; mousemove ?: ( event : EventObject ) => void ; } declare function setEventHandlers ( handlers : EventHandlers ) " ; ` Ok " declare var attr : { ( name : string ) : string ; ( name : string , value : string ) : Accessor ; ( map : any ) : Accessor ; } ; " ; ` Ok " interface Mover { move ( ) : void ; getStatus ( ) : { speed : number ; } ; } interface Shaker { shake ( ) : void ; getStatus ( ) : { frequency : number ; } ; } interface MoverShaker extends Mover , Shaker { getStatus ( ) : { speed : number ; frequency : number ; } ; } " ; ` Ok " interface StringComparer { ( a : string , b : string ) : number ; } " ; ` Ok " interface Document { createElement ( tagName : any ) : Element ; } interface Document { createElement ( tagName : string ) : HTMLElement ; } interface Document { createElement ( tagName : " \ div " ) \: HTMLDivElement ; createElement ( tagName : " \ span " ) \: HTMLSpanElement ; createElement ( tagName : " \ canvas " ) \: HTMLCanvasElement ; } " ; ` Ok " declare class A { a : number ; } declare module Foo { var A ; class B extends A { b : string ; } } " ; ` Ok " interface A { x : number ; f : ( ) => void ; g : ( a : any ) => any ; } interface B { x : number ; y : number ; f : ( ) => void ; g : ( b : boolean ) => boolean ; } " ; ` Ok " declare class Pair < T1 , T2 > { constructor ( public item1 : T1 , public item2 : T2 ) ; } declare class TwoArrays < T > extends Pair < T [ ] , T [ ] > { } interface Pair < T1 , T2 > { item1 : T1 ; item2 : T2 ; } interface TwoArrays < T > { item1 : T [ ] ; item2 : T [ ] ; } declare var Pair : { new < T1 , T2 ( > item1 : T1 , item2 : T2 ) : Pair < T1 , T2 ; > } ; declare var TwoArrays : { new < T ( > item1 : T [ ] , item2 : T [ ] ) : TwoArrays < T ; > } ; " ; ` Ok " interface Point { x : number ; y : number ; distance ( p : Point ) ; } declare var Point : { new ( x : number , y : number ) : Point ; origin : Point ; distance ( p1 : Point , p2 : Point ) : number ; } ; " ; ` Ok " declare enum Color { Red , Green , Blue } declare var Color : { [ x : number ] : string ; Red : Color ; Green : Color ; Blue : Color ; } ; " ; ` Ok " declare module A { export interface X { s : string } export var X : X ; } " ; ` Ok " interface A { x : string ; } declare module M { export interface B { x : A ; } export interface C { x : B ; } function foo ( c : C ) } " ; ] ; ] ; ] |
let run ( ) = run_test_tt_main test_typescript |> ignore |
let single_coin = let pr = continuous_uniform 0 . 1 . in let toss t = condition ' ( fun p -> Primitive . ( pdf @@ binomial 10 p ) t ) in let obs = 9 in let posterior = toss obs pr in posterior |
let single_coin_exact = Primitive . beta 10 . 2 . |
let flip = bernoulli let * b = flip 0 . 9 in let * c = flip 0 . 9 in let wet_grass = b && rain || c && sprinkler in condition wet_grass ( return rain ) let grass_model = grass_model ' ( ) ) * |
let grass_model ' ( ) = let d = condition ' ( fun ( w , _ ) -> if w then 1 . else 0 . ) ( let * cloudy = flip 0 . 5 in let * rain = flip ( if cloudy then 0 . 8 else 0 . 2 ) in let * sprinkler = flip ( if cloudy then 0 . 1 else 0 . 5 ) in let * b = flip 0 . 9 in let * c = flip 0 . 9 in let wet_grass = ( b && rain ) || ( c && sprinkler ) in return ( wet_grass , rain ) ) in fmap snd d |
let grass_model = grass_model ' ( ) |
let grass_model_exact = Primitive . categorical [ ( true , 0 . 704225 ) ; ( false , 0 . 295775 ) ] |
let close a b = N . ( sub a b |> abs |> sum ' ) < tolerance_f32 |
let compute_trans_conv2d seq input_shape kernel_shape stride pad = let inp = N . ones input_shape in let kernel = if seq = false then N . ones kernel_shape else N . sequential ~ a : 1 . kernel_shape in N . transpose_conv2d ~ padding : pad inp kernel stride |
let compute_trans_conv2d_bi seq input_shape kernel_shape stride pad = let inp = N . ones input_shape in let kernel = if seq = false then N . ones kernel_shape else N . sequential ~ a : 1 . kernel_shape in let output = N . transpose_conv2d ~ padding : pad inp kernel stride in let os = N . shape output in let output ' = N . ones os in N . transpose_conv2d_backward_input inp kernel stride output ' |
let compute_trans_conv2d_bk seq input_shape kernel_shape stride pad = let inp = N . ones input_shape in let kernel = N . ones kernel_shape in let output = N . transpose_conv2d ~ padding : pad inp kernel stride in let os = N . shape output in let output ' = if seq = false then N . ones os else N . sequential ~ a : 1 . os in N . transpose_conv2d_backward_kernel inp kernel stride output ' |
let verify_value ( ? seq = false ) fn input_shape kernel_shape stride pad expected = let a = fn seq input_shape kernel_shape stride pad in let output_shape = N . shape a in let b = N . of_array expected output_shape in close a b |
let test_forward input_shape kernel_shape stride pad magic_num = let ph = if pad = SAME then 0 else stride . ( 0 ) - 1 in let pw = if pad = SAME then 0 else stride . ( 1 ) - 1 in let result = compute_trans_conv2d false input_shape kernel_shape stride pad in let s = N . shape result in let expected = N . zeros s in for n = 0 to s . ( 0 ) - 1 do for k = 0 to s . ( 3 ) - 1 do for w = pw to s . ( 2 ) - 1 - pw do for h = ph to s . ( 1 ) - 1 - ph do let t = magic_num . ( 0 ) in let h_in = h mod stride . ( 0 ) = 0 && h > ph && h < s . ( 1 ) - 1 - ph in let w_in = w mod stride . ( 1 ) = 0 && w > pw && w < s . ( 2 ) - 1 - pw in let addon = if h_in && w_in then magic_num . ( 1 ) else if h_in || w_in then magic_num . ( 2 ) else 0 . in let t = t . + addon in N . set expected [ | n ; h ; w ; k ] | t done done ; if pad = VALID then ( let foo = N . get_slice [ [ n ] ; [ ] ; [ 1 ] ; [ k ] ] expected in N . set_slice [ [ n ] ; [ ] ; [ 0 ] ; [ k ] ] expected foo ; let foo = N . get_slice [ [ n ] ; [ ] ; [ - 2 ] ; [ k ] ] expected in N . set_slice [ [ n ] ; [ ] ; [ - 1 ] ; [ k ] ] expected foo ; let foo = N . get_slice [ [ n ] ; [ 1 ] ; [ ] ; [ k ] ] expected in N . set_slice [ [ n ] ; [ 0 ] ; [ ] ; [ k ] ] expected foo ; let foo = N . get_slice [ [ n ] ; [ - 2 ] ; [ ] ; [ k ] ] expected in N . set_slice [ [ n ] ; [ - 1 ] ; [ ] ; [ k ] ] expected foo ) done done ; N . ( result = expected ) |
module To_test_transpose_conv2d = struct let fun00 ( ) = test_forward [ | 1 ; 6 ; 4 ; 3 ] | [ | 3 ; 3 ; 3 ; 2 ] | [ | 1 ; 1 ] | SAME [ | 12 . 0 ; 15 . 0 ; 6 . 0 ] | let fun01 ( ) = test_forward [ | 1 ; 3 ; 3 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 2 ; 2 ] | SAME [ | 1 . 0 ; 3 . 0 ; 1 . 0 ] | let fun02 ( ) = test_forward [ | 1 ; 2 ; 2 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 1 ; 1 ] | SAME [ | 4 . 0 ; 0 . 0 ; 0 . 0 ] | let fun03 ( ) = test_forward [ | 1 ; 6 ; 4 ; 3 ] | [ | 3 ; 3 ; 3 ; 1 ] | [ | 2 ; 2 ] | VALID [ | 3 . 0 ; 9 . 0 ; 3 . 0 ] | let fun04 ( ) = test_forward [ | 1 ; 2 ; 2 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 2 ; 2 ] | VALID [ | 1 . 0 ; 3 . 0 ; 1 . 0 ] | let fun05 ( ) = let expected = [ | 1 . 0 ; 2 . 0 ; 3 . 0 ; 2 . 0 ; 1 . 0 ; 2 . 0 ; 4 . 0 ; 6 . 0 ; 4 . 0 ; 2 . 0 ; 3 . 0 ; 6 . 0 ; 9 . 0 ; 6 . 0 ; 3 . 0 ; 2 . 0 ; 4 . 0 ; 6 . 0 ; 4 . 0 ; 2 . 0 ; 1 . 0 ; 2 . 0 ; 3 . 0 ; 2 . 0 ; 1 . 0 ] | in verify_value compute_trans_conv2d [ | 1 ; 3 ; 3 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 1 ; 1 ] | VALID expected let fun06 ( ) = let expected = [ | 2 . ; 2 . ; 4 . ; 2 . ; 2 . ; 2 . ; 4 . ; 2 . ] | in verify_value compute_trans_conv2d [ | 1 ; 2 ; 2 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 1 ; 2 ] | SAME expected let fun07 ( ) = let expected = [ | 1 . ; 0 . ; 1 . ; 0 . ; 0 . ; 0 . ; 0 . ; 0 . ] | in verify_value compute_trans_conv2d [ | 1 ; 1 ; 2 ; 1 ] | [ | 1 ; 1 ; 1 ; 1 ] | [ | 2 ; 2 ] | SAME expected let fun08 ( ) = let expected = [ | 1 . 0 ; 2 . 0 ; 4 . 0 ; 2 . 0 ; 4 . 0 ; 5 . 0 ; 10 . 0 ; 5 . 0 ; 8 . 0 ; 10 . 0 ; 20 . 0 ; 10 . 0 ; 4 . 0 ; 5 . 0 ; 10 . 0 ; 5 . 0 ] | in verify_value compute_trans_conv2d ~ seq : true [ | 1 ; 2 ; 2 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 2 ; 2 ] | SAME expected end |
module To_test_transpose_conv2d_backward = struct let fun00 ( ) = let expected = [ | 9 . ; 9 . ; 9 . ; 9 . ] | in verify_value compute_trans_conv2d_bi [ | 1 ; 2 ; 2 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 2 ; 2 ] | VALID expected let fun01 ( ) = let expected = [ | 9 . ; 9 . ; 9 . ; 9 . ] | in verify_value compute_trans_conv2d_bi [ | 1 ; 2 ; 2 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 1 ; 1 ] | VALID expected let fun02 ( ) = let expected = [ | 9 . ; 9 . ; 6 . ; 9 . ; 9 . ; 6 . ; 6 . ; 6 . ; 4 . ] | in verify_value compute_trans_conv2d_bi [ | 1 ; 3 ; 3 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 2 ; 2 ] | SAME expected let fun03 ( ) = let expected = [ | 4 . ; 6 . ; 6 . ; 4 . ; 6 . ; 9 . ; 9 . ; 6 . ; 6 . ; 9 . ; 9 . ; 6 . ; 4 . ; 6 . ; 6 . ; 4 . ] | in verify_value compute_trans_conv2d_bi [ | 1 ; 4 ; 4 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 1 ; 1 ] | SAME expected let fun04 ( ) = let expected = [ | 6 . ; 6 . ; 4 . ; 9 . ; 9 . ; 6 . ; 6 . ; 6 . ; 4 . ] | in verify_value compute_trans_conv2d_bi [ | 1 ; 3 ; 3 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 1 ; 2 ] | SAME expected let fun05 ( ) = let expected = [ | 3 . ; 3 . ; 2 . ; 3 . ; 3 . ; 2 . ; 3 . ; 3 . ; 2 . ] | in verify_value compute_trans_conv2d_bi [ | 1 ; 3 ; 3 ; 1 ] | [ | 1 ; 3 ; 1 ; 1 ] | [ | 2 ; 2 ] | SAME expected let fun06 ( ) = let expected = [ | 45 . ; 27 . ; 21 . ; 12 . ] | in verify_value compute_trans_conv2d_bi ~ seq : true [ | 1 ; 2 ; 2 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 2 ; 2 ] | SAME expected let fun07 ( ) = let expected = [ | 18 . ; 18 . ; 12 . ; 12 . ; 12 . ; 12 . ; 8 . ; 8 . ] | in verify_value compute_trans_conv2d_bi [ | 1 ; 2 ; 2 ; 2 ] | [ | 3 ; 3 ; 2 ; 2 ] | [ | 2 ; 2 ] | SAME expected let fun08 ( ) = let expected = [ | 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ] | in verify_value compute_trans_conv2d_bk [ | 1 ; 2 ; 2 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 2 ; 2 ] | VALID expected let fun09 ( ) = let expected = [ | 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ] | in verify_value compute_trans_conv2d_bk [ | 1 ; 2 ; 2 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 1 ; 1 ] | VALID expected let fun10 ( ) = let expected = [ | 9 . ; 9 . ; 6 . ; 9 . ; 9 . ; 6 . ; 6 . ; 6 . ; 4 . ] | in verify_value compute_trans_conv2d_bk [ | 1 ; 3 ; 3 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 2 ; 2 ] | SAME expected let fun11 ( ) = let expected = [ | 9 . ; 12 . ; 9 . ; 12 . ; 16 . ; 12 . ; 9 . ; 12 . ; 9 . ] | in verify_value compute_trans_conv2d_bk [ | 1 ; 4 ; 4 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 1 ; 1 ] | SAME expected let fun12 ( ) = let expected = [ | 6 . ; 6 . ; 4 . ; 9 . ; 9 . ; 6 . ; 6 . ; 6 . ; 4 . ] | in verify_value compute_trans_conv2d_bk [ | 1 ; 3 ; 3 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 1 ; 2 ] | SAME expected let fun13 ( ) = let expected = [ | 9 . ; 9 . ; 6 . ] | in verify_value compute_trans_conv2d_bk [ | 1 ; 3 ; 3 ; 1 ] | [ | 1 ; 3 ; 1 ; 1 ] | [ | 2 ; 2 ] | SAME expected let fun14 ( ) = let expected = [ | 24 . ; 28 . ; 14 . ; 40 . ; 44 . ; 22 . ; 20 . ; 22 . ; 11 . ] | in verify_value compute_trans_conv2d_bk ~ seq : true [ | 1 ; 2 ; 2 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ] | [ | 2 ; 2 ] | SAME expected let fun15 ( ) = let expected = [ | 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 2 . ; 2 . ; 2 . ; 2 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 1 . ; 1 . ; 1 . ; 1 . ] | in verify_value compute_trans_conv2d_bk [ | 1 ; 2 ; 2 ; 2 ] | [ | 3 ; 3 ; 2 ; 2 ] | [ | 2 ; 2 ] | SAME expected end |
let fun_ctf00 ( ) = Alcotest . ( check bool ) " fun_ctf00 " true ( To_test_transpose_conv2d . fun00 ( ) ) |
let fun_ctf01 ( ) = Alcotest . ( check bool ) " fun_ctf01 " true ( To_test_transpose_conv2d . fun01 ( ) ) |
let fun_ctf02 ( ) = Alcotest . ( check bool ) " fun_ctf02 " true ( To_test_transpose_conv2d . fun02 ( ) ) |
let fun_ctf03 ( ) = Alcotest . ( check bool ) " fun_ctf03 " true ( To_test_transpose_conv2d . fun03 ( ) ) |
let fun_ctf04 ( ) = Alcotest . ( check bool ) " fun_ctf04 " true ( To_test_transpose_conv2d . fun04 ( ) ) |
let fun_ctf05 ( ) = Alcotest . ( check bool ) " fun_ctf05 " true ( To_test_transpose_conv2d . fun05 ( ) ) |
let fun_ctf06 ( ) = Alcotest . ( check bool ) " fun_ctf06 " true ( To_test_transpose_conv2d . fun06 ( ) ) |
let fun_ctf07 ( ) = Alcotest . ( check bool ) " fun_ctf07 " true ( To_test_transpose_conv2d . fun07 ( ) ) |
let fun_ctf08 ( ) = Alcotest . ( check bool ) " fun_ctf08 " true ( To_test_transpose_conv2d . fun08 ( ) ) |
let fun_ctb00 ( ) = Alcotest . ( check bool ) " fun_ctb00 " true ( To_test_transpose_conv2d_backward . fun00 ( ) ) |
let fun_ctb01 ( ) = Alcotest . ( check bool ) " fun_ctb01 " true ( To_test_transpose_conv2d_backward . fun01 ( ) ) |
let fun_ctb02 ( ) = Alcotest . ( check bool ) " fun_ctb02 " true ( To_test_transpose_conv2d_backward . fun02 ( ) ) |
let fun_ctb03 ( ) = Alcotest . ( check bool ) " fun_ctb03 " true ( To_test_transpose_conv2d_backward . fun03 ( ) ) |
let fun_ctb04 ( ) = Alcotest . ( check bool ) " fun_ctb04 " true ( To_test_transpose_conv2d_backward . fun04 ( ) ) |
let fun_ctb05 ( ) = Alcotest . ( check bool ) " fun_ctb05 " true ( To_test_transpose_conv2d_backward . fun05 ( ) ) |
let fun_ctb06 ( ) = Alcotest . ( check bool ) " fun_ctb06 " true ( To_test_transpose_conv2d_backward . fun06 ( ) ) |
let fun_ctb07 ( ) = Alcotest . ( check bool ) " fun_ctb07 " true ( To_test_transpose_conv2d_backward . fun07 ( ) ) |
let fun_ctb08 ( ) = Alcotest . ( check bool ) " fun_ctb08 " true ( To_test_transpose_conv2d_backward . fun08 ( ) ) |
let fun_ctb09 ( ) = Alcotest . ( check bool ) " fun_ctb09 " true ( To_test_transpose_conv2d_backward . fun09 ( ) ) |
let fun_ctb10 ( ) = Alcotest . ( check bool ) " fun_ctb10 " true ( To_test_transpose_conv2d_backward . fun10 ( ) ) |
let fun_ctb11 ( ) = Alcotest . ( check bool ) " fun_ctb11 " true ( To_test_transpose_conv2d_backward . fun11 ( ) ) |
let fun_ctb12 ( ) = Alcotest . ( check bool ) " fun_ctb12 " true ( To_test_transpose_conv2d_backward . fun12 ( ) ) |
let fun_ctb13 ( ) = Alcotest . ( check bool ) " fun_ctb13 " true ( To_test_transpose_conv2d_backward . fun13 ( ) ) |
let fun_ctb14 ( ) = Alcotest . ( check bool ) " fun_ctb14 " true ( To_test_transpose_conv2d_backward . fun14 ( ) ) |
let fun_ctb15 ( ) = Alcotest . ( check bool ) " fun_ctb15 " true ( To_test_transpose_conv2d_backward . fun15 ( ) ) |
let test_set = [ " fun_ctf00 " , ` Slow , fun_ctf00 ; " fun_ctf01 " , ` Slow , fun_ctf01 ; " fun_ctf02 " , ` Slow , fun_ctf02 ; " fun_ctf03 " , ` Slow , fun_ctf03 ; " fun_ctf04 " , ` Slow , fun_ctf04 ; " fun_ctf05 " , ` Slow , fun_ctf05 ; " fun_ctf06 " , ` Slow , fun_ctf06 ; " fun_ctf07 " , ` Slow , fun_ctf07 ; " fun_ctf08 " , ` Slow , fun_ctf08 ; " fun_ctb00 " , ` Slow , fun_ctb00 ; " fun_ctb01 " , ` Slow , fun_ctb01 ; " fun_ctb02 " , ` Slow , fun_ctb02 ; " fun_ctb03 " , ` Slow , fun_ctb03 ; " fun_ctb04 " , ` Slow , fun_ctb04 ; " fun_ctb05 " , ` Slow , fun_ctb05 ; " fun_ctb06 " , ` Slow , fun_ctb06 ; " fun_ctb07 " , ` Slow , fun_ctb07 ; " fun_ctb08 " , ` Slow , fun_ctb08 ; " fun_ctb09 " , ` Slow , fun_ctb09 ; " fun_ctb10 " , ` Slow , fun_ctb10 ; " fun_ctb11 " , ` Slow , fun_ctb11 ; " fun_ctb12 " , ` Slow , fun_ctb12 ; " fun_ctb13 " , ` Slow , fun_ctb13 ; " fun_ctb14 " , ` Slow , fun_ctb14 ; " fun_ctb15 " , ` Slow , fun_ctb15 ] |
let close a b = N . ( sub a b |> abs |> sum ' ) < tolerance_f32 |
let compute_trans_conv3d seq input_shape kernel_shape stride pad = let inp = N . ones input_shape in let kernel = if seq = false then N . ones kernel_shape else N . sequential ~ a : 1 . kernel_shape in N . transpose_conv3d ~ padding : pad inp kernel stride |
let compute_trans_conv3d_bi seq input_shape kernel_shape stride pad = let inp = N . ones input_shape in let kernel = if seq = false then N . ones kernel_shape else N . sequential ~ a : 1 . kernel_shape in let output = N . transpose_conv3d ~ padding : pad inp kernel stride in let os = N . shape output in let output ' = N . ones os in N . transpose_conv3d_backward_input inp kernel stride output ' |
let compute_trans_conv3d_bk seq input_shape kernel_shape stride pad = let inp = N . ones input_shape in let kernel = N . ones kernel_shape in let output = N . transpose_conv3d ~ padding : pad inp kernel stride in let os = N . shape output in let output ' = if seq = false then N . ones os else N . sequential ~ a : 1 . os in N . transpose_conv3d_backward_kernel inp kernel stride output ' |
let verify_value ( ? seq = false ) fn input_shape kernel_shape stride pad expected = let a = fn seq input_shape kernel_shape stride pad in let output_shape = N . shape a in let b = N . of_array expected output_shape in close a b |
module To_test_transpose_conv3d = struct let fun00 ( ) = let expected = [ | 1 . 0 ; 2 . 0 ; 3 . 0 ; 2 . 0 ; 1 . 0 ; 2 . 0 ; 4 . 0 ; 6 . 0 ; 4 . 0 ; 2 . 0 ; 3 . 0 ; 6 . 0 ; 9 . 0 ; 6 . 0 ; 3 . 0 ; 2 . 0 ; 4 . 0 ; 6 . 0 ; 4 . 0 ; 2 . 0 ; 1 . 0 ; 2 . 0 ; 3 . 0 ; 2 . 0 ; 1 . 0 ] | in verify_value compute_trans_conv3d [ | 1 ; 3 ; 3 ; 1 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ; 1 ] | [ | 1 ; 1 ; 1 ] | VALID expected let fun01 ( ) = let expected = [ | 2 . ; 2 . ; 4 . ; 2 . ; 2 . ; 2 . ; 4 . ; 2 . ] | in verify_value compute_trans_conv3d [ | 1 ; 2 ; 2 ; 1 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ; 1 ] | [ | 1 ; 2 ; 1 ] | SAME expected let fun02 ( ) = let expected = [ | 1 . ; 0 . ; 1 . ; 0 . ; 0 . ; 0 . ; 0 . ; 0 . ] | in verify_value compute_trans_conv3d [ | 1 ; 1 ; 2 ; 1 ; 1 ] | [ | 1 ; 1 ; 1 ; 1 ; 1 ] | [ | 2 ; 2 ; 1 ] | SAME expected let fun03 ( ) = let expected = [ | 1 . 0 ; 2 . 0 ; 4 . 0 ; 2 . 0 ; 4 . 0 ; 5 . 0 ; 10 . 0 ; 5 . 0 ; 8 . 0 ; 10 . 0 ; 20 . 0 ; 10 . 0 ; 4 . 0 ; 5 . 0 ; 10 . 0 ; 5 . 0 ] | in verify_value compute_trans_conv3d ~ seq : true [ | 1 ; 2 ; 2 ; 1 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ; 1 ] | [ | 2 ; 2 ; 1 ] | SAME expected let fun04 ( ) = let expected = [ | 2 . 0 ; 2 . 0 ; 4 . 0 ; 2 . 0 ; 2 . 0 ; 2 . 0 ; 4 . 0 ; 2 . 0 ; 4 . 0 ; 4 . 0 ; 8 . 0 ; 4 . 0 ; 2 . 0 ; 2 . 0 ; 4 . 0 ; 2 . 0 ; 4 . 0 ; 4 . 0 ; 8 . 0 ; 4 . 0 ; 2 . 0 ; 2 . 0 ; 4 . 0 ; 2 . 0 ; 2 . 0 ; 2 . 0 ; 4 . 0 ; 2 . 0 ; 2 . 0 ; 2 . 0 ; 4 . 0 ; 2 . 0 ; 4 . 0 ; 4 . 0 ; 8 . 0 ; 4 . 0 ; 2 . 0 ; 2 . 0 ; 4 . 0 ; 2 . 0 ; 4 . 0 ; 4 . 0 ; 8 . 0 ; 4 . 0 ; 2 . 0 ; 2 . 0 ; 4 . 0 ; 2 . 0 ; 4 . 0 ; 4 . 0 ; 8 . 0 ; 4 . 0 ; 4 . 0 ; 4 . 0 ; 8 . 0 ; 4 . 0 ; 8 . 0 ; 8 . 0 ; 16 . 0 ; 8 . 0 ; 4 . 0 ; 4 . 0 ; 8 . 0 ; 4 . 0 ; 8 . 0 ; 8 . 0 ; 16 . 0 ; 8 . 0 ; 4 . 0 ; 4 . 0 ; 8 . 0 ; 4 . 0 ; 2 . 0 ; 2 . 0 ; 4 . 0 ; 2 . 0 ; 2 . 0 ; 2 . 0 ; 4 . 0 ; 2 . 0 ; 4 . 0 ; 4 . 0 ; 8 . 0 ; 4 . 0 ; 2 . 0 ; 2 . 0 ; 4 . 0 ; 2 . 0 ; 4 . 0 ; 4 . 0 ; 8 . 0 ; 4 . 0 ; 2 . 0 ; 2 . 0 ; 4 . 0 ; 2 . 0 ] | in verify_value compute_trans_conv3d [ | 1 ; 2 ; 3 ; 2 ; 2 ] | [ | 3 ; 3 ; 3 ; 2 ; 1 ] | [ | 2 ; 2 ; 2 ] | SAME expected end |
module To_test_transpose_conv3d_backward = struct let fun00 ( ) = let expected = [ | 9 . ; 9 . ; 9 . ; 9 . ] | in verify_value compute_trans_conv3d_bi [ | 1 ; 2 ; 2 ; 1 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ; 1 ] | [ | 2 ; 2 ; 1 ] | VALID expected let fun01 ( ) = let expected = [ | 9 . ; 9 . ; 9 . ; 9 . ] | in verify_value compute_trans_conv3d_bi [ | 1 ; 2 ; 2 ; 1 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ; 1 ] | [ | 1 ; 1 ; 1 ] | VALID expected let fun02 ( ) = let expected = [ | 9 . ; 9 . ; 6 . ; 9 . ; 9 . ; 6 . ; 6 . ; 6 . ; 4 . ] | in verify_value compute_trans_conv3d_bi [ | 1 ; 3 ; 1 ; 3 ; 1 ] | [ | 3 ; 1 ; 3 ; 1 ; 1 ] | [ | 2 ; 1 ; 2 ] | SAME expected let fun03 ( ) = let expected = [ | 4 . ; 6 . ; 6 . ; 4 . ; 6 . ; 9 . ; 9 . ; 6 . ; 6 . ; 9 . ; 9 . ; 6 . ; 4 . ; 6 . ; 6 . ; 4 . ] | in verify_value compute_trans_conv3d_bi [ | 1 ; 4 ; 1 ; 4 ; 1 ] | [ | 3 ; 1 ; 3 ; 1 ; 1 ] | [ | 1 ; 1 ; 1 ] | SAME expected let fun04 ( ) = let expected = [ | 6 . ; 6 . ; 4 . ; 9 . ; 9 . ; 6 . ; 6 . ; 6 . ; 4 . ] | in verify_value compute_trans_conv3d_bi [ | 1 ; 3 ; 3 ; 1 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ; 1 ] | [ | 1 ; 2 ; 1 ] | SAME expected let fun05 ( ) = let expected = [ | 3 . ; 3 . ; 2 . ; 3 . ; 3 . ; 2 . ; 3 . ; 3 . ; 2 . ] | in verify_value compute_trans_conv3d_bi [ | 1 ; 3 ; 3 ; 1 ; 1 ] | [ | 1 ; 3 ; 1 ; 1 ; 1 ] | [ | 2 ; 2 ; 1 ] | SAME expected let fun06 ( ) = let expected = [ | 45 . ; 27 . ; 21 . ; 12 . ] | in verify_value compute_trans_conv3d_bi ~ seq : true [ | 1 ; 2 ; 2 ; 1 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ; 1 ] | [ | 2 ; 2 ; 1 ] | SAME expected let fun07 ( ) = let expected = [ | 18 . ; 18 . ; 12 . ; 12 . ; 12 . ; 12 . ; 8 . ; 8 . ] | in verify_value compute_trans_conv3d_bi [ | 1 ; 2 ; 2 ; 1 ; 2 ] | [ | 3 ; 3 ; 1 ; 2 ; 2 ] | [ | 2 ; 2 ; 1 ] | SAME expected let fun08 ( ) = let expected = [ | 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ] | in verify_value compute_trans_conv3d_bk [ | 1 ; 2 ; 1 ; 2 ; 1 ] | [ | 3 ; 1 ; 3 ; 1 ; 1 ] | [ | 2 ; 1 ; 2 ] | VALID expected let fun09 ( ) = let expected = [ | 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ] | in verify_value compute_trans_conv3d_bk [ | 1 ; 2 ; 2 ; 1 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ; 1 ] | [ | 1 ; 1 ; 1 ] | VALID expected let fun10 ( ) = let expected = [ | 9 . ; 9 . ; 6 . ; 9 . ; 9 . ; 6 . ; 6 . ; 6 . ; 4 . ] | in verify_value compute_trans_conv3d_bk [ | 1 ; 3 ; 3 ; 1 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ; 1 ] | [ | 2 ; 2 ; 1 ] | SAME expected let fun11 ( ) = let expected = [ | 9 . ; 12 . ; 9 . ; 12 . ; 16 . ; 12 . ; 9 . ; 12 . ; 9 . ] | in verify_value compute_trans_conv3d_bk [ | 1 ; 4 ; 4 ; 1 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ; 1 ] | [ | 1 ; 1 ; 1 ] | SAME expected let fun12 ( ) = let expected = [ | 6 . ; 6 . ; 4 . ; 9 . ; 9 . ; 6 . ; 6 . ; 6 . ; 4 . ] | in verify_value compute_trans_conv3d_bk [ | 1 ; 3 ; 3 ; 1 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ; 1 ] | [ | 1 ; 2 ; 1 ] | SAME expected let fun13 ( ) = let expected = [ | 9 . ; 9 . ; 6 . ] | in verify_value compute_trans_conv3d_bk [ | 1 ; 3 ; 1 ; 3 ; 1 ] | [ | 1 ; 1 ; 3 ; 1 ; 1 ] | [ | 2 ; 1 ; 2 ] | SAME expected let fun14 ( ) = let expected = [ | 24 . ; 28 . ; 14 . ; 40 . ; 44 . ; 22 . ; 20 . ; 22 . ; 11 . ] | in verify_value compute_trans_conv3d_bk ~ seq : true [ | 1 ; 2 ; 2 ; 1 ; 1 ] | [ | 3 ; 3 ; 1 ; 1 ; 1 ] | [ | 2 ; 2 ; 1 ] | SAME expected let fun15 ( ) = let expected = [ | 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 2 . ; 2 . ; 2 . ; 2 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 4 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 2 . ; 1 . ; 1 . ; 1 . ; 1 . ] | in verify_value compute_trans_conv3d_bk [ | 1 ; 2 ; 1 ; 2 ; 2 ] | [ | 3 ; 1 ; 3 ; 2 ; 2 ] | [ | 2 ; 1 ; 2 ] | SAME expected end |
let fun_ctf00 ( ) = Alcotest . ( check bool ) " fun_ctf00 " true ( To_test_transpose_conv3d . fun00 ( ) ) |
let fun_ctf01 ( ) = Alcotest . ( check bool ) " fun_ctf01 " true ( To_test_transpose_conv3d . fun01 ( ) ) |
let fun_ctf02 ( ) = Alcotest . ( check bool ) " fun_ctf02 " true ( To_test_transpose_conv3d . fun02 ( ) ) |
let fun_ctf03 ( ) = Alcotest . ( check bool ) " fun_ctf03 " true ( To_test_transpose_conv3d . fun03 ( ) ) |
let fun_ctf04 ( ) = Alcotest . ( check bool ) " fun_ctf04 " true ( To_test_transpose_conv3d . fun04 ( ) ) |
let fun_ctb00 ( ) = Alcotest . ( check bool ) " fun_ctb00 " true ( To_test_transpose_conv3d_backward . fun00 ( ) ) |
let fun_ctb01 ( ) = Alcotest . ( check bool ) " fun_ctb01 " true ( To_test_transpose_conv3d_backward . fun01 ( ) ) |
let fun_ctb02 ( ) = Alcotest . ( check bool ) " fun_ctb02 " true ( To_test_transpose_conv3d_backward . fun02 ( ) ) |
let fun_ctb03 ( ) = Alcotest . ( check bool ) " fun_ctb03 " true ( To_test_transpose_conv3d_backward . fun03 ( ) ) |
let fun_ctb04 ( ) = Alcotest . ( check bool ) " fun_ctb04 " true ( To_test_transpose_conv3d_backward . fun04 ( ) ) |
let fun_ctb05 ( ) = Alcotest . ( check bool ) " fun_ctb05 " true ( To_test_transpose_conv3d_backward . fun05 ( ) ) |
let fun_ctb06 ( ) = Alcotest . ( check bool ) " fun_ctb06 " true ( To_test_transpose_conv3d_backward . fun06 ( ) ) |
let fun_ctb07 ( ) = Alcotest . ( check bool ) " fun_ctb07 " true ( To_test_transpose_conv3d_backward . fun07 ( ) ) |
let fun_ctb08 ( ) = Alcotest . ( check bool ) " fun_ctb08 " true ( To_test_transpose_conv3d_backward . fun08 ( ) ) |
let fun_ctb09 ( ) = Alcotest . ( check bool ) " fun_ctb09 " true ( To_test_transpose_conv3d_backward . fun09 ( ) ) |
let fun_ctb10 ( ) = Alcotest . ( check bool ) " fun_ctb10 " true ( To_test_transpose_conv3d_backward . fun10 ( ) ) |
let fun_ctb11 ( ) = Alcotest . ( check bool ) " fun_ctb11 " true ( To_test_transpose_conv3d_backward . fun11 ( ) ) |
let fun_ctb12 ( ) = Alcotest . ( check bool ) " fun_ctb12 " true ( To_test_transpose_conv3d_backward . fun12 ( ) ) |
let fun_ctb13 ( ) = Alcotest . ( check bool ) " fun_ctb13 " true ( To_test_transpose_conv3d_backward . fun13 ( ) ) |
let fun_ctb14 ( ) = Alcotest . ( check bool ) " fun_ctb14 " true ( To_test_transpose_conv3d_backward . fun14 ( ) ) |
let fun_ctb15 ( ) = Alcotest . ( check bool ) " fun_ctb15 " true ( To_test_transpose_conv3d_backward . fun15 ( ) ) |
let test_set = [ " fun_ctf00 " , ` Slow , fun_ctf00 ; " fun_ctf01 " , ` Slow , fun_ctf01 ; " fun_ctf02 " , ` Slow , fun_ctf02 ; " fun_ctf03 " , ` Slow , fun_ctf03 ; " fun_ctf04 " , ` Slow , fun_ctf04 ; " fun_ctb00 " , ` Slow , fun_ctb00 ; " fun_ctb01 " , ` Slow , fun_ctb01 ; " fun_ctb02 " , ` Slow , fun_ctb02 ; " fun_ctb03 " , ` Slow , fun_ctb03 ; " fun_ctb04 " , ` Slow , fun_ctb04 ; " fun_ctb05 " , ` Slow , fun_ctb05 ; " fun_ctb06 " , ` Slow , fun_ctb06 ; " fun_ctb07 " , ` Slow , fun_ctb07 ; " fun_ctb08 " , ` Slow , fun_ctb08 ; " fun_ctb09 " , ` Slow , fun_ctb09 ; " fun_ctb10 " , ` Slow , fun_ctb10 ; " fun_ctb11 " , ` Slow , fun_ctb11 ; " fun_ctb12 " , ` Slow , fun_ctb12 ; " fun_ctb13 " , ` Slow , fun_ctb13 ; " fun_ctb14 " , ` Slow , fun_ctb14 ; " fun_ctb15 " , ` Slow , fun_ctb15 ] |
type t type ' a t type ' + _a t type ' - a t type ( ' a , ' + b , ( ' - c , ' - d ) ) t |
type t = A | B of ' a | C of ' a * ' b | D of ( ' a ) Array . t * ' b list | E of _ |
type t = { f1 : t1 ; f2 : ' a ; mutable f3 : t2 ; f4 : ' a ' b . t2 ; } |
type ' a t constraint ' a = t constraint ' b = ' a type ( ' a , ' + b , ( ' - c , ' - d ) ) t = { f1 : t1 ; f2 : ' a ; mutable f3 : t2 ; f4 : t1 * t2 ; } constraint ' a = t constraint ' b = ' a exception E exception E of ' a t * string exception E ' = E |
' ident _ ( t ) int -> int -> t -> t -> t lab1 : int -> lab2 : ( t ) -> t ? lab1 : ( ? _ : int -> t ) -> t ( t1 * t2 ) * ( t ) int ( ' a -> ' b ) Array . t int as ' bla [ ` _ | ` _ ' | ` _00 | ` Aa of int ] | ` _ | ` _ ' | ` _00 | ` Aa of int ] ` _ | ` _ ' | ` _00 | ` Aa of int ] [ | ` _ | ` _ ' | ` _00 | ` Aa of int ] | ` Bb of int & string & t | int > ` a ` _bbb ` c ` d ] < > < . . > < meth : int option ; meth2 : ' a . ' a option ; meth3 : ' a ' b . ( ' a , ' b ) Hashtbl . t > < meth : int option ; meth2 : ' a . ' a option ; meth3 : ' a ' b . ( ' a , ' b ) Hashtbl . t ; . . > # M . meth ' a # M . meth ( ' a , ' b ' * c ) # M . meth |
module Make ( N : Ndarray_Algodiff with type elt = float ) = struct let tolerance_f64 = 1e - 8 let tolerance_f32 = 5e - 4 let close a b = N . ( sub a b |> abs |> sum ' ) < tolerance_f32 let test_upsampling2d_forward input_shape size = let inp = N . sequential input_shape in let outp = N . upsampling2d inp size in let expected = N . repeat inp [ | 1 ; size . ( 0 ) ; size . ( 1 ) ; 1 ] | in close outp expected let test_upsampling2d_backward input_shape size = let inp = N . ones input_shape in let outp = N . upsampling2d inp size in let out_shp = N . shape outp in let outp ' = N . sequential out_shp in N . upsampling2d_backward inp size outp ' let verify_value input_shape size expected = let a = test_upsampling2d_backward input_shape size in let output_shape ' = N . shape a in assert ( output_shape ' = input_shape ) ; let b = N . of_array expected input_shape in close a b module To_test_upsampling2d = struct let fun00 ( ) = test_upsampling2d_forward [ | 1 ; 8 ; 7 ; 1 ] | [ | 2 ; 2 ] | let fun01 ( ) = test_upsampling2d_forward [ | 1 ; 8 ; 7 ; 1 ] | [ | 2 ; 3 ] | let fun02 ( ) = test_upsampling2d_forward [ | 4 ; 8 ; 7 ; 3 ] | [ | 3 ; 2 ] | let fun03 ( ) = test_upsampling2d_forward [ | 4 ; 8 ; 7 ; 3 ] | [ | 1 ; 1 ] | let fun04 ( ) = let expected = [ | 18 . ; 26 . ; 34 . ; 42 . ; 82 . ; 90 . ; 98 . ; 106 . ; 146 . ; 154 . ; 162 . ; 170 . ] | in verify_value [ | 1 ; 3 ; 4 ; 1 ] | [ | 2 ; 2 ] | expected let fun05 ( ) = let expected = [ | 56 . 0 ; 60 . 0 ; 64 . 0 ; 68 . 0 ; 88 . 0 ; 92 . 0 ; 96 . 0 ; 100 . 0 ; 120 . 0 ; 124 . 0 ; 128 . 0 ; 132 . 0 ; 248 . 0 ; 252 . 0 ; 256 . 0 ; 260 . 0 ; 280 . 0 ; 284 . 0 ; 288 . 0 ; 292 . 0 ; 312 . 0 ; 316 . 0 ; 320 . 0 ; 324 . 0 ] | in verify_value [ | 1 ; 2 ; 3 ; 4 ] | [ | 2 ; 2 ] | expected let fun06 ( ) = let expected = [ | 156 . 0 ; 162 . 0 ; 168 . 0 ; 174 . 0 ; 204 . 0 ; 210 . 0 ; 216 . 0 ; 222 . 0 ; 252 . 0 ; 258 . 0 ; 264 . 0 ; 270 . 0 ; 588 . 0 ; 594 . 0 ; 600 . 0 ; 606 . 0 ; 636 . 0 ; 642 . 0 ; 648 . 0 ; 654 . 0 ; 684 . 0 ; 690 . 0 ; 696 . 0 ; 702 . 0 ] | in verify_value [ | 1 ; 2 ; 3 ; 4 ] | [ | 3 ; 2 ] | expected let fun07 ( ) = let expected = [ | 66 . 0 ; 72 . 0 ; 102 . 0 ; 108 . 0 ; 138 . 0 ; 144 . 0 ; 282 . 0 ; 288 . 0 ; 318 . 0 ; 324 . 0 ; 354 . 0 ; 360 . 0 ; 498 . 0 ; 504 . 0 ; 534 . 0 ; 540 . 0 ; 570 . 0 ; 576 . 0 ; 714 . 0 ; 720 . 0 ; 750 . 0 ; 756 . 0 ; 786 . 0 ; 792 . 0 ; 930 . 0 ; 936 . 0 ; 966 . 0 ; 972 . 0 ; 1002 . 0 ; 1008 . 0 ; 1146 . 0 ; 1152 . 0 ; 1182 . 0 ; 1188 . 0 ; 1218 . 0 ; 1224 . 0 ] | in verify_value [ | 3 ; 2 ; 3 ; 2 ] | [ | 2 ; 3 ] | expected let fun08 ( ) = let expected = [ | 0 . ; 1 . ; 2 . ; 3 . ; 4 . ; 5 . ; 6 . ; 7 . ; 8 . ; 9 . ; 10 . ; 11 . ; 12 . ; 13 . ; 14 . ; 15 . ; 16 . ; 17 . ; 18 . ; 19 . ; 20 . ; 21 . ; 22 . ; 23 . ; 24 . ; 25 . ; 26 . ; 27 . ; 28 . ; 29 . ] | in verify_value [ | 1 ; 5 ; 6 ; 1 ] | [ | 1 ; 1 ] | expected end let fun_us2d00 ( ) = Alcotest . ( check bool ) " fun_us2d00 " true ( To_test_upsampling2d . fun00 ( ) ) let fun_us2d01 ( ) = Alcotest . ( check bool ) " fun_us2d01 " true ( To_test_upsampling2d . fun01 ( ) ) let fun_us2d02 ( ) = Alcotest . ( check bool ) " fun_us2d02 " true ( To_test_upsampling2d . fun02 ( ) ) let fun_us2d03 ( ) = Alcotest . ( check bool ) " fun_us2d03 " true ( To_test_upsampling2d . fun03 ( ) ) let fun_us2d04 ( ) = Alcotest . ( check bool ) " fun_us2d04 " true ( To_test_upsampling2d . fun04 ( ) ) let fun_us2d05 ( ) = Alcotest . ( check bool ) " fun_us2d05 " true ( To_test_upsampling2d . fun05 ( ) ) let fun_us2d06 ( ) = Alcotest . ( check bool ) " fun_us2d06 " true ( To_test_upsampling2d . fun06 ( ) ) let fun_us2d07 ( ) = Alcotest . ( check bool ) " fun_us2d07 " true ( To_test_upsampling2d . fun07 ( ) ) let fun_us2d08 ( ) = Alcotest . ( check bool ) " fun_us2d08 " true ( To_test_upsampling2d . fun08 ( ) ) let test_set = [ " fun_us2d00 " , ` Slow , fun_us2d00 ; " fun_us2d01 " , ` Slow , fun_us2d01 ; " fun_us2d02 " , ` Slow , fun_us2d02 ; " fun_us2d03 " , ` Slow , fun_us2d03 ; " fun_us2d04 " , ` Slow , fun_us2d04 ; " fun_us2d05 " , ` Slow , fun_us2d05 ; " fun_us2d06 " , ` Slow , fun_us2d06 ; " fun_us2d07 " , ` Slow , fun_us2d07 ; " fun_us2d08 " , ` Slow , fun_us2d08 ] end |
module V = Owl_view . Make ( N ) |
let x0 = N . sequential [ | 10 ] | |> V . of_arr |
let x1 = N . sequential [ | 10 ; 10 ] | |> V . of_arr |
let x2 = N . sequential [ | 10 ; 10 ; 10 ] | |> V . of_arr |
let x3 = N . sequential [ | 5 ; 5 ; 5 ; 5 ] | |> V . of_arr |
module To_test = struct let test_01 ( ) = let s = [ [ ] ] in let y = V . get_slice s x0 in V . equal y x0 let test_02 ( ) = let s = [ [ 3 ] ] in let y = V . get_slice s x0 in let z = N . of_array [ | 3 . ] | [ | 1 ] | in V . equal y ( V . of_arr z ) let test_03 ( ) = let s = [ [ 2 ; 5 ] ] in let y = V . get_slice s x0 in let z = N . of_array [ | 2 . ; 3 . ; 4 . ; 5 . ] | [ | 4 ] | in V . equal y ( V . of_arr z ) let test_04 ( ) = let s = [ [ 2 ; - 1 ; 3 ] ] in let y = V . get_slice s x0 in let z = N . of_array [ | 2 . ; 5 . ; 8 . ] | [ | 3 ] | in V . equal y ( V . of_arr z ) let test_05 ( ) = let s = [ [ - 2 ; 5 ] ] in let y = V . get_slice s x0 in let z = N . of_array [ | 8 . ; 7 . ; 6 . ; 5 . ] | [ | 4 ] | in V . equal y ( V . of_arr z ) let test_06 ( ) = let s = [ [ - 2 ; 4 ; - 2 ] ] in let y = V . get_slice s x0 in let z = N . of_array [ | 8 . ; 6 . ; 4 . ] | [ | 3 ] | in V . equal y ( V . of_arr z ) let test_07 ( ) = let s = [ [ ] ; [ ] ] in let y = V . get_slice s x1 in V . equal y x1 let test_08 ( ) = let s = [ [ 2 ] ; [ ] ] in let y = V . get_slice s x1 in let z = N . of_array [ | 20 . ; 21 . ; 22 . ; 23 . ; 24 . ; 25 . ; 26 . ; 27 . ; 28 . ; 29 . ] | [ | 1 ; 10 ] | in V . equal y ( V . of_arr z ) let test_09 ( ) = let s = [ [ 0 ; 5 ] ; [ ] ] in let y = V . get_slice s x1 in let z = N . sequential [ | 6 ; 10 ] | in V . equal y ( V . of_arr z ) let test_10 ( ) = let s = [ [ 0 ; 5 ; 2 ] ; [ ] ] in let y = V . get_slice s x1 in let z = N . of_array [ | 0 . ; 1 . ; 2 . ; 3 . ; 4 . ; 5 . ; 6 . ; 7 . ; 8 . ; 9 . ; 20 . ; 21 . ; 22 . ; 23 . ; 24 . ; 25 . ; 26 . ; 27 . ; 28 . ; 29 . ; 40 . ; 41 . ; 42 . ; 43 . ; 44 . ; 45 . ; 46 . ; 47 . ; 48 . ; 49 . ] | [ | 3 ; 10 ] | in V . equal y ( V . of_arr z ) let test_11 ( ) = let s = [ [ 5 ; 0 ; - 2 ] ; [ ] ] in let y = V . get_slice s x1 in let z = N . of_array [ | 50 . ; 51 . ; 52 . ; 53 . ; 54 . ; 55 . ; 56 . ; 57 . ; 58 . ; 59 . ; 30 . ; 31 . ; 32 . ; 33 . ; 34 . ; 35 . ; 36 . ; 37 . ; 38 . ; 39 . ; 10 . ; 11 . ; 12 . ; 13 . ; 14 . ; 15 . ; 16 . ; 17 . ; 18 . ; 19 . ] | [ | 3 ; 10 ] | in V . equal y ( V . of_arr z ) let test_12 ( ) = let s = [ [ 0 ; 5 ; 2 ] ; [ 1 ; 5 ] ] in let y = V . get_slice s x1 in let z = N . of_array [ | 1 . ; 2 . ; 3 . ; 4 . ; 5 . ; 21 . ; 22 . ; 23 . ; 24 . ; 25 . ; 41 . ; 42 . ; 43 . ; 44 . ; 45 . ] | [ | 3 ; 5 ] | in V . equal y ( V . of_arr z ) let test_13 ( ) = let s = [ [ 0 ; 5 ; 2 ] ; [ 1 ; 5 ; 3 ] ] in let y = V . get_slice s x1 in let z = N . of_array [ | 1 . ; 4 . ; 21 . ; 24 . ; 41 . ; 44 . ] | [ | 3 ; 2 ] | in V . equal y ( V . of_arr z ) let test_14 ( ) = let s = [ [ 0 ; 5 ; 2 ] ; [ - 5 ; 1 ] ] in let y = V . get_slice s x1 in let z = N . of_array [ | 5 . ; 4 . ; 3 . ; 2 . ; 1 . ; 25 . ; 24 . ; 23 . ; 22 . ; 21 . ; 45 . ; 44 . ; 43 . ; 42 . ; 41 . ] | [ | 3 ; 5 ] | in V . equal y ( V . of_arr z ) let test_15 ( ) = let s = [ [ 0 ; 5 ; 2 ] ; [ - 5 ; 1 ; - 2 ] ] in let y = V . get_slice s x1 in let z = N . of_array [ | 5 . ; 3 . ; 1 . ; 25 . ; 23 . ; 21 . ; 45 . ; 43 . ; 41 . ] | [ | 3 ; 3 ] | in V . equal y ( V . of_arr z ) let test_16 ( ) = let s = [ [ ] ; [ ] ; [ ] ] in let y = V . get_slice s x2 in V . equal y x2 let test_17 ( ) = let s = [ [ 0 ] ; [ ] ; [ ] ] in let y = V . get_slice s x2 in let z = N . sequential [ | 1 ; 10 ; 10 ] | in V . equal y ( V . of_arr z ) let test_18 ( ) = let s = [ [ 1 ] ; [ 2 ] ; [ ] ] in let y = V . get_slice s x2 in let z = N . of_array [ | 120 . ; 121 . ; 122 . ; 123 . ; 124 . ; 125 . ; 126 . ; 127 . ; 128 . ; 129 . ] | [ | 1 ; 1 ; 10 ] | in V . equal y ( V . of_arr z ) let test_19 ( ) = let s = [ [ 0 ; 5 ; 3 ] ; [ 0 ; 5 ; 3 ] ; [ 0 ; 2 ] ] in let y = V . get_slice s x2 in let z = N . of_array [ | 0 . ; 1 . ; 2 . ; 30 . ; 31 . ; 32 . ; 300 . ; 301 . ; 302 . ; 330 . ; 331 . ; 332 . ] | [ | 2 ; 2 ; 3 ] | in V . equal y ( V . of_arr z ) let test_20 ( ) = let s = [ [ 1 ] ; [ 2 ] ; [ 3 ] ] in let y = V . get_slice s x2 in let z = N . of_array [ | 123 . ] | [ | 1 ; 1 ; 1 ] | in V . equal y ( V . of_arr z ) let test_21 ( ) = let s = [ [ - 1 ; 0 ] ; [ - 1 ; 0 ] ; [ - 1 ; 0 ] ] in let y = V . get_slice s x2 in let z = N . reverse ( V . to_arr x2 ) in V . equal y ( V . of_arr z ) let test_22 ( ) = let s = [ [ - 1 ; 0 ] ; [ - 1 ; 0 ] ; [ - 1 ; 0 ] ; [ - 1 ; 0 ] ] in let y = V . get_slice s x3 in let z = N . reverse ( V . to_arr x3 ) in V . equal y ( V . of_arr z ) let test_23 ( ) = let s = [ [ 0 ; 2 ] ] in let x = V . to_arr x0 |> V . of_arr in let y = N . of_array [ | 2 . ; 3 . ; 5 . ] | [ | 3 ] | in V . set_slice s x ( V . of_arr y ) ; let z = N . of_array [ | 2 . ; 3 . ; 5 . ; 3 . ; 4 . ; 5 . ; 6 . ; 7 . ; 8 . ; 9 . ] | [ | 10 ] | in V . equal x ( V . of_arr z ) let test_24 ( ) = let s = [ [ 5 ; 3 ] ] in let x = V . to_arr x0 |> V . of_arr in let y = N . of_array [ | 2 . ; 3 . ; 5 . ] | [ | 3 ] | in V . set_slice s x ( V . of_arr y ) ; let z = N . of_array [ | 0 . ; 1 . ; 2 . ; 5 . ; 3 . ; 2 . ; 6 . ; 7 . ; 8 . ; 9 . ] | [ | 10 ] | in V . equal x ( V . of_arr z ) let test_25 ( ) = let s = [ [ 2 ; 8 ; 3 ] ] in let x = V . to_arr x0 |> V . of_arr in let y = N . of_array [ | 2 . ; 3 . ; 5 . ] | [ | 3 ] | in V . set_slice s x ( V . of_arr y ) ; let z = N . of_array [ | 0 . ; 1 . ; 2 . ; 3 . ; 4 . ; 3 . ; 6 . ; 7 . ; 5 . ; 9 . ] | [ | 10 ] | in V . equal x ( V . of_arr z ) let test_26 ( ) = let s = [ [ - 1 ] ; [ - 1 ] ] in let x = V . to_arr x1 |> V . of_arr in let y = N . of_array [ | 0 . ] | [ | 1 ; 1 ] | in V . set_slice s x ( V . of_arr y ) ; let z = V . to_arr x1 in N . set z [ | 9 ; 9 ] | 0 . ; V . equal x ( V . of_arr z ) let test_27 ( ) = let s = [ [ 0 ; 9 ; 9 ] ; [ 0 ; 9 ; 9 ] ] in let x = V . to_arr x1 |> V . of_arr in let y = N . of_array [ | 5 . ; 6 . ; 7 . ; 8 . ] | [ | 2 ; 2 ] | in V . set_slice s x ( V . of_arr y ) ; let z = V . to_arr x1 in N . set z [ | 0 ; 0 ] | 5 . ; N . set z [ | 0 ; 9 ] | 6 . ; N . set z [ | 9 ; 0 ] | 7 . ; N . set z [ | 9 ; 9 ] | 8 . ; V . equal x ( V . of_arr z ) let test_28 ( ) = let s = [ [ - 1 ; 0 ; - 9 ] ; [ - 1 ; 0 ; - 9 ] ] in let x = V . to_arr x1 |> V . of_arr in let y = N . of_array [ | 5 . ; 6 . ; 7 . ; 8 . ] | [ | 2 ; 2 ] | in V . set_slice s x ( V . of_arr y ) ; let z = V . to_arr x1 in N . set z [ | 0 ; 0 ] | 8 . ; N . set z [ | 0 ; 9 ] | 7 . ; N . set z [ | 9 ; 0 ] | 6 . ; N . set z [ | 9 ; 9 ] | 5 . ; V . equal x ( V . of_arr z ) let test_29 ( ) = let s = [ [ - 1 ] ; [ - 1 ] ; [ - 2 ] ] in let x = V . to_arr x2 |> V . of_arr in let y = N . of_array [ | 5 . ] | [ | 1 ; 1 ; 1 ] | in V . set_slice s x ( V . of_arr y ) ; let z = V . to_arr x2 in N . set z [ | 9 ; 9 ; 8 ] | 5 . ; V . equal x ( V . of_arr z ) let test_30 ( ) = let s = [ [ - 1 ] ; [ 5 ; 6 ] ; [ 0 ] ] in let x = V . to_arr x2 |> V . of_arr in let y = N . of_array [ | 1 . ; 2 . ] | [ | 1 ; 2 ; 1 ] | in V . set_slice s x ( V . of_arr y ) ; let z = V . to_arr x2 in N . set z [ | 9 ; 5 ; 0 ] | 1 . ; N . set z [ | 9 ; 6 ; 0 ] | 2 . ; V . equal x ( V . of_arr z ) end |
let test_01 ( ) = Alcotest . ( check bool ) " test 01 " true ( To_test . test_01 ( ) ) |
let test_02 ( ) = Alcotest . ( check bool ) " test 02 " true ( To_test . test_02 ( ) ) |
let test_03 ( ) = Alcotest . ( check bool ) " test 03 " true ( To_test . test_03 ( ) ) |
let test_04 ( ) = Alcotest . ( check bool ) " test 04 " true ( To_test . test_04 ( ) ) |
let test_05 ( ) = Alcotest . ( check bool ) " test 05 " true ( To_test . test_05 ( ) ) |
let test_06 ( ) = Alcotest . ( check bool ) " test 06 " true ( To_test . test_06 ( ) ) |
let test_07 ( ) = Alcotest . ( check bool ) " test 07 " true ( To_test . test_07 ( ) ) |
let test_08 ( ) = Alcotest . ( check bool ) " test 08 " true ( To_test . test_08 ( ) ) |
let test_09 ( ) = Alcotest . ( check bool ) " test 09 " true ( To_test . test_09 ( ) ) |
let test_10 ( ) = Alcotest . ( check bool ) " test 10 " true ( To_test . test_10 ( ) ) |
let test_11 ( ) = Alcotest . ( check bool ) " test 11 " true ( To_test . test_11 ( ) ) |
let test_12 ( ) = Alcotest . ( check bool ) " test 12 " true ( To_test . test_12 ( ) ) |
let test_13 ( ) = Alcotest . ( check bool ) " test 13 " true ( To_test . test_13 ( ) ) |
let test_14 ( ) = Alcotest . ( check bool ) " test 14 " true ( To_test . test_14 ( ) ) |
let test_15 ( ) = Alcotest . ( check bool ) " test 15 " true ( To_test . test_15 ( ) ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.